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:

Markstrom, S. L., Regan, R. S., Hay, L. E., Viger, R. J., Webb, R. M., Payn, R. A., & LaFontaine, J. H. (2015). PRMS-IV, the precipitation-runoff modeling system, version 4. US Geological Survey Techniques and Methods, 6, B7.

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 object

  • discretization (Parameters) – a discretization of class Parameters

  • parameters (Parameters) – a parameter object of class Parameters

  • prcp ([<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 radiation

  • soltab_horad_potsw (Union[str, Path, ndarray, Adapter]) – the solar table of potential shortwave radiation on a horizontal plane

  • verbose (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])

adjust_precip()

Input precipitation adjustments using calibrated parameters.

adjust_temperature()

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_et_jh()

Calculate potential evapotranspiration following Jensen and Haise

calculate_sw_rad_degree_day()

Calculate shortwave radiation using the degree day method.

calculate_transp_tindex()

description()

A dictionary description of this Process.

finalize()

Finalizes the Process, including output methods.

get_dimensions()

Get a tuple of dimension names for this Process.

get_init_values()

Get a dictionary of initialization values for each public variable.

get_inputs()

Get a tuple of input variable names for this Process.

get_parameters()

Get a tuple of parameter names for this Process.

get_restart_variables()

Get a list of restart varible names.

get_variables()

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

dimensions

A tuple of parameter names.

init_values

A dictionary of initial values for each public variable.

inputs

A tuple of input variable names.

parameters

A tuple of parameter names.

restart_variables

A tuple of restart variable names.

variables

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

adjust_temperature()[source]#

Input temperature adjustments using calibrated parameters.

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:

None

Returns:

None

calculate_potential_et_jh()[source]#

Calculate potential evapotranspiration following Jensen and Haise

Jensen and Haise (1963)

Return type:

None

Returns:

None

calculate_sw_rad_degree_day()[source]#

Calculate shortwave radiation using the degree day method.

Return type:

None

Returns:

None

calculate_transp_tindex()[source]#
classmethod description()#

A dictionary description of this Process.

Return type:

dict

Returns:

All metadata for all variables in inputs, variables, and parameters.

property dimensions: tuple#

A tuple of parameter names.

finalize()#

Finalizes the Process, including output methods. :rtype: None :returns: None

static get_dimensions()[source]#

Get a tuple of dimension names for this Process.

static get_init_values()[source]#

Get a dictionary of initialization values for each public variable.

Return type:

dict

static get_inputs()[source]#

Get a tuple of input variable names for this Process.

Return type:

tuple

static get_parameters()[source]#

Get a tuple of parameter names for this Process.

static get_restart_variables()#

Get a list of restart varible names.

Return type:

list

static get_variables()[source]#

Get a tuple of (public) variable names for this Process.

Return type:

tuple

property init_values: dict#

A dictionary of initial values for each public variable.

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

property inputs: tuple#

A tuple of input variable names.

output()[source]#

Output data to previously initialized output types. :returns: None

output_to_csv(pth)#

Save each output variable to separate csv file in specified path

property parameters: tuple#

A tuple of parameter names.

property restart_variables: tuple#

A tuple of restart variable names.

set_input_to_adapter(input_variable_name, adapter)#
property variables: tuple#

A tuple of public variable names.