pywatershed.PRMSChannel#
- class pywatershed.PRMSChannel(control, discretization, parameters, sroff_vol, ssres_flow_vol, gwres_flow_vol, imbalance_behavior='defer', calc_method=None, adjust_parameters='warn', input_aliases=None, verbose=None, restart_read=False, restart_write=False, restart_write_freq=False)[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:
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 objectdiscretization (
Parameters) – a discretization of class Parametersparameters (
Parameters) – a parameter object of class Parameterssroff_vol (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Surface runoff to the stream network for each HRUssres_flow_vol (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Interflow volume from gravity and preferential-flow reservoirs to the stream network for each HRUgwres_flow_vol (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Groundwater discharge volume from each GWR to the stream networkimbalance_behavior (
Literal['defer',None,'warn','error']) – one of [“defer”, None, “warn”, “error”] with “defer” being the default and defering to control.options[“imbalance_behavior”] when available. When control.options[“imbalance_behavior”] is not avaiable, imbalance_behavior is set to “warn”.calc_method (
Literal['numba','numpy']) – one of [“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 (
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','f',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, sroff_vol, ssres_flow_vol, gwres_flow_vol, imbalance_behavior='defer', calc_method=None, adjust_parameters='warn', input_aliases=None, verbose=None, restart_read=False, restart_write=False, restart_write_freq=False)[source]#
Methods
__init__(control, discretization, ...[, ...])advance()Advance the Process in time.
calculate(time_length, **kwargs)Calculate Process terms for a time step
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 variable names for energy budget terms.
Get a dictionary of initialization values for each public variable.
Get a tuple of input variable names for this Process.
Get a dictionary of variable names for mass budget terms.
Get a tuple of parameter names for this Process.
Get a dict of restart varible names mapping current: previous.
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
Legacy property for backward compatibility - returns mass budget.
A tuple of parameter names.
The energy budget for this process, if enabled.
A dictionary of variable names for the energy budget terms.
A dictionary of initial values for each public variable.
A tuple of input variable names.
The mass budget for this process, if enabled.
A dictionary of variable names for the mass budget terms.
A tuple of parameter names.
previous.
A tuple of public variable names.
- advance()#
Advance the Process in time.
- Returns:
None
- property budget#
Legacy property for backward compatibility - returns mass budget.
Deprecated since version The: ‘budget’ property is deprecated. Use ‘mass_budget’ instead.
- calculate(time_length, **kwargs)#
Calculate Process terms for a time step
- Parameters:
simulation_time – current simulation time
- Return type:
- Returns:
None
- classmethod description()#
A dictionary description of this Process.
- Return type:
- Returns:
All metadata for all variables in inputs, variables, parameters, mass_budget_terms, and energy_budget_terms for this Process.
- property energy_budget#
The energy budget for this process, if enabled.
- finalize()#
Finalize the Process, output methods, and close input adapters.
- Return type:
- Returns:
None
- classmethod get_energy_budget_terms()#
Get a dictionary of variable names for energy budget terms.
- Return type:
- static get_init_values()[source]#
Get a dictionary of initialization values for each public variable.
- Return type:
- static get_mass_budget_terms()[source]#
Get a dictionary of variable names for mass budget terms.
- Return type:
- static get_restart_variables()[source]#
Get a dict of restart varible names mapping current: previous.
- 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, budget_args=None, output_vars=None, extra_coords=None, addtl_output_vars=None)#
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.
- Return type:
- Returns:
None
- property mass_budget#
The mass budget for this process, if enabled.
- property outflow_mask#
- 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?