pywatershed.PRMSAtmosphere#
- class pywatershed.PRMSAtmosphere(control, discretization, parameters, prcp, tmax, tmin, soltab_potsw, soltab_horad_potsw, verbose=False)[source]#
PRMS atmospheric boundary layer model.
Implementation based on PRMS 5.2.1 with theoretical documentation given in the PRMS-IV documentation:
This representation uses precipitation and temperature inputs. Relative humidity could be added as well.
The boundary layer calculates and manages the following variables (given by PRMSAtmosphere.get_variables()):
tmaxf, tminf, prmx, hru_ppt, hru_rain, hru_snow, swrad, potet, transp_on
PRMS adjustments to temperature and precipitation are applied here to the inputs. Shortwave radiation (using degree day method) and potential evapotranspiration (Jensen and Haise ,1963) and a temperature based transpiration flag (transp_on) are also calculated.
Note that all variables are calculated for all time upon the first advance and that all calculated variables are written to NetCDF (when netcdf output is requested) the first time output is requested. This is effectively a complete preprocessing of the input CBH files to the fields the model actually uses on initialization. For an example of preprocessing the variables in PRMSAtmosphere, see this notebook.
The full time version of a variable is given by the “private” version of the variable which is named with a single-leading underscore (eg tmaxf for all time is _tmaxf).
This full-time initialization may not be tractable for large domains and/or long periods of time and require changes to batch the processing of the variables. The benefits of full-time initialization are 1) the code is vectorized and fast for such a large calculation, 2) the initialization of this class effectively preprocess all the inputs to the rest of the model and can then be skipped in subsequent model calls (unless the parameters are changing).
- Parameters:
control (
Control
) – a Control objectdiscretization (
Parameters
) – a discretization of class Parametersparameters (
Parameters
) – a parameter object of class Parametersprcp ([<class 'str'>, <class 'pathlib.Path'>]) – daily precipitation
tmax ([<class 'str'>, <class 'pathlib.Path'>]) – daily maximum temperature
tmin ([<class 'str'>, <class 'pathlib.Path'>]) – daily minimum temperature
soltab_potsw (
Union
[str
,Path
,ndarray
,Adapter
]) – the solar table of potential shortwave radiationsoltab_horad_potsw (
Union
[str
,Path
,ndarray
,Adapter
]) – the solar table of potential shortwave radiation on a horizontal planeverbose (
bool
) – Print extra information or not?
- __init__(control, discretization, parameters, prcp, tmax, tmin, soltab_potsw, soltab_horad_potsw, verbose=False)[source]#
Methods
__init__
(control, discretization, ...[, verbose])Input precipitation adjustments using calibrated parameters.
Input temperature adjustments using calibrated parameters.
advance
()Advance the Process in time.
calculate
(time_length, **kwargs)Calculate Process terms for a time step
Calculate potential evapotranspiration following Jensen and Haise
Calculate shortwave radiation using the degree day method.
A dictionary description of this Process.
finalize
()Finalizes the Process, including output methods.
Get a tuple of dimension names for this Process.
Get a dictionary of initialization values for each public variable.
Get a tuple of input variable names for this Process.
Get a tuple of parameter names for this Process.
Get a list of restart varible names.
Get a tuple of (public) variable names for this Process.
initialize_netcdf
([output_dir, ...])Initialize NetCDF output.
output
()Output data to previously initialized output types.
output_to_csv
(pth)Save each output variable to separate csv file in specified path
set_input_to_adapter
(input_variable_name, ...)Attributes
A tuple of parameter names.
A dictionary of initial values for each public variable.
A tuple of input variable names.
A tuple of parameter names.
A tuple of restart variable names.
A tuple of public variable names.
- adjust_precip()[source]#
Input precipitation adjustments using calibrated parameters.
Snow/rain partitioning of total precip depends on adjusted temperature in addition to depending on additonal parameters.
- Returns:
None
- advance()#
Advance the Process in time.
- Returns:
None
- calculate(time_length, **kwargs)#
Calculate Process terms for a time step
- Parameters:
simulation_time – current simulation time
- Return type:
- Returns:
None
- calculate_potential_et_jh()[source]#
Calculate potential evapotranspiration following Jensen and Haise
Jensen and Haise (1963)
- Return type:
- Returns:
None
- calculate_sw_rad_degree_day()[source]#
Calculate shortwave radiation using the degree day method.
- Return type:
- Returns:
None
- classmethod description()#
A dictionary description of this Process.
- Return type:
- Returns:
All metadata for all variables in inputs, variables, and parameters.
- static get_init_values()[source]#
Get a dictionary of initialization values for each public variable.
- Return type:
- static get_variables()[source]#
Get a tuple of (public) variable names for this Process.
- Return type:
- initialize_netcdf(output_dir=None, separate_files=None, output_vars=None, **kwargs)[source]#
Initialize NetCDF output.
- Parameters:
output_dir – base directory path or NetCDF file path if separate_files is True
separate_files – boolean indicating if storage component output variables should be written to a separate file for each variable
output_vars – list of variable names to outuput.
- Returns:
None
- output_to_csv(pth)#
Save each output variable to separate csv file in specified path
- set_input_to_adapter(input_variable_name, adapter)#