bw_hestia_bridge.strategies.linking =================================== .. py:module:: bw_hestia_bridge.strategies.linking Attributes ---------- .. autoapisummary:: bw_hestia_bridge.strategies.linking.DATA_DIR Functions --------- .. autoapisummary:: bw_hestia_bridge.strategies.linking.add_code_from_hestia_attributes bw_hestia_bridge.strategies.linking.create_mocks bw_hestia_bridge.strategies.linking.link_across_cycles bw_hestia_bridge.strategies.linking.link_ecoinvent_biosphere bw_hestia_bridge.strategies.linking.link_ecoinvent_technosphere bw_hestia_bridge.strategies.linking.link_to_previous_transformation bw_hestia_bridge.strategies.linking.pick_from_overlapping bw_hestia_bridge.strategies.linking.previous_transformation Module Contents --------------- .. py:function:: add_code_from_hestia_attributes(data: list) -> list .. py:function:: create_mocks(data) .. py:function:: link_across_cycles(data: list) -> list Link across two cycles using the `graph_element` attribute. In this product: ```python { 'name': 'Pig, piglet', 'term_type': 'liveAnimal', 'term_id': 'pigPiglet', 'type': 'product', 'cycle_id': 'baca63dqlc6n', 'graph_element': { 'from': { '@id': {'@id': 'baca63dqlc6n', '@type': 'Cycle'}, '@type': 'Cycle' }, 'to': { '@id': '5-qkgrlriqqm', '@type': 'Cycle' }, 'via': { 'term': { '@type': 'Term', 'termType': 'liveAnimal', 'name': 'Pig, piglet', '@id': 'pigPiglet' }, '@type': 'Product'} } } ``` We have a product (Pig, piglet) being produced by cycle `baca63dqlc6n` and used by cycle `5-qkgrlriqqm`. Here is the corresponding production exchanges in `baca63dqlc6n`: ```python { "type": "production", "name": "Pig, piglet", "term_type": "liveAnimal", "term_id": "pigPiglet", "unit": "number", "amount": 1, "transformation_id": null } ``` And the consuming exchange in `5-qkgrlriqqm`: ```python { "name": "Pig, piglet", "cycle_id": "5-qkgrlriqqm", "term_type": "liveAnimal", "term_id": "pigPiglet", "unit": "number", "amount": 1.026, "group": "Pig, piglet-0", "type": "technosphere" } ``` We normally only allow linking within one cycle, but in this case we need to link across cycles. .. py:function:: link_ecoinvent_biosphere(data: list, biosphere_label: Optional[str] = 'biosphere3') -> list .. py:function:: link_ecoinvent_technosphere(data: list, ecoinvent_database_label: str) -> list .. py:function:: link_to_previous_transformation(data) .. py:function:: pick_from_overlapping(exc: dict, possibles: collections.defaultdict, overlapping: list) -> None Try to find a provider of the supplied demand. `exc` is a dictionary; we use `term_id` (e.g. `manureSaltsKgK2O`) to search in `possibles`. `possibles` is a dictionary with keys of Hestia term `@id` keys, and values of bw2data processes which were mapped against the Hestia term ids in "ecoinvent_mappings_technosphere.csv". `overlapping` is an ordered list, from smallest to largest, or each region in ecoinvent which completely overlaps the `exc` dataset's location. We try to find the process in the correct `possibles` value list which most closely matches the `exc` dataset location. We also use fallback locations if necessary. The fallback locations are `RoE` (rest of Europe), `RoW` (rest of world), and `GLO` (global). If a match is found, adds `input` to the `exc`. .. py:function:: previous_transformation(val: str) -> str .. py:data:: DATA_DIR