Utils

reperiods.utils.duration_function(series: Series, production_normalized=False, time_normalized=True)[source]

Returns a function that calculates the duration of a time series above a given threshold. This function considered that all point represent the same duration.

Parameters:
  • series (pd.Series) – A pandas series representing a time series like load or production.

  • production_normalized (bool, optional) – Whether to normalize the series to be between 0 and 1. Defaults to True.

  • time_normalized (bool, optional) – Whether to return a function that normalizes the duration as a proportion of the total series length. Defaults to True.

Returns:

A lambda function that takes a threshold value and returns the duration of the series above that threshold, either as a proportion of the total series length or as a raw count, depending on the value of time_normalized.

Return type:

function

Example

duration_func = duration_function(series) duration_above_5 = duration_func(5) # calculates the duration of the series above 5