bw2io.strategies.biosphere#
Functions#
Drop subcategories if they are in the following: |
|
Convert dataset categories to tuples in the given database, if they are not already tuples. |
|
|
Normalize biosphere categories to ecoinvent 3.1 standard in the given database. |
|
Normalize biosphere flow names to ecoinvent 3.1 standard in the given database. |
Remove locations from biosphere exchanges in the given database, as biosphere exchanges are not geographically specific. |
Module Contents#
- bw2io.strategies.biosphere.drop_unspecified_subcategories(db)[source]#
Drop subcategories if they are in the following: *
unspecified
*(unspecified)
*''
(empty string) *None
- Parameters:
db (list) – A list of datasets, each containing exchanges.
- Returns:
A modified list of datasets with unspecified subcategories removed.
- Return type:
list
Examples
>>> db = [{"categories": ["A", "unspecified"]}, {"exchanges": [{"categories": ["B", ""]}]}, {"categories": ["C", None]}] >>> new_db = drop_unspecified_subcategories(db) >>> new_db [{"categories": ["A"]}, {"exchanges": [{"categories": ["B"]}]}, {"categories": ["C"]}]
- bw2io.strategies.biosphere.ensure_categories_are_tuples(db)[source]#
Convert dataset categories to tuples in the given database, if they are not already tuples.
- Parameters:
db (list) – A list of datasets, each containing exchanges.
- Return type:
A modified list of datasets with categories as tuples.
Examples
>>> db = [{"categories": ["A", "B"]}, {"categories": ("C", "D")}] >>> new_db = ensure_categories_are_tuples(db) >>> new_db [{"categories": ("A", "B")}, {"categories": ("C", "D")}]
- bw2io.strategies.biosphere.normalize_biosphere_categories(db, lcia=False)[source]#
Normalize biosphere categories to ecoinvent 3.1 standard in the given database.
- Parameters:
db (list) – A list of datasets, each containing exchanges.
lcia (bool, optional) – If True, only normalize biosphere categories in LCIA datasets. Defaults to False.
- Returns:
A modified list of datasets with normalized biosphere categories.
- Return type:
list
Examples
>>> db = [{"categories": ["old_biosphere_category"]}] >>> new_db = normalize_biosphere_categories(db) >>> new_db [{"categories": ["new_biosphere_category"]}]
- bw2io.strategies.biosphere.normalize_biosphere_names(db, lcia=False)[source]#
Normalize biosphere flow names to ecoinvent 3.1 standard in the given database.
Assumes that each dataset and each exchange have a
name
. Will change names even if exchange is already linked.- Parameters:
db (list) – A list of datasets, each containing exchanges.
lcia (bool, optional) – If True, only normalize biosphere flow names in LCIA datasets. Default is False.
- Returns:
A modified list of datasets with normalized biosphere flow names.
- Return type:
list
Examples
>>> db = [{"name": "old_biosphere_name"}] >>> new_db = normalize_biosphere_names(db) >>> new_db [{"name": "new_biosphere_name"}]
- bw2io.strategies.biosphere.strip_biosphere_exc_locations(db)[source]#
Remove locations from biosphere exchanges in the given database, as biosphere exchanges are not geographically specific.
- Parameters:
db (list) – A list of datasets, each containing exchanges.
- Returns:
A modified list of datasets with locations removed from biosphere exchanges.
- Return type:
list
Examples
>>> db = [{"exchanges": [{"type": "biosphere", "location": "GLO"}]}] >>> new_db = strip_biosphere_exc_locations(db) >>> new_db [{"exchanges": [{"type": "biosphere"}]}]