tracking

The tracking module handles the tracking of electricity to determine the decomposition of the electric mix.

ecodynelec.tracking.build_technology_matrix(data, ctry, ctry_mix, prod_means)[source]

Function building the technology matrix based on the production and exchange data.

Parameters:
  • data (pandas.DataFrame) – Table with the production and exchange mix (production of each source / total production (for each country) (considering imports as sources)) at a given time

  • ctry (array-like) – sorted list of involved countries

  • ctry_mix (array-like) – list of countries where eletricity can come from, including ‘Other’

  • prod_means (array-like) – list of production means, without mixes

Returns:

technology matrix A

Return type:

numpy.ndarray

ecodynelec.tracking.clean_technology_matrix(A)[source]

Reduce the size of the technology matrix. As the matrix A is a square matrix, for all indexes i where the i-th row AND the i-th column are both full of zeros, both row and column i are dropped. All other indexes j are written in the list ‘presence’, and the row and column j is kept in A.

ecodynelec.tracking.compute_producing_mix(df, ctry, prod_means)[source]

Computes the production mix for each country, considering imports as sources (Mix_CNTRY sources). The production mix is the production of each source divided by the total production of the corresponding country.

Parameters:
  • df (pandas.DataFrame) – production and exchange data from ENTSO-E.

  • ctry (list of str) – the list of countries to consider.

  • prod_means (list of str) – the list of production means to consider.

Returns:

table with the production mix in the studied countries (parameter.ctry + ‘Other’), containing each production mean of each country at each time step.

Return type:

pandas.DataFrame

ecodynelec.tracking.compute_tracking(data, all_sources, uP, ctry, ctry_mix, prod_means, residual=False, freq='H', is_verbose=False, progress_bar=None)[source]

Function leading the electricity tracking: by building the technology matrix and computing the inversion at each time step.

Parameters:
  • data (pandas.DataFrame) – Table with the production and exchange mix (production of each source / total production (for each country) (considering imports as sources))

  • all_sources (array-like) – an ordered list with the mix names and production mean names, without origin

  • uP (array-like) – vector that indicates the amount of energy before losses to obtain 1kWh of consumable elec

  • ctry (array-like) – sorted list of involved countries

  • ctry_mix (array-like) – list of countries where electricity can come from, including ‘Other’

  • prod_means (array-like) – list of production means, without mixes

  • residual (bool, default to False) – if residual are considered

  • freq (str, default to ‘H’) – frequency of a time step

  • is_verbose (bool, default to False) – show text during computation.

  • progress_bar (ProgressInfo, default to None) – if not None, a new progress bar is displayed to show the progress of the computation.

Returns:

table with the electricity mix in the studied countries (parameter.ctry + ‘Other’), containing each production mean of each country at each time step.

Return type:

pandas.DataFrame

ecodynelec.tracking.get_grid_losses(data, losses=None)[source]

Gives for each time step the amount of electricity to produce in order to consume 1 kWh.

ecodynelec.tracking.invert_technology_matrix(A, presence, L)[source]

Track the electric mix: it consists in computing (Id - A)⁻¹

Parameters:
  • A (numpy.array) – technology matrix at one time step

  • presence (list-like) – list of indexes to replace the computation results in their context

  • L (int) – the size of the results (and original A, before it was cleaned)

Returns:

matrix (Id - A)⁻¹ of shape (L, L)

Return type:

numpy.array

ecodynelec.tracking.reorder_info(data)[source]

Function to rename and reorder the columns in the production and exchanges table. It returns 4 useful lists for the electricity tracking.

Parameters:

data (pandas.DataFrame) – the production and exchange table

Returns:

  • list – ctry: sorted list of involved countries

  • list – ctry_mix: list of countries where electricity can come from, including ‘Other’ (list)

  • list – prod_means: list of production means, without mixes (list)

  • list – all_sources: list of production means and mixes, with precision of the country of origin (list)

ecodynelec.tracking.set_FU_vector(all_sources, target='CH')[source]

Defines the Functional Unit vector: full of zeros, except at the indexes corresponding to the target country, where a 1 is written.

This function isn’t used in the main pipeline.

Parameters:
  • all_sources (list) – All sources, as returned by reorder_info

  • target (str, default to ‘CH’) – target country

ecodynelec.tracking.track_mix(raw_data, freq='H', network_losses=None, residual_global=False, return_prod_mix=False, is_verbose=False, progress_bar=None)[source]

Performs the electricity tracking. Master function for the electricity mix computation.

Parameters:
  • raw_data – path to ENTSO-E data (str), or pandas.DataFrame with production and exchange data.

  • freq (str, default to “H”) – frequency of time steps

  • network_losses (pandas.Series, default to None) – vector of estimate for grid losses at every time step.

  • residual_global (bool, default to False) – whether to include a local production residual as production unit during the electricity tracking computation.

  • return_prod_mix (bool, default to False) – whether to return the production mix in addition to the electricity mix.

  • is_verbose (bool, default to False) – show text during computation.

  • progress_bar (ProgressInfo, default to None) – progress bar object to show progress during computation.

Returns:

First element: table with the electricity mix in the studied countries (parameter.ctry + ‘Other’), containing each production mean of each country at each time step. Second element: table with the production mix in the studied countries (parameter.ctry + ‘Other’), containing each production mean of each country at each time step.

Return type:

pandas.DataFrame if return_prod_mix is False, or tuple of pandas.DataFrame if return_prod_mix is True