mescal.normalization

Functions

from_str_to_tuple(→ pandas.DataFrame)

Convert a column of strings to tuples

normalize_lca_metrics(→ None | pandas.DataFrame)

Create a .dat file containing the normalized LCA metrics for AMPL and a csv file containing the normalization

restrict_lcia_metrics(→ pandas.DataFrame)

Restrict the dataframe to the LCIA method specified

Module Contents

mescal.normalization.from_str_to_tuple(df: pandas.DataFrame, col: str) pandas.DataFrame[source]

Convert a column of strings to tuples

Parameters:
  • df (pandas.DataFrame) – dataframe containing the column to be converted

  • col (str) – column to be converted

Returns:

dataframe with the column converted to tuples

Return type:

pandas.DataFrame

mescal.normalization.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[source]

Create a .dat file containing the normalized LCA metrics for AMPL and a csv file containing the normalization factors

Parameters:
  • R (pandas.DataFrame) – dataframe containing the LCA indicators results

  • mip_gap (float) – normalized values that are lower than the MIP gap are set to 0 (to improve numerical stability)

  • impact_abbrev (pandas.DataFrame) – dataframe containing the impact categories abbreviations

  • lcia_methods (list[str]) – list of LCIA methods to be used

  • R_direct (pandas.DataFrame) – dataframe containing the direct emissions indicators results. This dataframe must only be provided if assessment_type is ‘direct emissions’.

  • contrib_processes (pandas.DataFrame) – 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.

  • specific_lcia_categories (list[str]) – specific LCIA categories to be used

  • specific_lcia_abbrev (list[str]) – specific LCIA abbreviations to be used

  • assessment_type (str) – 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.

  • path (str) – path to results folder. Default is the results_path_file from the ESM class.

  • file_name (str) – 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’.

  • metadata (dict) – dictionary containing the metadata. Can contain keys ‘ecoinvent_version, ‘year’, ‘spatialized’, ‘regionalized’, ‘iam’, ‘ssp_rcp’, ‘lcia_method’.

  • output (str) – if ‘write’, writes the .dat file in ‘path’, if ‘return’, normalizes pandas dataframe, if ‘both’ does both operations.

  • skip_normalization (bool) – if True, skips the normalization step and only writes the .dat file with the original values.

Returns:

None or the normalized pandas dataframe (depending on the value of ‘output’)

Return type:

None | pandas.DataFrame

mescal.normalization.restrict_lcia_metrics(df: pandas.DataFrame, lcia_methods: list[str], specific_lcia_categories: list[str] = None, specific_lcia_abbrev: list[str] = None) pandas.DataFrame[source]

Restrict the dataframe to the LCIA method specified

Parameters:
  • df (pandas.DataFrame) – dataframe containing the LCA metrics

  • lcia_methods (list[str]) – general LCIA method to be used

  • specific_lcia_categories (list[str]) – specific LCIA categories to be used

  • specific_lcia_abbrev (list[str]) – specific LCIA abbreviations to be used

Returns:

dataframe containing the LCA metrics for the specified LCIA method

Return type:

pandas.DataFrame