mescal.impact_assessment
Attributes
Classes
Adaptation of the MultiLCA class from the bw2calc package in order to perform contribution analysis. |
Functions
|
Add a technosphere exchange to an activity |
Aggregate the activities subject to double counting for the same ESM technology |
|
|
Fill empty cells with the ESM value if the technology is not in the technology compositions file |
|
Compute the impact scores of the technologies and resources |
|
Compute the territorial and abroad impact scores from the contribution analysis of processes. |
Returns a dataframe comparing the direct carbon emissions obtained from the LCIA phase (direct emissions module) |
Module Contents
- class mescal.impact_assessment.MultiLCA(cs_name: str, contribution_analysis: str, limit: int or float, limit_type: str, req_technosphere: bool, log_config=None)[source]
Bases:
objectAdaptation of the MultiLCA class from the bw2calc package in order to perform contribution analysis.
Wrapper class for performing LCA calculations with many functional units and LCIA methods. Needs to be passed a
calculation_setupname. This class does not subclass the LCA class, and performs all calculations upon instantiation. Initialization creates self.results, which is a NumPy array of LCA scores, with rows of functional units and columns of LCIA methods. Ordering is the same as in the calculation_setup.Initialize the MultiLCA_with_contribution_analysis class.
- Parameters:
cs_name (str) – name of the calculation setup to use
contribution_analysis (str) – if ‘emissions’, the function will return the contribution analysis of top elementary flows. If ‘processes’, the function will return the contribution analysis of top processes. If ‘both’, it will return both.
limit (int or float) – number of values to return (if limit_type is ‘number’), or percentage cutoff (if limit_type is ‘percent’)
limit_type (str) – contribution analysis limit type, can be ‘percent’ or ‘number’
req_technosphere (bool) – if True, the function will compute the requirements for technosphere flows
log_config – log configuration for the LCA calculation
- mescal.impact_assessment._add_virtual_technosphere_flow(act: dict, exc_act: dict, amount: float) dict[source]
Add a technosphere exchange to an activity
- Parameters:
act (dict) – activity to which the exchange is added
exc_act (dict) – activity of the exchange
amount (float) – amount of the exchange
- Returns:
the activity with the new exchange
- Return type:
dict
- mescal.impact_assessment._aggregate_direct_emissions_activities(self, esm_db: mescal.database.Database, direct_emissions_db: list[dict], activities_subject_to_double_counting: pandas.DataFrame) mescal.database.Database[source]
Aggregate the activities subject to double counting for the same ESM technology
- Parameters:
esm_db (mescal.database.Database) – ESM database
direct_emissions_db (list[dict]) – direct emissions ESM database before aggregation
activities_subject_to_double_counting (pandas.DataFrame) – dataframe of activities subject to double counting
- Returns:
aggregated direct emissions ESM database
- Return type:
- mescal.impact_assessment._is_empty(self, row: pandas.Series) float[source]
Fill empty cells with the ESM value if the technology is not in the technology compositions file
- Parameters:
row (pandas.Series) – row of the lifetime dataframe
- Returns:
lifetime value
- Return type:
float
- mescal.impact_assessment.compute_impact_scores(self, methods: list[str], specific_lcia_categories: list[str] = None, specific_lcia_abbrev: list[str] = None, impact_abbrev: pandas.DataFrame = None, assessment_type: str = 'esm', overwrite: bool = True, contribution_analysis: str = None, contribution_analysis_limit_type: str = 'number', contribution_analysis_limit: float or int = 5, req_technosphere: bool = False) tuple[pandas.DataFrame, pandas.DataFrame | None, pandas.DataFrame | None][source]
Compute the impact scores of the technologies and resources
- Parameters:
methods (list[str]) – list of life-cycle impact assessment methods for which LCA scores are computed
specific_lcia_categories (list[str]) – restrict the impact assessment to specific LCIA categories
specific_lcia_abbrev (list[str]) – restrict the impact assessment to specific LCIA categories identified by their abbreviation in the impact_abbrev file
impact_abbrev (pandas.DataFrame) – dataframe containing the impact categories abbreviations
assessment_type (str) – type of assessment, can be ‘esm’ for the computation of the energy system life-cycle impacts, or ‘direct emissions’ for the computation of direct emissions only
overwrite (bool) – only relevant if assessment_type is ‘direct emissions’, if True, the direct emissions database will be overwritten if it exists
contribution_analysis (str) – if ‘emissions’, the function will return the contribution analysis of top elementary flows. If ‘processes’, the function will return the contribution analysis of top processes. If ‘both’, it will return both.
contribution_analysis_limit_type (str) – contribution analysis limit type, can be ‘percent’ or ‘number’. Default is ‘percent’.
contribution_analysis_limit (float or int) – number of values to return (if limit_type is ‘number’), or percentage cutoff (if limit_type is ‘percent’). Default is 0.01.
req_technosphere (bool) – if True, the function will compute the requirements for technosphere flows.
- Returns:
impact scores dataframe of the technologies and resources for all selected impact categories, contribution analysis dataframe (None if contribution_analysis is None), and technosphere flows requirements dataframe (None if req_technosphere is False).
- Return type:
tuple[pandas.DataFrame, pandas.DataFrame | None, pandas.DataFrame | None]
- mescal.impact_assessment.compute_territorial_impact_scores(self, df_contrib_processes: pandas.DataFrame) pandas.DataFrame[source]
Compute the territorial and abroad impact scores from the contribution analysis of processes.
- Parameters:
df_contrib_processes (pandas.DataFrame) – dataframe of the contribution analysis of processes
- Returns:
territorial and abroad impact scores dataframe
- Return type:
pandas.DataFrame
- mescal.impact_assessment.validation_direct_carbon_emissions(self, R_direct: pandas.DataFrame, lcia_method_carbon_emissions: str, carbon_flow_in_esm: str or list[str], esm_results: pandas.DataFrame = None, return_df: bool = False, save_df: bool = True) tuple[pd.DataFrame, pd.DataFrame | None] or None[source]
Returns a dataframe comparing the direct carbon emissions obtained from the LCIA phase (direct emissions module) and direct carbon emissions from the ESM. Please make sure that carbon emissions are expressed with the same physical unit, e.g., kg CO2-eq., in the ESM and LCIA method (while functional units, e.g., kWh, are automatically converted to ESM units).
- Parameters:
R_direct (pandas.DataFrame) – dataframe containing the direct carbon emissions from the LCIA phase
lcia_method_carbon_emissions (str) – name of the LCIA method for carbon emissions in brightway
carbon_flow_in_esm (str or list[str]) – names(s) of the carbon flow(s) in the ESM
esm_results (pandas.DataFrame) – dataframe containing the annual production of each technology in the ESM. It must contain the columns ‘Name’ and ‘Production’, and it can possibly contain the ‘Run’ and ‘Year’ columns too. If provided, the system’s direct emissions will be compared.
return_df (bool) – if True, the function will return the dataframe
save_df (bool) – if True, the function will save the dataframe to a csv file named direct_carbon_emissions_differences and a file named direct_carbon_emissions_differences_system (if esm_results is provided) in self.results_path_file
- Returns:
dataframe comparing the direct carbon emissions from the LCIA phase and the ESM if return_df is True
- Return type:
tuple[pd.DataFrame, pd.DataFrame | None] or None