pywrdrb.OutputRecorder#
- class pywrdrb.OutputRecorder(model, output_filename, nodes=None, parameters=None, **kwargs)#
Used to record and save data from the pywr model simulation.
This uses the pywr.Recorder class as a base class and is designed to be efficient (quick) while tracking all variables from the model. The data is saved to an HDF5 file. Manually adds a “time” dataset to the HDF5 file to store the datetime index, which is expected to be available in the pywrdrb loading methods.
- _get_model_node_names()#
Get a list of all pywr.core.Node objects from the model instance.
- _get_model_parameter_names()#
Get a list of all pywr.core.Parameter objects from the model instance.
- setup()#
Sets up the recorders.
- reset()#
Reset the recorders.
- after()#
Performed after each timestep.
- finish()#
Saves data to an HDF5 file.
- to_hdf5()#
Saves all data from the recorders to an HDF5 file. Used by finish().
- model#
The pywrdrb model instance to record data from.
- Type:
- output_filename#
The name of the output HDF5 file to save the data to, at the end of simulation.
- Type:
str
- nodes#
A list of pywr.core.Node objects to record data from. If None, all nodes with names will be recorded.
- Type:
list[pywr.core.Node], optional
- parameters#
A list of pywr.core.Parameter objects to record data from. If None, all parameters with names will be recorded.
- Type:
list[pywr.core.Parameter], optional
- recorder_dict#
A dictionary of recorders for each parameter and node.
- Type:
dict
- reservoir_list#
A list of reservoir names to determine when Storage recorder should be used.
- Type:
list
- __init__(model, output_filename, nodes=None, parameters=None, **kwargs)#
Initialize the OutputRecorder.
Different NumpyArray recorders are initialized for different variables in the model.
- Parameters:
model (pywrdrb.Model) – The pywrdrb model instance to record data from.
output_filename (str) – The name of the output HDF5 file to save the data to, at the end of simulation.
nodes (list[pywr.core.Node], optional) – A list of pywr.core.Node objects to record data from. If None, all nodes with names will be recorded.
parameters (list[pywr.core.Parameter], optional) – A list of pywr.core.Parameter objects to record data from. If None, all parameters with names will be recorded.
**kwargs (optional) – Additional keyword arguments to pass to the base pywr.Recorders class (unused).
- Return type:
None
Methods
__init__
(model, output_filename[, nodes, ...])Initialize the OutputRecorder.
after
()Performed after each timestep.
aggregated_value
(self)before
(self)finish
()Saves data to an hdf5.
is_constraint_violated
(self)Returns true if the value from this Recorder violates its constraint bounds.
load
(cls, model, data)register
(cls)reset
()Reset the recorders.
setup
()Sets up the recorders.
to_hdf5
()Saves all data from the recorders to an HDF5 file.
unregister
(cls)values
(self)Attributes
agg_func
children
comment
unicode
constraint_lower_bounds
constraint_upper_bounds
epsilon
'double'
ignore_nan
'bool'
is_constraint
Returns true if either upper or lower constraint bounds is defined.
is_double_bounded_constraint
Returns true if upper and lower constraint bounds are both defined and not-equal to one another.
is_equality_constraint
Returns true if upper and lower constraint bounds are both defined and equal to one another.
is_lower_bounded_constraint
Returns true if lower constraint bounds is defined and upper constraint bounds is not.
is_objective
is_upper_bounded_constraint
Returns true if upper constraint bounds is defined and lower constraint bounds is not.
name
parents
tags
dict