EcoDynElec: Open Python package to create historical profiles of environmental impacts from regional electricity mixes

This article presents the EcoDynElec python package that creates temporal historical profiles of various potential environmental impacts for electricity mixes in different regions. The profiles are evaluated with the same electricity modeling structure that is used in life cycle assessment databases, simplifying their consistent combination in studies. The open access information from the ENTSO-E platform is used as an input that enables the creation of profiles that can reach temporal precision of 15 min for the last five years. EcoDynElec is shared to open its use in environmental studies that can be substantially affected by the temporal variability of electricity uses.


Motivation and significance
Electricity use is often a substantial source of environmental impacts in supply chains that are analyzed with the life cycle assessment (LCA) framework [1]. It is therefore important to use models of electricity that are as representative as possible to increase the confidence in the conclusions of LCA studies. Considering the temporal variations of the electricity production is one aspect that leads to more representative models that take into account the moment when electricity is used. Strategies to create such models and their relevance have been shown in many ''long-term'' prospective LCA studies where the yearly evolutions * Corresponding author.
E-mail address: dib@empa.ch (Didier Beloin-Saint-Pierre). of electricity mixes have been considered in their relation with systems that have long lifetime (e.g. buildings) [2].
The consideration of ''short-term'' variations in electricity models is another important aspect to take into account. For instance, they can describe changes at different hours of the day, between the days of the week and in different seasons. Wellknown LCA databases, such as ecoinvent [3], do not provide this level of temporal detail since they typically offer average yearly representation of electricity mixes for different countries. Nevertheless, recent LCA studies have explored the ''short-term'' dynamics of electricity systems for their use in the building sector [4][5][6][7] and for cloud computing [8]. The developed models in these studies have limited details on the variations of exchanged electricity between neighboring countries. This limitation raises https questions about the accuracy of the evaluated environmental impacts for electricity uses that change throughout the days in many sectors. It is thus important to provide a tool to consider detailed temporal resolution for LCA studies where such variations are expected to bring substantial effects on the results.
The people behind the Electricity Maps web service [9] have explored this topic by using data provided by the ENTSO-E transparency platform [10] and the carbon footprint values of energy sources from different organizations like the IPCC [11]. Their efforts have created an access to visual representations and quantitative descriptions of the hourly average carbon-footprint values for the electricity mixes in different countries around the world. Since July 2022, their services also provide the historical average hourly values for up to five years in the past. Furthermore, they provide, free-of-charge, one year of hourly carbon footprint values for one country to academic researchers and some algorithms of their services are provided in an open source format in a GitHub repository to simplify collaboration with interested stakeholders. The Electricity Maps organization therefore offers a way to consider hourly variations of carbon footprint from electricity mixes in LCA studies, but this service presents some limitations.
First, the provided values do not inform on other impact categories (e.g. human toxicity & land use) that are required for an ISO 14040-44 compliant LCA study [12,13]. Second, the access to a detailed hourly carbon footprint description of the complete last five years requires payments. With that being said, the access to the data of 2021 and 2022 has been recently provided for free, upon request. Third, the regional representativeness of the carbon footprint values that they use (i.e. mainly IPCC report [11]) and the level of detail for energy sources are not consistent with some LCA databases (i.e. only one value per energy source not accounting for various technologies). Fourth, the modeling choices and algorithms of the Electricity Map Service are not consistent with current models of electricity mixes in LCA databases. Indeed, LCA databases typically model the electricity mix with the sum of national production options and importation from neighboring countries based on total energy production. The Electricity Map service, on the other hand, uses the flow tracing methodology [14] that account for power to evaluate the ''carbon intensity'' profile. Fifth, the hourly average values seem to be the highest level of provided description even if some countries offer a 15-min description of their production mixes in the ENTSO-E platform.
It is therefore relevant to provide a new digital tool that deals with these limitations and open possibilities for future scientific studies in environmental assessment. This article presents the EcoDynElec package that tackles the previously highlighted limitations. Its development has been carried out in a 5-year research work that started in 2018 at HEIG-VD and EMPA, in Switzerland. This open-source tool offers a way to calculate various potential life cycle environmental impacts for different time steps with all the historical data from ENTSO-E.

Software architecture:
EcoDynElec is a package implemented in Python. It is structured by three interconnected sections of modules shown in Fig. 1.

Data preprocessing
EcoDynElec relies on various data sources. The core data to compute the electricity mixes for most European countries are found on the ENTSO-E repository [10] and can be retrieved with the Downloading module. These files describe the flows of electricity by sources and regions since 2016. Strictly necessary data are Extracted from these files by considering user-defined countries (from the Parameter module) in the electricity cross-border exchanges. The created reduced dataset can be saved locally.
Missing information at the sources can happen [15] and can be Autocompleted via methods described in the EcoDynElec documentation 1 . For Switzerland specifically, low-voltage generation values, which are not described by ENTSO-E statistics, are gathered from additional governmental statistics, loaded by the Auxiliary module and used by the Residual module. These statistics are stored in the support_files directory.
The obtained electricity generation and exchange time series are finally resampled to an appropriate time step (user defined) and returned by the Loading module.

Electricity tracking
The Tracking module uses the electricity generation and exchange values of all involved countries that are defined by the data pre-processing modules. The module normalizes the data, so that each production from electricity sources of the selected countries becomes a percentage and not a quantity of energy. The data is then reorganized into one so-called technology matrix per time step. The Tracking module inverts these technology matrixes. For each resulting matrix, the column containing the electricity mix of the evaluated country is extracted. The mix describes the percentage of contribution of all generation sources from all involved countries. The module output is a new matrix built from these selected columns. Implementation details to limit the computation time are given in EcoDynElec documentation.

Computation of environmental impacts
The data of the electricity mix for 1 kWh of delivered electricity from the Tracking module are coupled with the impacts of each generation source (e.g. solar, wind, coal) by the Impacts module. The Impacts module computes the impacts of the electricity mix at each time step by considering the products of all shares of electricity sources (national productions and imports) with their respective environmental impacts and then summing these values. All results are returned for in-script use and can be saved as .csv files by the Saving module.

User interface
The Pipelines module wraps up all three components into a smooth workflow. Parametrization of the computation is done via the side module Parameter, further described in the next section.

Software functionalities:
When combined, the three components offer a signal that describes the temporal variability of environmental impacts for the electricity mix of a chosen country. EcoDynElec can be used by interested stakeholders if they have access to values of environmental impacts for different energy sources and to the ENTSO-E repository (which requires a free registration).

High-level parametrization
A high-level customization of the execution parameters is enabled via the side module Parameter. The module may be used to set the configuration directly in Python or to load parameters from an excel spreadsheet. A template spreadsheet is provided for download on the GitHub repository 2 . The main parameters define the experiment date, the countries involved, the target country and the resolution of time step (frequency of evaluation).
The autocompleting of ENTSO-E data can be turned on (default) or off via another high-level parameter. Similarly, the crossborder flows may be equalized after adjusting the frequency to be a net total during each time step (default is not equalized). This means that electricity exports are subtracted from imports to find 1 exchange value per time step between two countries.
Additional customization for the specific case of Switzerland is enabled (default is not enabled). Via parameters, EcoDynElec allows to (1) replace all exchanges with all the Swiss neighbors with data from the national electricity provider SwissGrid; (2) estimate a local production mix (called ''residual'' in EcoDynElec); and to include this residual as an additional electricity source (3) that can be shared or not with neighbor countries.
This specific case is justified, since the ENTSO-E data does not inform on 100% of the production means and exchange flows at the Swiss borders (i.e. less tracking of medium-or low-voltage production such as run-off river hydropower). Its central location in Europe results in additional transits of electricity throughout the country [16], and to the best of our knowledge, Switzerland is a special case in Western Europe where limited coverage from ENTSO-E substantially affect the temporal impact profiles.
Various examples of the utilization of parameters are available in the online documentation.

Mapping of impacts from electricity sources
The discrepancies in the list of electricity sources in the ENTSO-E platform and environmental databases like ecoinvent require the definition of a mapping file to describe how these two data sources can be connected. A Mapping template, EcoDynElec is available for download, 3 explains how weighted averages of electricity technologies from environmental databases can be combined to offer environmental impact factors for the energy sources of ENTSO-E. This file can be modified by the user to use a different database or update the information in the future.

Modularity of EcoDynElec
The package is built as an ensemble of modules. This feature allows for usages of specific sections of the package. It can be used to simply download or autocomplete data from the ENTSO-E servers, or solely for its electricity-tracking module.
The modularity is also an advantage for further refinements of modeling hypotheses. An example is the auto-completing functionalities, whose default behavior is as follows: a data gap is completed (1) with linear interpolation if is less than 2 h long; (2) with zeros if the gap represents more than 40% of the total duration of the experiment; and (3) with an average day of the 7 days before and after the gap in other cases. These numbers can be customized by taking advantage of the software modularity but they were excluded from high-level parametrization for the sake of simplicity.

Illustrative examples
The main uses of EcoDynElec are shown with the example of Swiss electricity profiles of four impact categories that are based on the ReCiPe 2016 Midpoint (H) method [17]. Output results are presented in Fig. 2 for 2020 to show the type of information that can be retrieved. The impact profiles could be provided for the period between 2017 until today, but other years are left out to present readable figures. Similar profiles could be created for other countries or other impact categories, provided that the user has access to the necessary LCIA indicators (to be included in the Mapping file).
First, all the modules of the preprocessing section are used to extract the necessary data to model the temporal variations of the Swiss electricity mix and its related impacts. A template spreadsheet is filled with information to ensure that data from ENTSO-E are retrieved for the electricity production and exchanges between Switzerland and selected countries. The list of selected countries (mostly neighboring countries) is set by the users after a hotspot analysis of the key sources of impacts in the annual average results of the Swiss electricity mix. Gaps in data are automatically filled following rules that are defined in the Autocomplete module.
A file with the values for 2020 is available in the EcoDynElec package (see Table 1) to serve as an example. The missing domestic production is added using information from the Swiss Federal Office of Energy on 36 typical days over a year. EcoDynElec In a third step, the environmental impacts of the sources of electricity in the selected countries are retrieved from the Unit_Impact_Vector file, which has been created with the information from version 3.8 of the ecoinvent database (cut-off) by aggregating the impacts of technologies into electricity sources that are used by ENTSO-E (see Mapping). Once all the necessary data are retrieved and adapted, the different results can be obtained by running the Tracking and Impacts modules.
As mentioned before, Fig. 2 presents the different types of results that can be computed by EcoDynElec to describe the variation of environmental impacts from the Swiss electricity mix over the year 2020. These results show that the information can be provided with different levels of temporal precision for various impact categories (e.g. climate change) and with the corresponding yearly distribution of probability, which describes the range of impact variability. The information provided by EcoDynElec thus inform on the different trends and variation scales that can be observed for different impact categories. When taken separately, the profiles show when the electricity mix is presenting lower impacts if compared with the average value at a higher temporal scale. For example, on the 21st of June, the climate change impact of the electricity mix between 17:00 and 23:00 is lower than the daily average value. This type of information can be used to select moments in the day where it is preferable to use electricity in houses or to charge electrical cars to reduce the environmental footprint of their use phase. From a researchers' perspective, the width of the probability distribution (right side) gives insights on the uncertainty of environmental assessments if we do not know when electricity is used by different supply chains. The existence of more than one peak in the probability distributions also suggests that there are different average states at different periods of the year. When compared, the four profiles show that the trends of different impacts are not always synchronized and that electricity uses at some period might be optimal for one impact category but not for the others. This combined information thus reduces the risks of making choices that would optimize the reduction of GHG emissions, but increase the human toxicity of electricity uses.

Impact
EcoDynElec can provide up to 5 years of historical profile data that can be used to train machine-learning algorithms in forecasting environmental impacts of ''short-term'' future electricity mixes (e.g. for 48 h in the future). This research topic is part of the ongoing S-DSM project, which is funded by the Swiss Federal Office of Energy. The output of this work will be used to find how the carbon footprint of the buildings' use-phase can be reduced by enabling ''smart'' demand-side management of electricity. It is expected that the same results could be used in other sectors like the charging of electric cars with electricity that has a low carbon content.
EcoDynElec also offers the possibility to conduct new LCA studies where the ''short-term'' temporal variability of regional electricity mixes can be considered while using a consistent modeling approach that fits with background LCA databases. This reduces the complexity, for any LCA practitioner, to evaluate the uncertainty of results if we do not know when the products are created or the services are offered and could thus improve our capacity to properly differentiate the environmental impacts of systems with equivalent functions.
The current implementation of EcoDynElec makes the implicit assumption that the environmental burden of electricity mixes is homogeneous in a country, but it could be further developed to smaller geographical granularity if more specific temporal data are made available for electricity production options and flows. The time resolution is also mostly limited by the data availability. Bringing the package to the open-source space might thus help researchers and developers to adapt the tool to any derived uses or to use a market dataset that is more consistent with the scope of other LCA studies.
EcoDynElec could be beneficial to a large community of researchers and practitioners that want to consider a high level of temporal details when calculating the environmental impacts of the electricity uses in different systems.
EcoDynElec is being released to the public at the same time as this publication. The current number of users is therefore limited to the researchers of the Swiss organizations that participated to the EcoDynBat [18] and S-DSM projects. Nevertheless, it could be used by environmental assessment practitioners that are eager to learn more about the environmental impacts of electric consumption at different periods of a day, week and month.
EcoDynElec is not currently used in commercial settings but might enable the creation of a spin-off company after further developments.

Conclusions
The EcoDynElec package provides a powerful yet simple methodology that is consistent with the models of current LCA databases. It allows a deeper understanding of the interactions between electricity producers and their effects on the environmental impacts that we consume at different moments of the day.

Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Data availability
All data provided along with the software is openly accessible and free to use. See the documentation for further details.