TemporalData class

class reperiods.temporal_data.TemporalData(data: DataFrame)[source]

Bases: object

calculate_RP(method: str, N_RP: int, RP_length: int, N_bins: int = 15, solver: Any = None)[source]

Calculate representative periods (RPs) using the specified method.

Could be improved using protocol or ABC

Parameters:
  • method (str) – The method to use for RP calculation (“poncelet”, “kmedoids”, or “random”).

  • N_RP (int) – The number of representative periods to calculate.

  • RP_length (int) – The length of each representative period.

  • N_bins (int, optional) – The number of bins for duration curve discretization. Defaults to 15.

  • solver – An optional solver object for optimization (required for “poncelet” method).

Raises:

ValueError – If an invalid method is provided.

Returns:

None

property curve_set: Index

Get the set of curves (column names) in the data.

Returns:

A list of curve names.

Return type:

list

export(folder_path: str = './', sep: str = ',')[source]

Export representative periods (RPs) and their weights to CSV files.

Parameters:
  • folder_path (str, optional) – The path to the folder where the files will be saved. Defaults to ‘./’.

  • sep (str, optional) – The separator used in the CSV files. Defaults to ‘,’.

Raises:

ValueError – If RPs have not been calculated for the TemporalData object.

Returns:

None

plot_DC()[source]

Plot the duration curves (DCs) of the original data and combined RPs.

Returns:

A Plotly figure displaying the DCs.

Return type:

go.Figure

plot_RP()[source]

Plot the representative periods (RPs).

Returns:

A Plotly figure displaying the RPs.

Return type:

go.Figure

plot_curves()[source]

Plot the original curves.

Returns:

A Plotly figure displaying the original curves.

Return type:

go.Figure

property time_horizon: DatetimeIndex

Get the time horizon (index) of the data.

Returns:

The time horizon of the data.

Return type:

pd.DatetimeIndex

reperiods.temporal_data.check_is_RP(temporal_data: TemporalData)[source]

Check if RPs have been calculated for the TemporalData object.

Parameters:

temporal_data (TemporalData) – A TemporalData object.

Raises:

ValueError – If RPs have not been calculated.