auxiliary

Module containing a collection of functions to load side-datasets that may be required during the execution of ecodynelec proceses.

ecodynelec.preprocessing.auxiliary.clear_ambiguous_dates(sg)[source]

Function to clear ambiguous dates in SwissGrid raw data

ecodynelec.preprocessing.auxiliary.get_default_file(name, level=0, max_level=3)[source]

Function to return the absolute path of default files. The function uses the location of the current auxiliary.py file but assumes no structure in EcoDynElec. It only searches the structure upward

ecodynelec.preprocessing.auxiliary.load_ch_enr_model(ch_enr_model_path, start, end, freq)[source]

Load the CH energy production data from the given path and returns a dataframe with the same format as the processed ENTSO-E production and exchange data.

Parameters:
  • ch_enr_model_path (str) – Path to the CH energy production data, generated with EcoDynElec-EnrModel

  • start (str) – Start date of the data to load

  • end (str) – End date of the data to load

  • freq (str) – Frequency of the data to return (from H to Y)

Returns:

A dataframe with the same format as the processed ENTSO-E production and exchange data, containing the CH energy production data for the given period

Return type:

pd.DataFrame

ecodynelec.preprocessing.auxiliary.load_gap_content(path_gap, start=None, end=None, freq='H', enr_prod_residual_ch=None)[source]

Function that defines the relative composition of the swiss residual production. The function is very file format specific. If enr_prod_residual_ch is not None, it will be subtracted from the “other” residual production before computing the relative composition of each category.

Parameters:
  • path_gap (str) – Path to the file containing residual content information. The file must contain absolute values for each category, for each time step (if not, use updating.update_residual_share to update the file).

  • start (default to None) – starting date, as datetime or str

  • end (default to None) – ending date, as datetime or str

  • freq (str, default to “H”) – frequency to resample the data to

  • enr_prod_residual_ch (default to None) – Delta between the renewable electricity production of EcoDynElec-EnrModel and the production given by the ENTSO-E data. If not None, the total will be subtracted from the “other” residual category.

Returns:

table with relative residual production composition for each time step.

Return type:

pandas.DataFrame

ecodynelec.preprocessing.auxiliary.load_grid_losses(network_loss_path, start=None, end=None)[source]

Function that loads network grid losses and returns a pandas DataFrame with the fraction of network loss in the transmitted electricity for each month.

ecodynelec.preprocessing.auxiliary.load_rawEntso(mix_data, freq='H')[source]

Function that can load an existing production and exchange matrix in a CSV file

ecodynelec.preprocessing.auxiliary.load_swissGrid(path_sg, start=None, end=None, freq='H')[source]

Function to load production and cross-border flows information from Swiss Grid. Data used many times along the algorithm.

Parameters:
  • path_sg (str) – path to the file with Swiss Grid information

  • start (str, default None) – starting date, as datetime or str

  • end (str, default None) – ending date, as datetime or str

  • freq (str, default to ‘H’) – frequency to resample the SwissGrid data to

Returns:

table of SwissGrid information in MWh

Return type:

pandas.DataFrame

ecodynelec.preprocessing.auxiliary.load_useful_countries(path_neighbour, ctry)[source]

Function to load a list of countries directly or indirectly involved in the computation. Countries directly involved are passed as arguments. Countries indirectly involved are their neighbours. These indirectly involved countries help building the import from ‘other’ countries.

ecodynelec.preprocessing.auxiliary.post_process_2017(columns)[source]

Helper to fix the 2017 data read from the OFEN pdf file

ecodynelec.preprocessing.auxiliary.post_process_2022(columns)[source]

Helper to fix the 2022 data read from the OFEN pdf file

ecodynelec.preprocessing.auxiliary.post_process_2023(columns)[source]

Helper to fix the 2023 data read from the OFEN pdf file

ecodynelec.preprocessing.auxiliary.post_process_2024(columns)[source]

Helper to fix the 2024 data read from the OFEN pdf file

ecodynelec.preprocessing.auxiliary.read_ofen_pdf_file(file, post_process_fun, page=31)[source]

Reads an ofen pdf file and extracts a dictionary of typical days with their electricity mix. Supports years from 2017 to 2024. Not tested after. A post-processing function should be provided to fix the data read from the pdf file. This function depends on the year of the data because the format of the pdf file changes between years. Four post-processing functions are provided above for 2017, 2022, 2023 and 2024.

Parameters:
  • file (str) – Path to the pdf file to read

  • post_process_fun (function) – Function to apply to the data read from the pdf file Takes a list of columns as input and returns the modified list of columns

  • page (int) – Page of the pdf file to read (default: 31)

ecodynelec.preprocessing.auxiliary.split_cell(cell, index)[source]

Utility function to split a cell of a table read from tabula