dopo.lca

Generates and saves Life Cycle Assessment (LCA) scores plots for various sectors.

The module computes LCA scores for activities and methods.

Attributes

bc_version

Functions

_agg_small_inputs(dataframe[, cutoff])

Aggregates small inputs in a DataFrame into an "other" input category.

_compare_activities_multiple_methods(→ pandas.DataFrame)

Compares a list of activities using multiple LCA methods and stores the results in a dictionary

compare_activities_by_grouped_leaves(activities, ...)

Compare activities by the impact of their different inputs, aggregated by the product classification of those inputs.

find_leaves(activity, lcia_method[, results, lca_obj, ...])

Traverse the supply chain of an activity to find leaves - places where the impact of that

sector_lca_scores(→ dict)

Generates LCA score tables for each sector's activity list, including total scores and CPC

Module Contents

dopo.lca._agg_small_inputs(dataframe, cutoff=0.01)[source]

Aggregates small inputs in a DataFrame into an “other” input category.

This function calculates the sum of scores for each group of activities and then calculates the percentage for each row. Rows with less than the specified cutoff percentage are labeled as “Other”. The function then groups the DataFrame by the same columns and ‘input’ to aggregate scores.

Parameters:
  • dataframe (pandas DataFrame) – A DataFrame containing LCA scores for activities.

  • cutoff (float, optional) – A threshold value for summarizing inputs below or equal to this value in an “other” column.

Returns:

A DataFrame with aggregated scores.

Return type:

pandas DataFrame

dopo.lca._compare_activities_multiple_methods(activities: list, methods: list, output_format: str = 'pandas', mode: str = 'absolute', cutoff: float = 0.01, cache=None) pandas.DataFrame[source]

Compares a list of activities using multiple LCA methods and stores the results in a dictionary of DataFrames.

This function generates comparison results for each method in methods, formats them into DataFrames, and organizes them in a dictionary where the keys are method-specific names derived from the identifier and method details. Each DataFrame contains total scores and input contributions, with columns ordered and indexed appropriately.

Parameters:
  • activities (list) – A list of activities to compare.

  • methods (list) – A list of methods to use for comparison.

  • output_format (str, optional) – The format of the output DataFrame.

  • mode (str, optional) – The mode of the comparison.

Returns:

A pandas DataFrame containing LCA scores.

Return type:

pd.DataFrame

dopo.lca.compare_activities_by_grouped_leaves(activities, lcia_method, mode='relative', max_level=4, cutoff=0.0075, output_format='list', str_length=50, cache=None)[source]

Compare activities by the impact of their different inputs, aggregated by the product classification of those inputs.

Args:

activities: list of Activity instances. lcia_method: tuple. LCIA method to use when traversing supply chain graph. mode: str. If “relative” (default), results are returned as a fraction of total input. Otherwise, results are absolute impact per input exchange. max_level: int. Maximum level in supply chain to examine. cutoff: float. Fraction of total impact to cutoff supply chain graph traversal at. output_format: str. See below. str_length; int. If output_format is html, this controls how many characters each column label can have.

Raises:

ValueError: activities is malformed.

Returns:

Depends on output_format:

  • list: Tuple of (column labels, data)

  • html: HTML string that will print nicely in Jupyter notebooks.

  • pandas: a pandas DataFrame.

dopo.lca.find_leaves(activity, lcia_method, results=None, lca_obj=None, amount=1, total_score=None, level=0, max_level=3, cutoff=0.025, cache=None, activities_to_exclude_from_cache=None)[source]

Traverse the supply chain of an activity to find leaves - places where the impact of that component falls below a threshold value.

Returns a list of (impact of this activity, amount consumed, Activity instance) tuples.

dopo.lca.sector_lca_scores(sectors, methods, cutoff=0.01) dict[source]

Generates LCA score tables for each sector’s activity list, including total scores and CPC input contributions.

This function calculates LCA scores for activities within each sector using methods specified in the method_dict. Inputs below or equal to the cutoff value are summarized in an “other” column.

Parameters:
  • sectors (dict) – A dictionary where keys are sector names and values are lists of activities.

  • methods (list) – A list of methods to use for LCA calculations.

  • cutoff (float, optional) – A threshold value for summarizing inputs below or equal to this value in an “other” column.

Returns:

A dictionary where each key is a sector name and each value is a DataFrame containing LCA scores.

Return type:

dict

dopo.lca.bc_version[source]