scmdata.timeseries

TimeSeries handling

Functionality for handling and storing individual time-series

class scmdata.timeseries.TimeSeries(data, time=None, **kwargs)[source]

Bases: scmdata._base.OpsMixin

A 1D time-series with metadata

Proxies an xarray.DataArray with a single time dimension

copy()[source]

Create a deep copy of the timeseries.

Any further modifications to the Timeseries returned copy will not be reflected in the current Timeseries

Returns

Return type

Timeseries

interpolate(target_times: Union[numpy.ndarray, List[Union[datetime.datetime, int]]], interpolation_type: str = 'linear', extrapolation_type: str = 'linear')[source]

Interpolate the timeseries onto a new time axis

Parameters
  • target_times – Time grid onto which to interpolate

  • interpolation_type (str) – Interpolation type. Options are ‘linear’

  • extrapolation_type (str or None) – Extrapolation type. Options are None, ‘linear’ or ‘constant’

Returns

A new TimeSeries with the new time dimension

Return type

TimeSeries

property meta

Metadata associated with the timeseries

Returns

Return type

dict

property name

Timeseries name

If no name was provided this will be an automatically incrementing number

reindex(time, **kwargs)[source]

Update the time dimension, filling in the missing values with NaN’s

This is different to interpolating to fill in the missing values. Uses xarray.DataArray.reindex to perform the reindexing

Parameters
  • time (obj:np.ndarray) – Time values to reindex the data to. Should be np.datetime64 values

  • **kwargs – Additional arguments passed to xarray’s DataArray.reindex function

Returns

A new TimeSeries with the new time dimension

Return type

TimeSeries

References

http://xarray.pydata.org/en/stable/generated/xarray.DataArray.reindex_like.html#xarray.DataArray.reindex_like

property time_points

Time points of the data

Returns

Return type

numpy.ndarray

property values

Get the data as a numpy array

Returns

Return type

numpy.ndarray