pywatershed.PRMSAtmosphere#
- class pywatershed.PRMSAtmosphere(control, discretization, parameters, prcp, tmax, tmin, soltab_potsw, soltab_horad_potsw, input_aliases=None, verbose=False, restart_read=False, restart_write=False, restart_write_freq=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 Parameterssoltab_potsw (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – the solar table of potential shortwave radiationsoltab_horad_potsw (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – the solar table of potential shortwave radiation on a horizontal planeverbose (
bool) – Print extra information or not?restart_read (
Union[Path,bool]) – May be boolean or a Pathlib.Path. If False, control.options will be examined for this key. If True, the working directory is searched for restart files. If a Pathlib.Path, this specifies an alternative directory to search for restart files. Files searched for are of the pattern YYYY-mm-dd-varname.nc where the date is the control.init_time. The timestamp on the file is the valid time of the states in the file with the exception of processes with sub-daily timesteps. For example, the outflow_ts variable of PRMSChannel is instantaneous and valid at the 23rd hour of the timestampped day whereas its variable seg_outflow is the daily averge value over the timestampped day.restart_write (
Union[Path,bool]) – As for restart_read but for writing. The directory in either case will be attempted to be created if it does not exist.restart_write_freq (
Literal['y','m','d',False]) – If False, then control.options is examined for this key. The follwing values set the frequency of restart output with “y” for yearly, “m” for monthly, “d” for daily, or “f” for final. “Final” means that restart files are written with the states at control.end_time to files timestampped with control.end_time. Yearly and monthly restart options write files with timestamps on the last day of each year or month during the run. If daily, restarts are written every day. If restart_write is not False and restart_write_freq is False, the default of “f” is used.
- __init__(control, discretization, parameters, prcp, tmax, tmin, soltab_potsw, soltab_horad_potsw, input_aliases=None, verbose=False, restart_read=False, restart_write=False, restart_write_freq=False)[source]#
Methods
__init__(control, discretization, ...[, ...])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()Finalize the Process, output methods, and close input adapters.
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.
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, ...)Set input variables to adapter.current and manage the adapter.
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.
previous.
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.
- finalize()#
Finalize the Process, output methods, and close input adapters.
- Return type:
- Returns:
None
- static get_init_values()[source]#
Get a dictionary of initialization values for each public variable.
- Return type:
- classmethod get_variables()#
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 ([<class ‘str’>, <class ‘pathlib.Path’>]) – base directory path or NetCDF file path if separate_files is True
separate_files (
bool) – boolean indicating if storage component output variables should be written to a separate file for each variableoutput_vars (
list) – list of variable names to output.
- 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)#
Set input variables to adapter.current and manage the adapter.
TODO: make this private?