pywatershed.PRMSChannel#

class pywatershed.PRMSChannel(control, discretization, parameters, sroff_vol, ssres_flow_vol, gwres_flow_vol, budget_type=None, calc_method=None, adjust_parameters='warn', verbose=None)[source]#

PRMS channel flow (muskingum_mann).

A representation of channel flow from PRMS.

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.

The muskingum module was originally developed for the Precipitation Runoff Modeling System (PRMS) by Mastin and Vaccaro (2002) and developed further by Markstrom and others (2008). This module has been modified from past versions to make it more stable for stream network routing in watersheds with stream segments with varying travel times. Although this module runs on the same daily time step as the rest of the modules in PRMS, it has an internal structure which allows for a different computational time step for each segment in the stream network, ensuring that the simulation produces stable values. Flow values computed at these finer time steps are aggregated by the Muskingum module to provide consistent daily time step values, regardless of the segment length.

Delta t, which is the travel time (in hours), is rounded down to an even divisor of 24 hours (for example 24, 12, 6, 4, 3, 2, and 1). PRMS is restricted to daily time steps, so Delta t segment can never be more than one day in length. This means that the travel time of any segment in the stream network (K_coef) must be less than one day. An implication of this is that the routed streamflow in each segment is computed using different solution time steps. Consequently, streamflow must be aggregated when flowing from segments with shorter Delta t segment to segments with longer Delta t. Likewise, streamflow must be disaggregated when flowing from segments with longer Delta to shorter Delta t. In either case, flow from upstream segments is averaged and summed to the appropriate value of Delta t.

The muskingum_mann method is a modified version of the original muskingum function in PRMS that was introduced in PRMS version 5.2.1 (1/20/2021). The muskingum_mann method provides a method to calculate K_coef values using mann_n, seg_length, seg_depth (bank full), and seg_slope. The velocity at bank full segment depth is calculated using Manning’s equation

velocity = ((1/n) sqrt(seg_slope) seg_depth**(2/3)

K_coef ,in hours, is then calculated using

K_coef = seg_length / (velocity * 60 * 60)

K_coef values computed greater than 24.0 are set to 24.0, values computed less than 0.01 are set to 0.01, and the value for lake HRUs is set to 24.0.

Parameters:
  • control (Control) – a Control object

  • discretization (Parameters) – a discretization of class Parameters

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

  • sroff_vol (Union[str, Path, ndarray, Adapter]) – Surface runoff to the stream network for each HRU

  • ssres_flow_vol (Union[str, Path, ndarray, Adapter]) – Interflow volume from gravity and preferential-flow reservoirs to the stream network for each HRU

  • gwres_flow_vol (Union[str, Path, ndarray, Adapter]) – Groundwater discharge volume from each GWR to the stream network

  • budget_type (Optional[Literal[None, 'warn', 'error']]) – one of [None, “warn”, “error”]

  • calc_method (Optional[Literal['fortran', 'numba', 'numpy']]) – one of [“fortran”, “numba”, “numpy”]. None defaults to “numba”.

  • adjust_parameters (Literal['warn', 'error', 'no']) – one of [“warn”, “error”, “no”]. Default is “warn”, the code edits the parameters and issues a warning. If “error” is selected the the code issues warnings about all edited parameters before raising the error to give you information. If “no” is selected then no parameters are adjusted and there will be no warnings or errors.

  • verbose (Optional[bool]) – Print extra information or not?

__init__(control, discretization, parameters, sroff_vol, ssres_flow_vol, gwres_flow_vol, budget_type=None, calc_method=None, adjust_parameters='warn', verbose=None)[source]#

Methods

__init__(control, discretization, ...[, ...])

advance()

Advance the Process in time.

calculate(time_length, **kwargs)

Calculate Process terms for a time step

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

Get a dictionary of variable names for mass budget terms.

get_outflow_mask()

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.

mass_budget_terms

A dictionary of variable names for the mass budget terms.

outflow_mask

parameters

A tuple of parameter names.

restart_variables

A tuple of restart variable names.

variables

A tuple of public variable names.

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

classmethod description()#

A dictionary description of this Process.

Return type:

dict

Returns:

All metadata for all variables in inputs, variables,parameters, and mass_budget_terms for this Process.

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.

Return type:

tuple

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_mass_budget_terms()[source]#

Get a dictionary of variable names for mass budget terms.

get_outflow_mask()[source]#
static get_parameters()[source]#

Get a tuple of parameter names for this Process.

Return type:

tuple

static get_restart_variables()#

Get a list of restart varible names.

Return type:

list

classmethod get_variables()#

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, budget_args=None, output_vars=None)#

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.

property mass_budget_terms: dict#

A dictionary of variable names for the mass budget terms.

property outflow_mask#
output()#

Output data to previously initialized output types. :rtype: None :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.