smrf.framework package

Submodules

smrf.framework.model_framework module

The module model_framework contains functions and classes that act as a major wrapper to the underlying packages and modules contained with SMRF. A class instance of SMRF is initialized with a configuration file indicating where data is located, what variables to distribute and how, where to output the distributed data, or run as a threaded application. See the help on the configuration file to learn more about how to control the actions of SMRF.

Example

The following examples shows the most generic method of running SMRF. These commands will generate all the forcing data required to run iSnobal. A complete example can be found in run_smrf.py

>>> import smrf
>>> s = smrf.framework.SMRF(configFile) # initialize SMRF
>>> s.loadTopo() # load topo data
>>> s.initializeDistribution() # initialize the distribution
>>> s.initializeOutput() # initialize the outputs if desired
>>> s.loadData() # load weather data  and station metadata
>>> s.distributeData() # distribute
class smrf.framework.model_framework.SMRF(config, external_logger=None)[source]

Bases: object

SMRF - Spatial Modeling for Resources Framework

Parameters

configFile (str) – path to configuration file.

Returns

SMRF class instance.

start_date

start_date read from configFile

end_date

end_date read from configFile

date_time

Numpy array of date_time objects between start_date and end_date

config

Configuration file read in as dictionary

distribute

Dictionary the contains all the desired variables to distribute and is initialized in initializeDistribution()

create_distributed_threads()[source]

Creates the threads for a distributed run in smrf. Designed for smrf runs in memory

Returns

t: list of threads for distirbution q: queue

distributeData()[source]

Wrapper for various distribute methods. If threading was set in configFile, then distributeData_threaded() will be called. Default will call distributeData_single().

distributeData_single()[source]

Distribute the measurement point data for all variables in serial. Each variable is initialized first using the smrf.data.loadTopo.Topo() instance and the metadata loaded from loadData(). The function distributes over each time step, all the variables below.

Steps performed:
  1. Sun angle for the time step

  2. Illumination angle

  3. Air temperature

  4. Vapor pressure

  5. Wind direction and speed

  6. Precipitation

  7. Cloud Factor

  8. Solar radiation

  9. Thermal radiation

  10. Soil temperature

  11. Output time step if needed

distributeData_threaded()[source]

Distribute the measurement point data for all variables using threading and queues. Each variable is initialized first using the smrf.data.loadTopo.Topo() instance and the metadata loaded from loadData(). A DateQueue is initialized for all threading variables. Each variable in smrf.distribute() is passed all the required point data at once using the distribute_thread function. The distribute_thread function iterates over date_time and places the distributed values into the DateQueue.

initializeDistribution()[source]

This initializes the distirbution classes based on the configFile sections for each variable. initializeDistribution() will initialize the variables within the smrf.distribute() package and insert into a dictionary ‘distribute’ with variable names as the keys.

Variables that are intialized are:
initializeOutput()[source]

Initialize the output files based on the configFile section [‘output’]. Currently only NetCDF files is supported.

loadData()[source]

Load the measurement point data for distributing to the DEM, must be called after the distributions are initialized. Currently, data can be loaded from three different sources:

After loading, loadData() will call smrf.framework.model_framework.find_pixel_location() to determine the pixel locations of the point measurements and filter the data to the desired stations if CSV files are used.

loadTopo(calcInput=True)[source]

Load the information from the configFile in the [‘topo’] section. See smrf.data.loadTopo.Topo() for full description.

modules = ['air_temp', 'albedo', 'precip', 'soil_temp', 'solar', 'cloud_factor', 'thermal', 'vapor_pressure', 'wind']
output(current_time_step, module=None, out_var=None)[source]

Output the forcing data or model outputs for the current_time_step.

Parameters
  • current_time_step (date_time) – the current time step datetime object

  • - (var_name) –

  • -

post_process()[source]

Execute all the post processors

thread_variables = ['cosz', 'azimuth', 'illum_ang', 'air_temp', 'dew_point', 'vapor_pressure', 'wind_speed', 'precip', 'percent_snow', 'snow_density', 'last_storm_day_basin', 'storm_days', 'precip_temp', 'clear_vis_beam', 'clear_vis_diffuse', 'clear_ir_beam', 'clear_ir_diffuse', 'albedo_vis', 'albedo_ir', 'net_solar', 'cloud_factor', 'thermal', 'output', 'veg_ir_beam', 'veg_ir_diffuse', 'veg_vis_beam', 'veg_vis_diffuse', 'cloud_ir_beam', 'cloud_ir_diffuse', 'cloud_vis_beam', 'cloud_vis_diffuse', 'thermal_clear', 'wind_direction']
title(option)[source]

A little title to go at the top of the logger file

smrf.framework.model_framework.can_i_run_smrf(config)[source]

Function that wraps run_smrf in try, except for testing purposes

Parameters

config – string path to the config file or inicheck UserConfig instance

smrf.framework.model_framework.find_pixel_location(row, vec, a)[source]

Find the index of the stations X/Y location in the model domain

Parameters
  • row (pandas.DataFrame) – metadata rows

  • vec (nparray) – Array of X or Y locations in domain

  • a (str) – Column in DataFrame to pull data from (i.e. ‘X’)

Returns

Pixel value in vec where row[a] is located

smrf.framework.model_framework.run_smrf(config)[source]

Function that runs smrf how it should be operate for full runs.

Parameters

config – string path to the config file or inicheck UserConfig instance

Module contents