mescal.contribution_analysis
Classes
Activity Browser version of bw2analyzer.ContributionAnalysis |
Functions
|
Internal function to export comprehensive Excel file. |
|
Process contribution analysis data for environmental impacts. |
Module Contents
- class mescal.contribution_analysis.ABContributionAnalysis[source]
Bases:
bw2analyzer.ContributionAnalysisActivity Browser version of bw2analyzer.ContributionAnalysis
- sort_array(data: numpy.array, limit: float = 25, limit_type: str = 'number', total: float | None = None) numpy.array[source]
Activity Browser version of bw2analyzer.ContributionAnalysis.sort_array.
Should be removed once https://github.com/brightway-lca/brightway2-analyzer/pull/32 is merged. See PR above on why we overwrite this function.
- Parameters:
data (numpy.array)
limit (float)
limit_type (str)
total (Optional[float])
- Return type:
numpy.array
- mescal.contribution_analysis._export_comprehensive_excel(df: pandas.DataFrame, unit_type_groups_dict: dict, saving_path: str, act_types: list[str], contribution_type: str, detail_col: str) None[source]
Internal function to export comprehensive Excel file.
- Parameters:
df (pandas.DataFrame) – DataFrame with contribution analysis results
unit_type_groups_dict (dict) – Dictionary mapping (ESM, Type) to list of technology names
saving_path (str) – Output directory for Excel file
act_types (list[str]) – List of activity types to include in Excel export
contribution_type (str) – Type of contribution analysis: ‘processes’ or ‘emissions’
detail_col (str) – Column name for process or emission details (‘process_name’ or ‘ef_name’)
- Returns:
None
- Return type:
None
- mescal.contribution_analysis.process_contribution_data(contrib_df: pandas.DataFrame, impact_scores_df: pandas.DataFrame, unit_conversion_df: pandas.DataFrame, contribution_type: str = 'processes', saving_path: str = None, export_excel: bool = False, act_types: list[str] = None) tuple[pandas.DataFrame, dict][source]
Process contribution analysis data for environmental impacts.
- Parameters:
contrib_df (pandas.DataFrame) – contribution analysis dataframe (processes or emissions)
impact_scores_df (pandas.DataFrame) – impact scores dataframe with total impacts
unit_conversion_df (pandas.DataFrame) – unit conversion dataframe
contribution_type (str) – Type of contribution analysis: ‘processes’ or ‘emissions’
saving_path (str) – Output directory for Excel file (required if export_excel=True)
export_excel (bool) – Whether to export comprehensive Excel file
act_types (list[str]) – List of activity types for Excel export
- Returns:
Processed DataFrame with impact_share column, Unit type groups dictionary
- Return type:
tuple[pandas.DataFrame, dict]