zen_garden.preprocess.time_series_aggregation

Functions to apply time series aggregation to time series.

Classes

TimeSeriesAggregation(energy_system)

Class containing methods to apply time series aggregation.

class zen_garden.preprocess.time_series_aggregation.TimeSeriesAggregation(energy_system: EnergySystem)

Class containing methods to apply time series aggregation.

__init__(energy_system: EnergySystem)

Initializes the time series aggregation. The data is aggregated for a single year and then concatenated.

Parameters:

energy_system – The energy system to use

add_year_specific_ts(element, ts, new_ts, header_set_time_steps)

This method adds a year specific time series for an element.

Parameters:
  • element – element of the time series

  • ts – time series to add

  • new_ts – new time series to add year specific values to

  • header_set_time_steps – name of set_time_steps

calculate_time_steps_storage_level()

Calculates the number of time steps on the storage level, and the sequence in which the storage levels are connected.

extract_raw_ts(element, header_set_time_steps)

Extract the time series from an element and concatenates the non-constant time series to a pd.DataFrame.

Parameters:
  • element – element of the optimization

  • header_set_time_steps – name of set_time_steps

Returns:

df_ts_raw: pd.DataFrame with non-constant time series

get_excluded_ts()

Gets the names of all elements and parameter ts that shall be excluded from the time series aggregation.

Calculates the necessary overlapping time steps of the investment and operation of a technology for all years.

It sets the union of the time steps for investment, operation and years.

manually_aggregate_ts(df)

Manually aggregates time series for excluded parameters.

Parameters:

df – dataframe that is manually aggregated

Returns:

agg_df: aggregated dataframe

multiply_yearly_variation(element, ts_name, ts, year_specific=None)

Multiplies time series with the yearly variation of the time series.

The index of the variation is the same as the original time series, just time and year substituted.

Parameters:
  • element – technology of the optimization

  • ts_name – name of time series

  • ts – time series

Returns:

multipliedTimeSeries: ts multiplied with yearly variation

overwrite_ts_with_expanded_timeindex(element, old_sequence_time_steps)

This method expands the aggregated time series to match the extended operational time steps because of matching the investment and operational time sequences.

Parameters:
  • element – element of the optimization

  • old_sequence_time_steps – old order of operational time steps

overwrite_ts_without_expanded_timeindex(element)

Multiply the time series with the yearly variation if the element’s time series are not aggregated.

Parameters:

element – element of the optimization

repeat_sequence_time_steps_for_all_years()

This method repeats the operational time series for all years.

run_tsa(year_specific=None)

This method runs the time series aggregation.

run_tsa_for_year_specific_ts(new_sequence_time_steps)

This method runs the time series aggregation for year-specific time series.

Parameters:
  • new_sequence_time_steps – old sequence of time steps that is now overwritten with new sequence of year specific TSA for respective year

  • new_sequence_time_steps – new sequence of time steps updated with year specific TSA sequence

select_ts_of_all_elements()

This method retrieves the raw time series for the aggregation of all input data sets.

set_aggregated_ts_all_elements()

This method sets the aggregated time series and sets the necessary attributes after the aggregation.

set_time_attributes(set_time_steps, time_steps_duration, sequence_time_steps)

This method sets the operational time attributes of an element.

Parameters:
  • set_time_steps – set_time_steps of operation

  • time_steps_duration – time_steps_duration of operation

  • sequence_time_steps – sequence of operation

single_ts_tsa()

Manually aggregates the constant time series to single ts.

substitute_column_names(direction='flatten', year_specific=False)

This method substitutes the column names to have flat columns names (otherwise sklearn warning).

Parameters:

direction – flatten or raise

unique_time_steps_multiple_indices(list_sequence_time_steps)

Returns the unique time steps of multiple time grids.

Parameters:

list_sequence_time_steps – list of operational and investment time steps

Returns:

(set_time_steps, time_steps_duration, sequence_time_steps)

time steps, duration and sequence

Return type:

tuple