pywatershed.PRMSStreamTemp#
- class pywatershed.PRMSStreamTemp(control, discretization, parameters, seg_outflow, seg_lateral_inflow, swrad, potet, sroff, ssres_flow, gwres_flow, tavgc, snowmelt, hru_rain, soltab_potsw, seg_flow_width=None, seg_flow_depth=None, seg_flow_area=None, seg_flow_velocity=None, stream_shade=None, stream_shade_class=None, stream_shade_parameters=None, calc_method=None, imbalance_behavior='defer', input_aliases=None, verbose=False, use_vectorized_shade=True, track_energy_fluxes=True, atmos_exchange_factor=1.0)[source]#
PRMS stream temperature with monthly segment humidity parameter.
Corresponds to
strmtemp_humidity_flag=1where humidity is supplied via theseg_humidityparameter (12 monthly values per segment) rather than a time-varying CBH input. All other behaviour is identical toPRMSStreamTempHumidityCBH.- Parameters:
control (
Control) – a Control objectdiscretization (
Parameters) – a discretization of class Parametersparameters (
Parameters) – a parameter object of class Parameters — must includeseg_humiditywith shape(nmonth, nsegment)seg_outflow (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Streamflow leaving each segment (from PRMSChannel)seg_lateral_inflow (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Lateral inflow entering each segmentswrad (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Solar radiation for each HRUpotet (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Potential ET for each HRUsroff (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Surface runoff for each HRUssres_flow (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Subsurface flow for each HRUgwres_flow (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Groundwater flow for each HRUtavgc (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Average air temperature for each HRU in Celsiussnowmelt (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Snowmelt for each HRUhru_rain (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Rainfall for each HRUsoltab_potsw (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Potential shortwave radiation table for current dayseg_flow_width (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Flow-dependent width from PRMSHydraulicGeometryFullseg_flow_depth (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Flow-dependent depth from PRMSHydraulicGeometryFullseg_flow_area (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Flow-dependent cross-sectional areaseg_flow_velocity (
Union[str,Path,ndarray,Adapter,PrmsDynamicParameter]) – Flow-dependent velocitystream_shade (
Optional[PRMSStreamShade]) – PRMSStreamShade instancestream_shade_class (
Optional[type]) – Class to use for stream shade computationstream_shade_parameters (
Union[Parameters,Path,None]) – Parameters for stream shade computationimbalance_behavior (
Literal['defer',None,'warn','error']) – one of [“defer”, None, “warn”, “error”]verbose (
bool) – Print extra information or not?use_vectorized_shade (
bool) – Use vectorized shade computationtrack_energy_fluxes (
bool) – Track energy flux terms for budget analysis
- __init__(control, discretization, parameters, seg_outflow, seg_lateral_inflow, swrad, potet, sroff, ssres_flow, gwres_flow, tavgc, snowmelt, hru_rain, soltab_potsw, seg_flow_width=None, seg_flow_depth=None, seg_flow_area=None, seg_flow_velocity=None, stream_shade=None, stream_shade_class=None, stream_shade_parameters=None, calc_method=None, imbalance_behavior='defer', input_aliases=None, verbose=False, use_vectorized_shade=True, track_energy_fluxes=True, atmos_exchange_factor=1.0)[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 energy budget terms for stream temperature.
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.
A list of restart varible names.
Get a tuple of (public) variable names for this Process.
initialize_netcdf([output_dir, ...])Initialize NetCDF output with energy flux tracking checks.
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
- static get_energy_budget_terms()#
Get energy budget terms for stream temperature.
- Return type:
- Returns:
Dictionary with inputs, outputs, exchanges, and storage_changes for energy budget.
Notes
Energy fluxes are computed in Watts (J/s). The budget tracks: - Advective heat transport (upstream, lateral, outflow) - Surface energy exchange (solar, longwave, evaporation) - Internal sources (friction, groundwater conduction) - Bi-directional exchanges that can be gains or losses
Storage changes are empty because the kinematic wave assumption means water storage is constant - only temperature (and thus heat content) changes, which is captured by the balance of inputs and outputs.
Exchanges are net fluxes that can be positive (heat gain) or negative (heat loss) depending on temperature gradients: - convective_exchange: depends on air vs water temperature While it seems that the following could be exchanges, their current formulation restricts their sign and they have been categorized to match that pre-determined sign: - longwave_vegetation: net longwave exchange with vegetation - groundwater_conduction: depends on groundwater vs water temp
- static get_init_values()#
Get a dictionary of initialization values for each public variable.
- Return type:
- static get_mass_budget_terms()#
Get a dictionary of variable names for mass budget terms.
- 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 with energy flux tracking checks.
This method overrides the parent class to add consistency checks for energy flux tracking.
- Parameters:
output_dir (
Union[str,Path]) – base directory path or NetCDF file path if separate_files is Trueseparate_files (
bool) – boolean indicating if storage component output variables should be written to a separate file for each variablebudget_args (
dict) – arguments to pass to budget initializationoutput_vars (
list) – list of variable names to outputextra_coords (
dict) – extra coordinates to add to the outputaddtl_output_vars (
list) – additional output variables
- Return type:
- Returns:
None
- property mass_budget#
The mass budget for this process, if enabled.
- 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?