pywatershed.base.ConservativeProcess#
- class pywatershed.base.ConservativeProcess(control, discretization, parameters, budget_type=None, metadata_patches=None, metadata_patch_conflicts='error')[source]#
Base class for representation of conservative physical processes.
ConservativeProcess is a base class for mass and energy conservation which extends the
Process()
class with a budget on mass (energy in the future). Please seeProcess()
for many details on the design of this parent class. In ConservativeProcess only mass conservation is currently implemented. Budgets can optionally be established for mass (and eventually energ) and these can be enforced or simply diagnosed with the model run.Conventions are adopted through the use of the following properties/methods:
- mass_budget_terms/get_mass_budget_terms():
These terms must all in in the same units across all components of the budget (inputs, outputs, storage_changes). Diagnostic variables should not appear in the budget terms, only prognostic variables should.
- _calculate():
This method is to be overridden by the subclass. Near the end of the method, the subclass should calculate its changes in mass and energy storage in an obvious way. As commented for mass_budget_terms, storage changes should only be tracked for prognostic variables. (For example is snow_water_equiv = snow_ice + snow_liquid, then storage changes for snow_ice and snow_liquid should be tracked and not for snow_water_equiv).
- Parameters:
control (
Control
) – A Control objectdiscretization (
Parameters
) – A discretization objectparameters (
Parameters
) – The parameters for this objectbudget_type (
Optional
[Literal
[None
,'warn'
,'error'
]]) – Use a budget and what action to take on budget imbalance.metadata_patches (
Optional
[dict
[dict
]]) – Override static metadata for any public parameter or variable – experimental.metadata_patch_conflicts (
Literal
['ignore'
,'warn'
,'error'
]) – How to handle metadata_patches conflicts. Experimental.
- __init__(control, discretization, parameters, budget_type=None, metadata_patches=None, metadata_patch_conflicts='error')[source]#
Methods
__init__
(control, discretization, parameters)advance
()Advance the Process in time.
calculate
(time_length, **kwargs)Calculate Process terms for a time step
A dictionary description of this Process.
finalize
()Finalizes the Process, including output methods.
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 dictionary of variable names for mass budget terms.
Get a tuple of parameter names for this Process.
Get 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, ...)Attributes
A tuple of parameter names.
A dictionary of initial values for each public variable.
A tuple of input variable names.
A dictionary of variable names for the mass budget terms.
A tuple of parameter names.
A tuple of restart variable names.
A tuple of public variable names.
- advance()#
Advance the Process in time.
- Returns:
None
- calculate(time_length, **kwargs)[source]#
Calculate Process terms for a time step
- Parameters:
simulation_time – current simulation time
- Return type:
- Returns:
None
- classmethod description()[source]#
A dictionary description of this Process.
- Return type:
- Returns:
All metadata for all variables in inputs, variables,parameters, and mass_budget_terms for this Process.
- static get_init_values()#
Get a dictionary of initialization values for each public variable.
- Return type:
- classmethod get_mass_budget_terms()[source]#
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)[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
- output_to_csv(pth)#
Save each output variable to separate csv file in specified path