scmdata.timeseries

TimeSeries handling

Functionality for handling and storing individual time-series

TimeSeries

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

Bases: 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:

Timeseries

interpolate(target_times, interpolation_type='linear', extrapolation_type='linear')[source]

Interpolate the timeseries onto a new time axis

Parameters:
Returns:

TimeSeries – A new TimeSeries with the new time dimension

property meta

Metadata associated with the timeseries

Returns:

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 (typing.Any) – Additional arguments passed to xarray’s DataArray.reindex function

Returns:

TimeSeries – A new TimeSeries with the new time dimension

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:

numpy.ndarray

property values

Get the data as a numpy array

Returns:

numpy.ndarray