updating
Module, whose only objective is to update and copy the data necessary for the software to work correctly. The source can be anywhere and is defaulted to the support_files (assuming the file is used from within the repository and not after an install. If installed, the files must be specified each time). Updating the information from SwissGrid uses source codes from https://swissgrid.ch. It is much more intensive and requires a specific parametrization of the updater function.
- ecodynelec.updating.extract_entsoe_daily_generation_for_residuals(config, path_dir=None, n_hours=2, days_around=7, limit=0.4, save=True, is_verbose=False)[source]
Extracts the daily entsoe generation data that will be used for the residual share estimation. The extracted data corresponds to the days in the ‘Redisual_model.xlsx’ file. The data is saved in a file named ‘daily_entsoe_data_for_residual.csv’ in path_dir.
Note that the required entsoe data isn’t downloaded automatically. See downloading.py for more information.
- Parameters:
config (ecodynelec.Parameter or str) – a set of configuration parameters to govern the computation, either as Parameter object or str pointing at an xlsx file.
Only the ‘target’, ‘start’, ‘end’, ‘path.generation’ and ‘path.exchanges’ parameters are used.
path_dir (str, optional) – path to the directory containing updated files. Typically, this is the support_files/ directory of the cloned git repository of EcoDynElec. The directory must contain ALL the files of interest, otherwise the execution is aborted. If None, an attempt to use a default path is made, with no promises.
n_hours (int, default to 2) – max number of successive missing hours to be considered as occasional event
days_around (int, default to 7) – number of days after and before a gap to consider to create a ‘typical mean day’
limit (float, default to 0.4) – max relative length of a gap to fill the data. Longer gaps are filled with zeros.
save (bool, optional) – to decide whether to overwrite the software files with the new extracted data default is True.
is_verbose (bool, optional) – to display information. Default to False.
- Return type:
A pandas.DataFrame containing the daily entsoe data that will be used for the residual share estimation.
- ecodynelec.updating.extract_ofen_typical_days_for_residual(year, post_process_fun, path_dir=None, save=True)[source]
Extracts the typical days from the OFEN data that will be used for the residual share estimation. The extracted data corresponds to the days in the ‘Redisual_model.xlsx’ file. The data is saved in a file named ‘ofen_data/daily_ofen_data_for_residual_year.csv’ in path_dir.
The input data is the annual report of the OFEN, in a pdf that should be named ‘year.pdf’ and in the directory path_dir’/ofen_data’.
- Parameters:
year (str) – the year of the OFEN report to use
post_process_fun (function) – A function to post-process the pdf table data. It takes a list of columns and should return the modified list of columns. Refer to auxiliary.read_ofen_pdf_file for details.
path_dir (str, optional) – path to the directory containing input and output files (that should be in a ‘ofen_data’ sub directory). Typically, this is the support_files/ directory of the cloned git repository of EcoDynElec. If None, an attempt to use a default path is made, with no promises.
save (bool, optional) – to decide whether to overwrite the software files with the new extracted data default is True.
- Return type:
A dict containing the ofen data of the typical days that will be used for the residual share estimation.
- ecodynelec.updating.extract_uvek_impact(ctry, vector_path, is_verbose=False) DataFrame[source]
Extracts the impact data from the provided file and processes the data to filter and rename specified impact categories.
The function reads the input file, identifies and processes specific categories of impact-related data, performs renaming, and adjusts the resultant dataset accordingly. It returns a cleaned matrix containing the processed data.
- Parameters:
ctry (list, tuple, or str) – The country or list of countries for which the data extraction is performed.
vector_path (str) – Path to the input CSV file containing the impact data.
is_verbose (bool, optional) – If True, the function prints progress or debug messages. Default is False.
- Returns:
The cleaned matrix containing filtered and renamed impact categories and their corresponding data.
- Return type:
pandas.DataFrame
- Raises:
TypeError – If ctry is not of type list, tuple, or str.
ValueError – If the header “Catégorie d’impact” is not found in the input file.
- ecodynelec.updating.impact_mapping_matching(uvek_path, ui_vector_path, mapping_path, is_verbose=False)[source]
Matches technologies with their environmental impact values by mapping data from various sources (UVEK, UI impact vector, and mapping details). Generates a new dataframe aligning UI technologies to their corresponding impact values.
- Parameters:
uvek_path (str) – File path to the UVEK impact data file.
ui_vector_path (str) – File path to the UI impact vector data file.
mapping_path (str) – File path to the mapping file linking EcoInvent and UVEK.
is_verbose (bool, optional) – Flag to enable verbose output during the process, default is False.
- Returns:
A new impact vector with combined environmental data for technologies from the UI impact vector and the mapping to UVEK impact data.
- Return type:
pandas.DataFrame
- ecodynelec.updating.update_all(path_dir=None, path_swissGrid=None, is_verbose=False)[source]
Updates all possible software files at once.
Parameter
- path_dir: str, optional
path to the directory containing updated files. Typically, this is the support_files/ directory of the cloned git repository of EcoDynElec. The directory must contain ALL the files of interest, otherwise the execution is aboarded. If None, an attempt to use a default path is made, with no promises.
- path_swissGrid: str, optional
path to a directory containting files downloaded from https://swissgrid.ch. If not given, the swiss-grid information is not updated. This will have no impact if no path_dir is given. To solely update the swiss-grid data, please use the update_sg function.
- is_verbose: bool, optional
to display information. Default to False.
- ecodynelec.updating.update_enr_data_from_pronovo(path_dir=None, output_file=None, verbose=False)[source]
- Function to update the renewable electricity data from Pronovo and Energy Charts.This updates the enr_prod_2016-2022_completed.csv file in the support_files directory.The source files should be manually downloaded following the procedure described in the documentation of the ecodynelec.preprocessing.enr_residual_utils module.The source files should be placed in the path_dir directory :
a ‘pronovo_data’ sub-directory should contain the files from Pronovo (‘prod_year’ directories containing the .csv files downloaded on the Pronovo’s website, AND a ‘EC_Solar_year.csv’ EnergyCharts solar production file to scale the hourly Pronovo data to the real daily production given by EnergyCharts (see ecodynelec.preprocessing.enr_residual_utils module documentation)
a ‘energy_charts_data’ sub-directory should contain the files from Energy Charts
a ‘enr_prod_2016-2019.csv’ file should be in the path_dir directory
This file is generated using the Ecd-EnrModel project. It contains predicted solar and wind electricity production from 2016 to 2019.- Parameters:
path_dir (str, optional) – path to the directory containing the source files. Typically, this is the support_files/ directory of the cloned git repository of EcoDynElec. The directory must contain ALL the files of interest, otherwise the execution is aborted. If None, an attempt to use a default path is made, with no promises.
output_file (str, optional) – path to the file to save the updated data. If None, the file is saved in a ‘enr_prod_2016-2022_completed.csv’ file in the path_dir directory.
verbose (bool, optional) – to display information. Default to False.
- Return type:
None
Extracts the data relative to residual share estimate and save it in software files
- ecodynelec.updating.update_sg(path_dir=None, path_files=None, save=True, is_verbose=False)[source]
Function to update the SwissGrid values from source files. It requires the source files from swissgrid.ch to be downloaded manually. The files are downloaded in parallel to save time, as .xlsx are particularly long to load.
The data is returned and automatically overwrites previous version in the software files if save=True.
- Parameters:
path_dir (str, optional) – path do directory containing EXCLUSIVELY the files from swissgrid.ch Either path_dir or path_files must be specified.
path_files (list-like, optional) – list of paths to the files downloaded from swissgrid.ch on local computer Either path_dir or path_files must be specified.
save (bool, optional) – to decide whether to overwrite the software files with the new extracted data default is True.
is_verbose (to display information)
- Return type:
pandas.DataFrame