mescal.esm_back_to_lca ====================== .. py:module:: mescal.esm_back_to_lca Functions --------- .. autoapisummary:: mescal.esm_back_to_lca._correct_esm_and_lca_capacity_factor_differences mescal.esm_back_to_lca._create_or_modify_activity_from_esm_results mescal.esm_back_to_lca.connect_esm_results_to_database mescal.esm_back_to_lca.create_new_database_with_esm_results Module Contents --------------- .. py:function:: _correct_esm_and_lca_capacity_factor_differences(self, esm_results: pandas.DataFrame, name_capacity_factor_difference_file: str, write_cp_report: bool = True) -> None 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. :param esm_results: results of the ESM in terms of annual production and installed capacity. It should contain the columns 'Name', 'Production', and 'Capacity'. :param name_capacity_factor_difference_file: name of the file to save the capacity factor differences :param write_cp_report: if True, save a csv file reporting capacity factors differences in the results folder :return: None .. py:function:: _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]] Create or modify an activity in the LCI database based on the ESM results :param original_activity_prod: reference product of the original activity :param original_activity_name: name of the original activity :param original_activity_database: database of the original activity :param flows: mapping file between ESM flows and LCI datasets :param esm_results: results of the ESM in terms of annual production and installed capacity. It should contain the columns 'Name', 'Production', and 'Capacity'. :param new_end_use_types: adapt end use types to fit the results LCI datasets mapping :return: list of activities to perform double counting removal .. py:function:: 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 Connect new LCI datasets obtained from the ESM results to the main database :param create_new_db: if True, create a new database connected to the ESM results database. If False, directly modifies the main database. :param new_db_name: name of the new database if create_new_db is True :param specific_db_name: if you want to connect another database than the main database :param locations: 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. :param update_exchanges_based_on_activity_name: if True, update similar flows based on the activity and product names, if False, update similar flows based on the product name only. :return: None (copies and/or modifies the main database) .. py:function:: 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 Create a new database with the ESM results :param esm_results: results of the ESM in terms of annual production and installed capacity. It should contain the columns 'Name', 'Production', and 'Capacity'. :param tech_to_remove_layers: technologies to remove from the result LCI datasets :param new_end_use_types: adapt end use types to fit the results LCI datasets mapping :param return_database: if True, return the new database :param write_database: if True, write the new database in the Brightway project :param remove_background_construction_flows: 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. :param harmonize_efficiency_with_esm: if True, apply the efficiency correction to harmonize the LCI datasets with the ESM assumptions :param harmonize_capacity_factor_with_esm: 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. :param esm_results_db_name: name of the new database with the ESM results :param name_capacity_factor_difference_file: name of the file to save the capacity factor differences :param write_cp_report: if True, save a csv file reporting capacity factors differences in the results folder :return: database of the ESM results if return_database is True, else None .. py:method:: _replace_mobility_end_use_type(row: pandas.Series, new_end_use_types: pandas.DataFrame) -> str :staticmethod: Reformat the end use type of the mobility technologies :param row: row of the model dataframe :param new_end_use_types: adapt end use types to fit the results LCI datasets mapping :return: updated end use type