Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

68 smrf integration #81

Merged
merged 20 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
498bd11
cleaned up the smrf connection, need run smrf to accept an extermal l…
scotthavens Sep 22, 2020
ac641bf
moved almost all of pysnobal and smrf into a Pysnobal class, needs cl…
scotthavens Sep 23, 2020
17bc2f4
smrf_ipysnobal not producing results within the tolerance for all of …
scotthavens Sep 23, 2020
7a01564
drying out code for ipysnobal and smrf
scotthavens Sep 24, 2020
2b4f7a0
more drying
scotthavens Sep 24, 2020
1efd52c
run_ipysnobal and run_smrf_ipysnobal producing the same results after…
scotthavens Sep 24, 2020
d74a0ab
expanding the smrf_ipysnobal tests to all lakes tests, lidar update h…
scotthavens Sep 24, 2020
e5f1de4
lidar updates working with both model run types
scotthavens Sep 28, 2020
c567057
smrf_ipysnobal with threading working for all tests
scotthavens Sep 29, 2020
845845b
cleaning up the different types of smrf simulations
scotthavens Sep 29, 2020
05699a5
moved smrf related io into the smrf connector
scotthavens Sep 29, 2020
3b88b67
cleaning up redunant code
scotthavens Sep 29, 2020
a805bb2
get_tstep_info from ipysnobal instead of awsm
Oct 1, 2020
c34b1b8
moving more code into ipysnobal, deleted initialize_model.py and smrf…
Oct 1, 2020
527a9ea
renamed interface.py to smrf_connector, cleaned up imports
Oct 1, 2020
7c72c8b
added test to ensure that HRRR can be loaded in the timestep in all c…
Oct 1, 2020
6248449
cleaning up ipysnobal and added doc strings to all methods
Oct 1, 2020
ede744b
update requirements for smrf 0.11.4
Oct 2, 2020
7f6885a
cleaning up tests
Oct 2, 2020
5f16ada
some more cleanup
Oct 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awsm/framework/CoreConfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ model_type: default = None,

mask_isnobal: default = False,
type = bool,
description = Mask snopack model output.
description = Mask snowpack model output.

[paths]
path_dr: type = criticaldirectory,
Expand Down
50 changes: 28 additions & 22 deletions awsm/framework/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

from awsm.data.init_model import ModelInit
from awsm.framework import ascii_art
from awsm.interface import interface as smin, smrf_ipysnobal as smrf_ipy
from awsm.interface.smrf_connector import SMRFConnector
from awsm.interface.ipysnobal import PySnobal


class AWSM():
Expand All @@ -33,7 +34,7 @@ class AWSM():
Attributes:
"""

def __init__(self, config):
def __init__(self, config, testing=False):
jomey marked this conversation as resolved.
Show resolved Hide resolved
"""
Initialize the model, read config file, start and end date, and logging
Args:
Expand All @@ -42,6 +43,7 @@ def __init__(self, config):
"""

self.read_config(config)
self.testing = testing

# create blank log and error log because logger is not initialized yet
self.tmp_log = []
Expand Down Expand Up @@ -169,9 +171,11 @@ def __init__(self, config):
# create log now that directory structure is done
# self.create_log()

self.smrf_connector = SMRFConnector(self)

# if we have a model, initialize it
if self.model_type is not None:
self.myinit = ModelInit(
self.model_init = ModelInit(
self.config,
self.topo,
self.path_output,
Expand Down Expand Up @@ -327,37 +331,36 @@ def create_log(self):
for line in self.tmp_err:
self._logger.error(line)

def runSmrf(self):
def run_smrf(self):
"""
Run smrf. Calls :mod: `awsm.interface.interface.smrfMEAS`
Run smrf through the :mod: `awsm.smrf_connector.SMRFConnector`
"""
# modify config and run smrf
smin.smrfMEAS(self)

self.smrf_connector.run_smrf()

def run_smrf_ipysnobal(self):
"""
Run smrf and pass inputs to ipysnobal in memory.
Calls :mod: `awsm.interface.smrf_ipysnobal.run_smrf_ipysnobal`
"""

smrf_ipy.run_smrf_ipysnobal(self)
PySnobal(self).run_smrf_ipysnobal()
# smrf_ipy.run_smrf_ipysnobal(self)

def run_awsm_daily(self):
"""
This function runs
:mod:`awsm.interface.smrf_ipysnobal.run_smrf_ipysnobal` on an
hourly output from Pysnobal, outputting to daily folders, similar
to the HRRR froecast.
"""
# def run_awsm_daily(self):
# """
# This function runs
# :mod:`awsm.interface.smrf_ipysnobal.run_smrf_ipysnobal` on an
# hourly output from Pysnobal, outputting to daily folders, similar
# to the HRRR froecast.
# """

smin.run_awsm_daily(self)
# smin.run_awsm_daily(self)
jomey marked this conversation as resolved.
Show resolved Hide resolved

def run_ipysnobal(self):
"""
Run PySnobal from previously run smrf forcing data
Calls :mod: `awsm.interface.smrf_ipysnobal.run_ipysnobal`
"""
smrf_ipy.run_ipysnobal(self)
PySnobal(self).run_ipysnobal()

def mk_directories(self):
"""
Expand Down Expand Up @@ -571,22 +574,25 @@ def run_awsm_daily_ops(config_file):
run_awsm(new_config)


def run_awsm(config):
def run_awsm(config, testing=False):
"""
Function that runs awsm how it should be operate for full runs.
Args:
config: string path to the config file or inicheck UserConfig instance
testing: only to be used with unittests, if True will convert SMRF data
from to 32-bit then 64-bit to mimic writing the data to a
netcdf. This enables a single set of gold files.
"""
with AWSM(config) as a:
with AWSM(config, testing) as a:
if a.do_forecast:
runtype = 'forecast'
else:
runtype = 'smrf'

if not a.config['isnobal restart']['restart_crash']:
if a.do_smrf:
a.runSmrf()
a.run_smrf()

if a.model_type == 'ipysnobal':
a.run_ipysnobal()
Expand Down
7 changes: 0 additions & 7 deletions awsm/interface/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
# -*- coding: utf-8 -*-

__author__ = """Micah Sandusky"""
__email__ = '[email protected]'

from . import interface, ipysnobal, smrf_ipysnobal, initialize_model, \
pysnobal_io, ingest_data
Loading