bw2io.strategies.products#

Attributes#

Functions#

create_products_as_new_nodes(→ List[dict])

Create new product nodes and link to them if needed.

separate_processes_from_products(→ List[dict])

Given a set of processes, and no separate data on products, create copies of the processes

Module Contents#

bw2io.strategies.products.create_products_as_new_nodes(data: List[dict]) List[dict][source]#

Create new product nodes and link to them if needed.

We create new product if the following conditions are met:

  • The dataset is not multifunctional (

    dataset.get(“type”) != bd.labels.multifunctional_node_default). Multifunctional datasets handle product creation separately.

  • The edge is functional (obj.get(“functional”) is True)

  • The edge is unlinked (obj.get(“input”) is falsey)

  • The given edge has a name, and that name is different than the dataset name

  • The combination of name and location is not present in the other dataset nodes. If no

    location attribute is given for the edge under consideration, we use the location of the dataset.

Create new nodes, and links the originating edges to the new product nodes.

Modifies data in-place, and returns the modified data.

bw2io.strategies.products.separate_processes_from_products(data: List[dict], field_exclusions=['location'], code_suffix: str = '-product') List[dict][source]#

Given a set of processes, and no separate data on products, create copies of the processes as products and re-link the local supply chain.

Designed for use in importing databases where processes are not strongly typed as different from products.

Copies over all attributes from the source processes except:

  • Those listed in field_exclusions

  • type is set to bw2data.labels.product_node_default

  • Uses the code_suffix to generate a new code value (previous plus code suffix)

  • No edges are copied over

  • If the attribute is present reference product, this is used as the product name

Should come late in the import process, when internal links are all present.

bw2io.strategies.products.EDGE_CORE_COLUMNS = ['name', 'amount', 'database', 'location', 'unit', 'functional', 'type', 'uncertainty type',...[source]#