bw2io.strategies.exiobase#
Functions#
|
Add 'id' key to each dictionary in the list of correspondence data based on the ecoinvent |
|
Add 'id' key to each dictionary in the list of products based on the name and location |
|
Adds STAM labels to the input data, which should be a list |
Takes a dictionary containing 'ecoinvent category' and |
|
Reads the 'EXIOBASE-ecoinvent-biosphere.csv' file and |
|
|
|
|
Removes any numeric codes found at the end of the product names |
|
Renames CO2 equivalent flows in the input list of flows. The |
Module Contents#
- bw2io.strategies.exiobase.add_biosphere_ids(correspondence, biospheres=None)[source]#
Add âidâ key to each dictionary in the list of correspondence data based on the ecoinvent and exiobase names found in the specified biosphere databases.
- Parameters:
correspondence (list of dict) â A list of dictionaries containing correspondence data.
biospheres (list, optional) â A list of biosphere database names. Defaults to the biosphere defined in the configuration file.
- Returns:
The correspondence data with added âidâ keys.
- Return type:
list of dict
- Raises:
ValueError â If the correspondence data does not have the required keys, or if a specified biosphere database does not exist.
Examples
>>> correspondence_data = [{'ecoinvent name': 'CO2', 'exiobase name': 'CO2', 'ecoinvent category': 'air', 'ecoinvent subcategory': ''}] >>> add_biosphere_ids(correspondence_data) [{'ecoinvent name': 'CO2', 'exiobase name': 'CO2', 'ecoinvent category': 'air', 'ecoinvent subcategory': '', 'id': some_id}]
- bw2io.strategies.exiobase.add_product_ids(products, db_name)[source]#
Add âidâ key to each dictionary in the list of products based on the name and location of the products found in the specified database.
- Parameters:
products (list of dict) â A list of dictionaries containing product data.
db_name (str) â The name of the database to look up the product IDs.
- Returns:
The products data with added âidâ keys.
- Return type:
list of dict
- Raises:
ValueError â If the product data does not have the required keys, or if the specified database does not exist.
Examples
>>> products_data = [{'name': 'Electricity', 'location': 'CH'}] >>> add_product_ids(products_data, 'ecoinvent 3.7.1') [{'name': 'Electricity', 'location': 'CH', 'id': some_id}]
- bw2io.strategies.exiobase.add_stam_labels(data)[source]#
Adds STAM labels to the input data, which should be a list of dictionaries containing a key-value pair for the name. The STAM labels are loaded from a JSON file located in the âlciâ directory.
Parameters
for the name.
- Returns:
The updated list of dictionaries with added STAM labels.
- Return type:
list of dict
- Raises:
TypeError â If data is not a list of dictionaries.
Examples
>>> data = [ ... {"name": "element 1"}, ... {"name": "element 2"}, ... ] >>> add_stam_labels(data) [ {"name": "element 1", "stam": "STAM 1"}, {"name": "element 2", "stam": "STAM 2"}, ]
- bw2io.strategies.exiobase.get_categories(x)[source]#
Takes a dictionary containing âecoinvent categoryâ and âecoinvent subcategoryâ keys and returns a tuple containing the category and subcategory if both are available, or just the category if the subcategory is not available.
- Parameters:
x (dict) â A dictionary containing âecoinvent categoryâ and âecoinvent subcategoryâ.
- Returns:
A tuple containing the ecoinvent category and subcategory if both are available, or just the category if the subcategory is not available.
- Return type:
tuple
Examples
>>> data = {'ecoinvent category': 'Energy', 'ecoinvent subcategory': 'Electricity'} >>> get_categories(data) ('Energy', 'Electricity')
- bw2io.strategies.exiobase.get_exiobase_biosphere_correspondence()[source]#
Reads the âEXIOBASE-ecoinvent-biosphere.csvâ file and returns the correspondence data as a list of dictionaries. The file is expected to be in the âdata_directory/lciâ directory.
- Returns:
A list of dictionaries containing Exiobase biosphere correspondence data.
- Return type:
list of dict
Examples
>>> correspondence_data = get_exiobase_biosphere_correspondence()
- bw2io.strategies.exiobase.normalize_units(data, label='unit')[source]#
â Normalize the units of the given data by replacing them with their equivalent, standardized representations. The function takes a list of dictionaries where each dictionary contains a key-value pair for the specified label (default: âunitâ). The function uses a lookup table to replace the unit values with their standardized representations.
- Parameters:
data (list) â A list of dictionaries where each dictionary contains a key-value pair for the specified label.
label (str, optional) â The label of the key in the dictionaries whose value needs to be normalized (default: âunitâ).
- Returns:
The updated list of dictionaries with normalized units.
- Return type:
list
Examples
>>> data = [ ... {"unit": "M.EUR"}, ... {"unit": "1000 p"}, ... {"unit": "M.hr"}, ... ] >>> normalize_units(data) [ {"unit": "million âŹ"}, {"unit": "1000 people"}, {"unit": "million hour"}, ]
- bw2io.strategies.exiobase.remove_numeric_codes(products)[source]#
Removes any numeric codes found at the end of the product names in the given list of products.
- Parameters:
products (list of dict) â A list of dictionaries, where each dictionary contains a key-value pair for the product name.
- Returns:
The updated list of dictionaries with numeric codes removed from product names.
- Return type:
list of dict
- Raises:
TypeError â If products is not a list of dictionaries.
Examples
>>> products = [ ... {"name": "product A (01)"}, ... {"name": "product B (99)"}, ... ] >>> remove_numeric_codes(products) [ {"name": "product A"}, {"name": "product B"}, ]
- bw2io.strategies.exiobase.rename_exiobase_co2_eq_flows(flows)[source]#
Renames CO2 equivalent flows in the input list of flows. The input list should contain dictionaries with a key-value pair for the âexiobase nameâ. The function updates the âexiobase nameâ for the flows that match the provided mapping.
- Parameters:
flows (list of dict) â A list of dictionaries, where each dictionary contains a key-value pair for the âexiobase nameâ.
- Returns:
The updated list of flows with renamed CO2 equivalent flows.
- Return type:
list of dict
Examples
>>> flows = [ ... {"exiobase name": "PFC - air"}, ... {"exiobase name": "HFC - air"}, ... ] >>> rename_exiobase_co2_eq_flows(flows) [ {"exiobase name": "PFC (CO2-eq)"}, {"exiobase name": "HFC (CO2-eq)"}, ]