energy_analysis_toolbox.timeseries.resample.interpolate module#

Apply basic maths transformations to be applied to timeseries of physical values.

This module defines utilities used to create fine-sampled timeseries from coarse sampled one:

Resampling to coarser resolution may be done as well, but the relevance may be questioned VS a well-chosen aggregation.

See also

In case the series to be resampled must satisfy conservation laws

energy_analysis_toolbox.timeseries.power.conservative

energy_analysis_toolbox.timeseries.resample.interpolate.piecewise_affine(timeseries: Series | float, target_instants: DatetimeIndex) Series[source]#

Return resampled timeseries assuming a piecewise affine function of time.

Parameters:
  • timeseries (pd.Series or float) – Series of values of a function of time, indexed using DateTimeIndex.

  • target_instants (pd.DatetimeIndex) – Dates at which the series values are required, sorted in ascending order.

Returns:

new_series (pd.Series) – Values of the function, interpolated at target times, indexed with target_instants.

Warning

The returned values may not be relevant when some target times are required outside the convex span of the input samples: the corresponding border value is used for these target times.

See also

np.interp on which the interpolation is based.

energy_analysis_toolbox.timeseries.resample.interpolate.piecewise_constant(timeseries: Series, target_instants: DatetimeIndex, left_pad: float | None = None) Series[source]#

Return resampled timeseries assuming a piecewise constant function of time.

Parameters:
  • timeseries (pd.Series or float) – Series of values of a function of time, indexed using DateTimeIndex.

  • target_instants (pd.DatetimeIndex) – A sequence of target timestamps, sorted in ascending order.

  • left_pad (float or None, optional) – A value to be used for target instants which are located before the first instant in timeseries. The default is None in which case, the value of the first instant is used.

Returns:

new_series (pd.Series) – Values of the series interpolated at target times, indexed with target_instants.

See also

np.digitize on which the function is based.