mescal.CPC ========== .. py:module:: mescal.CPC Functions --------- .. autoapisummary:: mescal.CPC._add_CPC_categories_based_on_existing_activities mescal.CPC._add_product_or_activity_CPC_category mescal.CPC._save_mapping_between_products_and_CPC_categories mescal.CPC.add_CPC_categories Module Contents --------------- .. py:function:: _add_CPC_categories_based_on_existing_activities(self, mapping_existing_products_to_cpc: dict) -> None Add CPC categories to a database based on existing activities :param mapping_existing_products_to_cpc: dictionary mapping existing products to CPC categories. The latter has been generated using the _save_mapping_between_products_and_CPC_categories method. :return: None .. py:function:: _add_product_or_activity_CPC_category(self, name: str, CPC_category: str, search_type: str, key: str, overwrite_existing_CPC: bool) -> None Add a CPC category to a set of activities in a LCI database :param name: name or part of the name of the product or activity :param CPC_category: CPC category to add :param search_type: 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) :param key: searching key, it can be 'name' or 'reference product' :param overwrite_existing_CPC: if True, overwrite existing CPC categories in the database with the ones of the mapping :return: None .. py:function:: _save_mapping_between_products_and_CPC_categories(self, return_dict: bool = False, save_dict: bool = True) -> dict or None Crate a dictionary mapping the database products and their CPC categories and return it save it as a json file :param return_dict: if True, return the dictionary :param save_dict: if True, save the dictionary as a json file in the current directory :return: dictionary mapping products to CPC categories (if return_type is 'return' or 'both') or None (if return_type is 'save') .. py:function:: 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 Add CPC categories to a database, and write it as a new database if asked :param mapping_existing_products_to_CPC: 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. :param mapping_new_products_to_CPC: 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. :param new_db_name: name of the new database (only required if write is True) :param write: if True, write the new database in the Brightway project :param overwrite_existing_CPC: 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) :return: None