mescal.CPC

Functions

_add_CPC_categories_based_on_existing_activities(→ None)

Add CPC categories to a database based on existing activities

_add_product_or_activity_CPC_category(→ None)

Add a CPC category to a set of activities in a LCI database

_save_mapping_between_products_and_CPC_categories(...)

Crate a dictionary mapping the database products and their CPC categories and return it save it as a json file

add_CPC_categories(→ None)

Add CPC categories to a database, and write it as a new database if asked

Module Contents

mescal.CPC._add_CPC_categories_based_on_existing_activities(self, mapping_existing_products_to_cpc: dict) None[source]

Add CPC categories to a database based on existing activities

Parameters:

mapping_existing_products_to_cpc (dict) – dictionary mapping existing products to CPC categories. The latter has been generated using the _save_mapping_between_products_and_CPC_categories method.

Returns:

None

Return type:

None

mescal.CPC._add_product_or_activity_CPC_category(self, name: str, CPC_category: str, search_type: str, key: str, overwrite_existing_CPC: bool) None[source]

Add a CPC category to a set of activities in a LCI database

Parameters:
  • name (str) – name or part of the name of the product or activity

  • CPC_category (str) – CPC category to add

  • search_type (str) – type of search, it can be ‘equals’ (i.e., exact name matching) or ‘contains’ (i.e., name is in the activity name or product name)

  • key (str) – searching key, it can be ‘name’ or ‘reference product’

  • overwrite_existing_CPC (bool) – if True, overwrite existing CPC categories in the database with the ones of the mapping

Returns:

None

Return type:

None

mescal.CPC._save_mapping_between_products_and_CPC_categories(self, return_dict: bool = False, save_dict: bool = True) dict or None[source]

Crate a dictionary mapping the database products and their CPC categories and return it save it as a json file

Parameters:
  • return_dict (bool) – if True, return the dictionary

  • save_dict (bool) – if True, save the dictionary as a json file in the current directory

Returns:

dictionary mapping products to CPC categories (if return_type is ‘return’ or ‘both’) or None (if return_type is ‘save’)

Return type:

dict or None

mescal.CPC.add_CPC_categories(self, mapping_existing_products_to_CPC: dict or str = 'default', mapping_new_products_to_CPC: pd.DataFrame or str = 'default', new_db_name: str = None, write: bool = False, overwrite_existing_CPC: bool = False) None[source]

Add CPC categories to a database, and write it as a new database if asked

Parameters:
  • mapping_existing_products_to_CPC (dict or str) – mapping between existing products and CPC categories, can be a dictionary or the path towards a json file. If ‘default’, the default mapping will be used.

  • mapping_new_products_to_CPC (pd.DataFrame or str) – mapping between new products (i.e., addition with respect to ecoinvent products) and CPC categories, can be a pandas DataFrame or the path towards the csv file. If ‘default’, the default mapping will be used.

  • new_db_name (str) – name of the new database (only required if write is True)

  • write (bool) – if True, write the new database in the Brightway project

  • overwrite_existing_CPC (bool) – if True, overwrite existing CPC categories in the database with the ones of the mapping_new_products_to_CPC mapping (default is False, i.e., do not overwrite existing CPC categories)

Returns:

None

Return type:

None