pywr.recorders.TablesRecorder

class pywr.recorders.TablesRecorder(model, h5file, nodes=None, parameters=None, where='/', time='/time', routes_flows=None, routes='/routes', scenarios='/scenarios', **kwargs)

A recorder that saves to PyTables CArray

This Recorder creates a CArray for every node passed to the constructor. Each CArray stores the data for all scenarios on the specific node. This is useful for analysis of Node statistics across multiple scenarios.

__init__(model, h5file, nodes=None, parameters=None, where='/', time='/time', routes_flows=None, routes='/routes', scenarios='/scenarios', **kwargs)
Parameters
modelpywr.model.Model

The model to record nodes from.

h5filetables.File or filename

The tables file handle or filename to attach the CArray objects to. If a filename is given the object will open and close the file handles.

nodesiterable or None

Nodes to save in the tables database. Can be an iterable of Node objects or node names. It can also be a iterable of tuples with a node specific where keyword as the first item and a Node object or name as the second item. If an iterable of tuples is provided then the node specific where keyword is used in preference to the where keyword (see below).

parametersiterable or None

Parameters to save. Similar to the nodes keyword, except refers to Parameter objects or names thereof.

wherestring

Default path to create the CArrays inside the database.

timestring

Default full node path to save a time tables.Table. If None no table is created.

scenariosstring

Default full node path to save a scenarios tables.Table. If None no table is created.

routes_flowsstring

Relative (to where) node path to save the routes flow CArray. If None (default) no array is created.

routesstring

Full node path to save the routes tables.Table. If None not table is created.

filter_kwdsdict

Filter keywords to pass to tables.open_file when opening a file.

modestring

Model argument to pass to tables.open_file. Defaults to ‘w’

metadatadict

Dict of user defined attributes to save on the root node (root._v_attrs)

create_directoriesbool

If a file path is given and create_directories is True then attempt to make the intermediate directories. This uses os.makedirs() underneath.

Methods

__init__(model, h5file[, nodes, parameters, …])

Parameters

after()

Save data to the tables

aggregated_value(self)

before(self)

finish(self)

generate_dataframes(h5file[, time, scenarios])

Helper function to generate pandas dataframes from TablesRecorder data.

is_constraint_violated(self)

Returns true if the value from this Recorder violates its constraint bounds.

load(type cls, model, data)

register(type cls)

reset(self)

setup()

Setup the tables

unregister(type cls)

values(self)

Attributes

agg_func

children

comment

comment: unicode

constraint_lower_bounds

constraint_upper_bounds

epsilon

epsilon: ‘double’

ignore_nan

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.

model

name

parents