Search code examples
brightway

Unlinked exchanges while importing from excel


I am currently trying to import the inventory from excel. I matched the names with ecoinvent 3.8 database and excel template to brightway2 format.

here

However, all my biosphere flows are unlinked together with some exchanges from ecoinvent. The differences are shown here

I could not understand what reference product meant and which location must be inserted for biosphere flows.

Could someone please help me understand where the difference is coming from and how I should go about it? Thank you very much in advance!


Solution

  • By default, the linking algorithm matches on all these fields:

    • "name"
    • "categories"
    • "unit"
    • "reference product"
    • "location"

    It looks to me that your biosphere flows aren't linking because they are missing the category field (there are multiple biosphere flows, one for each category). You can fix this by either adding the biosphere flow codes (then you match only on code, not other fields), or by including the categories. Note that categories are stored as a tuple, and brightway uses :: to separate the tuple elements, so ('foo', 'bar') would become foo::bar in your CSV or Excel.

    Your technosphere flows are linking because you don't specify the reference product. This fails to match because the background database does specify the reference product, so these attributes aren't the same. You can try to fix that by doing my_importer.match_database("ecoinvent 3.8_cutoff", fields=["name", "unit", "location"]), i.e. not matching on the reference product.