brightway-lca / brightway2-data

Tools for the management of inventory databases and impact assessment methods. Part of the Brightway LCA framework.
https://docs.brightway.dev/
BSD 3-Clause "New" or "Revised" License
8 stars 21 forks source link

Setting project (`bw2data.projects.set_current(...)`) leads to unlinked exchanges (Ecoinvent 3.8 import with `bw2io=0.8.7`) #118

Closed michaelweinold closed 1 year ago

michaelweinold commented 1 year ago

Steps to reproduce:

  1. Install conda environment:
conda create -n bw_test -c conda-forge bw2io=0.8.7 numpy=1.23.5
  1. Run import script:
import bw2io
import bw2data
bw2data.projects.set_current("ecoinvent38")
importer_ei38 = bw2io.SingleOutputEcospold2Importer(dirpath = <PATH>, db_name = 'ei38')
bw2io.create_core_migrations()
importer_ei38.apply_strategies()
importer_ei38.statistics()

Which leads to this error:

19565 datasets
629959 exchanges
388452 unlinked exchanges
  Type biosphere: 1018 unique unlinked exchanges
(19565, 629959, 388452)

Simply omitting the bw2data.projects.set_current("ecoinvent38") yields the expected 0 unlinked exchanges.

michaelweinold commented 1 year ago

Likely related to a corrupt Brightway project (in this case named ecoinvent38). Running the above with a different project name results in 0 unlinked exchanges.