pywr.recorders.GaussianKDEStorageRecorder

class pywr.recorders.GaussianKDEStorageRecorder(*args, **kwargs)

A recorder that fits a KDE to a time-series of volume.

This recorder is an extension to NumpyArrayStorageRecorder which, at the end of a simulation, uses kernel density estimation (KDE) to estimate the probability density function of the storage time-series. It returns the probability of being at or below a specified target volume in the aggregated_value() method (i.e. used for optimisation). The recorder flattens data from all scenarios before computing the KDE. Therefore, a single PDF is produced and returned via .to_dataframe().

The user can specify an optional resampling (e.g. to create annual minimum time-series) prior to fitting the KDE. By default the KDE is reflected at the proportional storage bounds (0.0 and 1.0) to represent the boundedness of the distribution. This can be disabled if required.

Parameters:
resample_freqstr or None

If not None the resampling frequency used by prior to distribution fitting.

resample_funcstr or None

If not None the resampling function used prior to distribution fitting.

target_volume_pcfloat

The proportional target volume for which a probability of being at or lower is estimated.

num_pdfint

Number of points in the PDF estimate. Defaults to 101.

use_reflectionbool

Whether to reflect the PDF at the upper and lower bounds (i.e. 0% and 100% volume) to account for the boundedness of the distribution. Defaults to true.

__init__(*args, **kwargs)

Methods

__init__(*args, **kwargs)

after(self)

aggregated_value(self)

before(self)

finish(self)

is_constraint_violated(self)

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

load(cls, model, data)

register(cls)

reset(self)

setup(self)

to_dataframe()

Return a pandas.DataFrame of the estimated PDF.

unregister(cls)

values()

Return the estimated PDF values.

Attributes

agg_func

children

comment

comment: unicode

constraint_lower_bounds

constraint_upper_bounds

data

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

node

parents

proportional

proportional: 'bool'

tags

tags: dict

temporal_agg_func