mescal.utils ============ .. py:module:: mescal.utils Functions --------- .. autoapisummary:: mescal.utils._short_name_ds_type mescal.utils.change_mapping_year mescal.utils.change_year_in_name mescal.utils.ecoinvent_unit_convention mescal.utils.expand_impact_category_levels mescal.utils.premise_changing_names mescal.utils.random_code Module Contents --------------- .. py:function:: _short_name_ds_type(ds_type: str) -> str Returns the short name of the LCI dataset type :param ds_type: type of LCI dataset :return: short name of the LCI dataset type .. py:function:: change_mapping_year(mapping: pandas.DataFrame, year_from: int, year_to: int) -> pandas.DataFrame Change the year in the name of the activities and databases in the mapping file :param mapping: mapping file between the LCI database and the ESM database :param year_from: year of the original mapping file :param year_to: year of the new mapping file :return: updated mapping file .. py:function:: change_year_in_name(row: pandas.Series, year_from: int, year_to: int) -> pandas.Series Change the year in the name of the activity and database :param row: row of the mapping file :param year_from: year of the original mapping file :param year_to: year of the new mapping file :return: updated mapping row .. py:function:: ecoinvent_unit_convention(unit: str) -> str Reformat unit to the ecoinvent convention :param unit: unit to reformat :return: ecoinvent unit .. py:function:: expand_impact_category_levels(df: pandas.DataFrame, impact_category_col: str = 'Impact_category') -> pandas.DataFrame Expand the impact category levels into separate columns :param df: dataframe with impact category column :param impact_category_col: name of the impact category column :return: the dataframe with expanded impact category levels .. py:function:: premise_changing_names(activity_name: str, activity_prod: str, activity_loc: str, name_premise_db, premise_db_dict_name: dict, premise_changes: pandas.DataFrame = None) -> tuple[str, str, str] Returns the updated name, product and location in case some changes have occurred in premise :param activity_name: name of the LCI dataset :param activity_prod: product of the LCI dataset :param activity_loc: location of the LCI dataset :param name_premise_db: name of the premise database :param premise_db_dict_name: dictionary of the database with (name, product, location, database) as key :param premise_changes: file of the premise name changes impacting the mapping :return: the updated name, product and location of the LCI dataset .. py:function:: random_code() -> str Create a random code :return: code