TimeSeriesData

(class from pyomo.contrib.mpc.data.series_data)

class pyomo.contrib.mpc.data.series_data.TimeSeriesData(data, time, time_set=None, context=None)[source]

Bases: _DynamicDataBase

An object to store time series data associated with time-indexed variables.

Parameters:
  • data (dict or ComponentMap) – Maps variables, names, or CUIDs to lists of values

  • time (list) – Contains the time points corresponding to variable data points.

  • time_set (ContinuousSetData)

  • context (BlockData)

__init__(data, time, time_set=None, context=None)[source]

Methods

__init__(data, time[, time_set, context])

concatenate(other[, tolerance])

Extend time list and variable data lists with the time points and variable values in the provided TimeSeriesData.

contains_key(key[, context])

Returns whether this object's dict contains the given key.

extract_variables(variables[, context, ...])

Only keep variables specified.

get_cuid(key[, context])

Get the time-indexed CUID corresponding to the provided key

get_data()

Return a dictionary mapping CUIDs to values

get_data_at_time([time, tolerance])

Returns the data associated with the provided time point or points.

get_data_at_time_indices(indices)

Returns data at the specified index or indices of this object's list of time points.

get_data_from_key(key[, context])

Returns the value associated with the given key.

get_time_points()

Get time points of the time series data

shift_time_points(offset)

Apply an offset to stored time points.

to_serializable()

Convert to json-serializable object.

update_data(other[, context])

Updates this object's data dict.

Member Documentation

concatenate(other, tolerance=0.0)[source]

Extend time list and variable data lists with the time points and variable values in the provided TimeSeriesData. The new time points must be strictly greater than the old time points.

contains_key(key, context=None)

Returns whether this object’s dict contains the given key.

extract_variables(variables, context=None, copy_values=False)[source]

Only keep variables specified.

get_cuid(key, context=None)

Get the time-indexed CUID corresponding to the provided key

get_data()

Return a dictionary mapping CUIDs to values

get_data_at_time(time=None, tolerance=0.0)[source]

Returns the data associated with the provided time point or points. This function attempts to map time points to indices, then uses get_data_at_time_indices to actually extract the data. If a provided time point does not exist in the time-index map, binary search is used to find the closest value within a tolerance.

Parameters:
  • time (Float or iterable) – The time point or points corresponding to returned data.

  • tolerance (Float) – Tolerance within which we will search for a matching time point. The default is 0.0, meaning time points must be specified exactly.

Returns:

TimeSeriesData containing only the specified time points or dict mapping CUIDs to values at the specified scalar time point.

Return type:

TimeSeriesData or ScalarData

get_data_at_time_indices(indices)[source]

Returns data at the specified index or indices of this object’s list of time points.

get_data_from_key(key, context=None)

Returns the value associated with the given key.

get_time_points()[source]

Get time points of the time series data

shift_time_points(offset)[source]

Apply an offset to stored time points.

to_serializable()[source]

Convert to json-serializable object.

update_data(other, context=None)

Updates this object’s data dict.