mescal.normalization ==================== .. py:module:: mescal.normalization Functions --------- .. autoapisummary:: mescal.normalization.from_str_to_tuple mescal.normalization.normalize_lca_metrics mescal.normalization.restrict_lcia_metrics Module Contents --------------- .. py:function:: from_str_to_tuple(df: pandas.DataFrame, col: str) -> pandas.DataFrame Convert a column of strings to tuples :param df: dataframe containing the column to be converted :param col: column to be converted :return: dataframe with the column converted to tuples .. py:function:: normalize_lca_metrics(self, R: pandas.DataFrame, mip_gap: float, impact_abbrev: pandas.DataFrame, lcia_methods: list[str], R_direct: pandas.DataFrame = None, contrib_processes: pandas.DataFrame = None, specific_lcia_categories: list[str] = None, specific_lcia_abbrev: list[str] = None, assessment_type: str = 'esm', path: str = None, file_name: str = None, metadata: dict = None, output: str = 'write', skip_normalization: bool = False) -> None | pandas.DataFrame Create a .dat file containing the normalized LCA metrics for AMPL and a csv file containing the normalization factors :param R: dataframe containing the LCA indicators results :param mip_gap: normalized values that are lower than the MIP gap are set to 0 (to improve numerical stability) :param impact_abbrev: dataframe containing the impact categories abbreviations :param lcia_methods: list of LCIA methods to be used :param R_direct: dataframe containing the direct emissions indicators results. This dataframe must only be provided if assessment_type is 'direct emissions'. :param contrib_processes: dataframe containing the contribution of processes for each technology/resource and impact category. This dataframe must only be provided if assessment_type is 'territorial emissions'. It will be used to compute the amount of territorial/abroad impact for each impact category. :param specific_lcia_categories: specific LCIA categories to be used :param specific_lcia_abbrev: specific LCIA abbreviations to be used :param assessment_type: type of assessment, can be 'esm' for the full LCA database, 'direct emissions' for the computation of direct emissions only, or 'territorial emissions' for the computation of territorial and abroad emissions. :param path: path to results folder. Default is the results_path_file from the ESM class. :param file_name: name of the .dat file. Default is 'techs_lcia' if assessment_type is 'esm', 'techs_direct' if assessment_type is 'direct emissions', and 'techs_territorial' if assessment_type is 'territorial emissions'. :param metadata: dictionary containing the metadata. Can contain keys 'ecoinvent_version, 'year', 'spatialized', 'regionalized', 'iam', 'ssp_rcp', 'lcia_method'. :param output: if 'write', writes the .dat file in 'path', if 'return', normalizes pandas dataframe, if 'both' does both operations. :param skip_normalization: if True, skips the normalization step and only writes the .dat file with the original values. :return: None or the normalized pandas dataframe (depending on the value of 'output') .. py:function:: restrict_lcia_metrics(df: pandas.DataFrame, lcia_methods: list[str], specific_lcia_categories: list[str] = None, specific_lcia_abbrev: list[str] = None) -> pandas.DataFrame Restrict the dataframe to the LCIA method specified :param df: dataframe containing the LCA metrics :param lcia_methods: general LCIA method to be used :param specific_lcia_categories: specific LCIA categories to be used :param specific_lcia_abbrev: specific LCIA abbreviations to be used :return: dataframe containing the LCA metrics for the specified LCIA method