Skip to content

Commit

Permalink
Merge pull request #81 from USDA-ARS-NWRC/68_smrf_integration
Browse files Browse the repository at this point in the history
68 smrf integration
  • Loading branch information
Scott Havens authored Oct 2, 2020
2 parents 17917d5 + 5f16ada commit a40046a
Show file tree
Hide file tree
Showing 20 changed files with 1,015 additions and 1,555 deletions.
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):
"""
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)

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

0 comments on commit a40046a

Please sign in to comment.