bw2io.strategies.exiobase
#
Module Contents#
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 |
- 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#
- correspondencelist of dict
A list of dictionaries containing correspondence data.
- biosphereslist, optional
A list of biosphere database names. Defaults to the biosphere defined in the configuration file.
Returns#
- list of dict
The correspondence data with added âidâ keys.
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#
- productslist of dict
A list of dictionaries containing product data.
- db_namestr
The name of the database to look up the product IDs.
Returns#
- list of dict
The products data with added âidâ keys.
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#
- list of dict
The updated list of dictionaries with added STAM labels.
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#
- xdict
A dictionary containing âecoinvent categoryâ and âecoinvent subcategoryâ.
Returns#
- tuple
A tuple containing the ecoinvent category and subcategory if both are available, or just the category if the subcategory is not available.
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#
- list of dict
A list of dictionaries containing Exiobase biosphere correspondence data.
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#
- datalist
A list of dictionaries where each dictionary contains a key-value pair for the specified label.
- labelstr, optional
The label of the key in the dictionaries whose value needs to be normalized (default: âunitâ).
Returns#
- list
The updated list of dictionaries with normalized units.
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#
- productslist of dict
A list of dictionaries, where each dictionary contains a key-value pair for the product name.
Returns#
- list of dict
The updated list of dictionaries with numeric codes removed from product names.
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#
- flowslist of dict
A list of dictionaries, where each dictionary contains a key-value pair for the âexiobase nameâ.
Returns#
- list of dict
The updated list of flows with renamed CO2 equivalent flows.
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)"}, ]