REGISTER NOW: DdS Autumn School! 🇨🇭 Grosshöchstetten (Switzerland) 🗓️ 6.-11. October 2024

bw2io.strategies.biosphere#

Module Contents#

Functions#

drop_unspecified_subcategories(db)

Drop subcategories if they are in the following:

ensure_categories_are_tuples(db)

Convert dataset categories to tuples in the given database, if they are not already tuples.

normalize_biosphere_categories(db[, lcia])

Normalize biosphere categories to ecoinvent 3.1 standard in the given database.

normalize_biosphere_names(db[, lcia])

Normalize biosphere flow names to ecoinvent 3.1 standard in the given database.

strip_biosphere_exc_locations(db)

Remove locations from biosphere exchanges in the given database, as biosphere exchanges are not geographically specific.

bw2io.strategies.biosphere.drop_unspecified_subcategories(db)[source]#

Drop subcategories if they are in the following: * unspecified * (unspecified) * '' (empty string) * None

Parameters#

dblist

A list of datasets, each containing exchanges.

Returns#

list

A modified list of datasets with unspecified subcategories removed.

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#

dblist

A list of datasets, each containing exchanges.

Returns#

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#

dblist

A list of datasets, each containing exchanges.

lciabool, optional

If True, only normalize biosphere categories in LCIA datasets. Defaults to False.

Returns#

list

A modified list of datasets with normalized biosphere categories.

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#

dblist

A list of datasets, each containing exchanges.

lciabool, optional

If True, only normalize biosphere flow names in LCIA datasets. Default is False.

Returns#

list

A modified list of datasets with normalized biosphere flow names.

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#

dblist

A list of datasets, each containing exchanges.

Returns#

list

A modified list of datasets with locations removed from biosphere exchanges.

Examples#

>>> db = [{"exchanges": [{"type": "biosphere", "location": "GLO"}]}]
>>> new_db = strip_biosphere_exc_locations(db)
>>> new_db
[{"exchanges": [{"type": "biosphere"}]}]