mescal.esm_back_to_lca

Functions

_correct_esm_and_lca_capacity_factor_differences(→ None)

Correct the differences of capacity factors between ESM technologies and their operation LCI datasets

_create_or_modify_activity_from_esm_results(...)

Create or modify an activity in the LCI database based on the ESM results

connect_esm_results_to_database(→ None)

Connect new LCI datasets obtained from the ESM results to the main database

create_new_database_with_esm_results(...)

Create a new database with the ESM results

Module Contents

mescal.esm_back_to_lca._correct_esm_and_lca_capacity_factor_differences(self, esm_results: pandas.DataFrame, name_capacity_factor_difference_file: str, write_cp_report: bool = True) None[source]

Correct the differences of capacity factors between ESM technologies and their operation LCI datasets during the creation of the ESM results database. Concretely, it changes the amount of the construction input flow in the operation LCI dataset.

Parameters:
  • esm_results (pandas.DataFrame) – results of the ESM in terms of annual production and installed capacity. It should contain the columns ‘Name’, ‘Production’, and ‘Capacity’.

  • name_capacity_factor_difference_file (str) – name of the file to save the capacity factor differences

  • write_cp_report (bool) – if True, save a csv file reporting capacity factors differences in the results folder

Returns:

None

Return type:

None

mescal.esm_back_to_lca._create_or_modify_activity_from_esm_results(self, original_activity_prod: str, original_activity_name: str, original_activity_database: str, flows: pandas.DataFrame, esm_results: pandas.DataFrame, new_end_use_types: pandas.DataFrame) list[list[str]][source]

Create or modify an activity in the LCI database based on the ESM results

Parameters:
  • original_activity_prod (str) – reference product of the original activity

  • original_activity_name (str) – name of the original activity

  • original_activity_database (str) – database of the original activity

  • flows (pandas.DataFrame) – mapping file between ESM flows and LCI datasets

  • esm_results (pandas.DataFrame) – results of the ESM in terms of annual production and installed capacity. It should contain the columns ‘Name’, ‘Production’, and ‘Capacity’.

  • new_end_use_types (pandas.DataFrame) – adapt end use types to fit the results LCI datasets mapping

Returns:

list of activities to perform double counting removal

Return type:

list[list[str]]

mescal.esm_back_to_lca.connect_esm_results_to_database(self, create_new_db: bool = False, new_db_name: str = None, specific_db_name: str = None, locations: list[str] or str = None, update_exchanges_based_on_activity_name: bool = True) None[source]

Connect new LCI datasets obtained from the ESM results to the main database

Parameters:
  • create_new_db (bool) – if True, create a new database connected to the ESM results database. If False, directly modifies the main database.

  • new_db_name (str) – name of the new database if create_new_db is True

  • specific_db_name (str) – if you want to connect another database than the main database

  • locations (list[str] or str) – list of locations to be considered for connection with the ESM results database. If None, only the ESM location is considered. If ‘all’, all locations are considered.

  • update_exchanges_based_on_activity_name (bool) – if True, update similar flows based on the activity and product names, if False, update similar flows based on the product name only.

Returns:

None (copies and/or modifies the main database)

Return type:

None

mescal.esm_back_to_lca.create_new_database_with_esm_results(self, esm_results: pandas.DataFrame, new_end_use_types: pandas.DataFrame = None, tech_to_remove_layers: pandas.DataFrame = None, return_database: bool = False, write_database: bool = True, remove_background_construction_flows: bool = True, harmonize_efficiency_with_esm: bool = True, harmonize_capacity_factor_with_esm: bool = False, esm_results_db_name: str = None, name_capacity_factor_difference_file: str = 'capacity_factor_differences', write_cp_report: bool = True) mescal.database.Database | None[source]

Create a new database with the ESM results

Parameters:
  • esm_results (pandas.DataFrame) – results of the ESM in terms of annual production and installed capacity. It should contain the columns ‘Name’, ‘Production’, and ‘Capacity’.

  • tech_to_remove_layers (pandas.DataFrame) – technologies to remove from the result LCI datasets

  • new_end_use_types (pandas.DataFrame) – adapt end use types to fit the results LCI datasets mapping

  • return_database (bool) – if True, return the new database

  • write_database (bool) – if True, write the new database in the Brightway project

  • remove_background_construction_flows (bool) – if True, the new LCI datasets undergo the double-counting removal process to remove background construction flows. It should be set to True in the context of a loop between the ESM and LCI database, in order to not count the infrastructure impacts several times over several time-steps. It should be set to False if the new database is meant to be shared or used as a standalone database.

  • harmonize_efficiency_with_esm (bool) – if True, apply the efficiency correction to harmonize the LCI datasets with the ESM assumptions

  • harmonize_capacity_factor_with_esm (bool) – if True, apply the capacity factor correction to harmonize the LCI datasets with the ESM assumptions. It should be set to False if the background construction flows are removed.

  • esm_results_db_name (str) – name of the new database with the ESM results

  • name_capacity_factor_difference_file (str) – name of the file to save the capacity factor differences

  • write_cp_report (bool) – if True, save a csv file reporting capacity factors differences in the results folder

Returns:

database of the ESM results if return_database is True, else None

Return type:

mescal.database.Database | None

static mescal.esm_back_to_lca._replace_mobility_end_use_type(row: pandas.Series, new_end_use_types: pandas.DataFrame) str[source]

Reformat the end use type of the mobility technologies

Parameters:
  • row (pandas.Series) – row of the model dataframe

  • new_end_use_types (pandas.DataFrame) – adapt end use types to fit the results LCI datasets mapping

Returns:

updated end use type

Return type:

str