polca / premise

Coupling Integrated Assessment Models output with Life Cycle Assessment.
BSD 3-Clause "New" or "Revised" License
101 stars 45 forks source link

Errors when using "write_db_to_brightway" #106

Closed SidiPeng closed 1 year ago

SidiPeng commented 1 year ago

Hey, I was using "write_db_to_brightway" from premise v.1.5.7. When I worked with ecoinvent v3.8, it worked perfectly, but errors occurred when I worked with ecoinvent v3.7.1 and v3.9.1. I am not an urgent user of v3.7.1 and v3.9.1, and I am just curious why these errors occur. :)

Here are my codes and errors :

bw2data.projects.set_current("premise") bw2data.databases clear_cache() bw.bw2setup()

ndb37 = NewDatabase( scenarios=[ {"model":"image", "pathway":"SSP2-RCP19", "year":2050}, ], source_db="ecoinvent 3.7.1_cutoff_ecoSpold02", source_version="3.7", key='......................' ) ndb39.update_all() ndb37.write_db_to_brightway(name=["ecoinvent 3.7.1_cutoff_ecoSpold02 image SSP2-RCP19 2050"]) error-3 7 1

ndb39 = NewDatabase( scenarios=[ {"model":"image", "pathway":"SSP2-RCP19", "year":2050}, ], source_type="ecospold", source_file_path=r"../database/ecoinvent 3.9.1_cutoff_ecoSpold02/datasets", source_version="3.9", key='......................' ) ndb39.update_all() ndb39.write_db_to_brightway(name=["ecoinvent 3.9.1_cutoff_ecoSpold02 image SSP2-RCP19 2050"]) error-3 9 1 (1) error-3 9 1 (2)

romainsacchi commented 1 year ago

Hi @SidiPeng,

let's look first at the case using ei 3.9. Can you confirm that the version of bw2io is 0.8.8? If not, update to bw2io==0.8.8 and update your biosphere database in your project. Then, try again.

SidiPeng commented 1 year ago

Thanks for your quick response! I run the following code: del bw2data.databases['biosphere3'] bw.bw2setup() New errors came:

image

Now, bw2io==0.8.8, premise==1.5.7, bw2data==3.6.6.

romainsacchi commented 1 year ago

OK, then try:

create_default_lcia_methods(overwrite=True)
romainsacchi commented 1 year ago

But in any case, while recreating the LCIA methods failed without overwrite=True, create_default_biosphere passed, so you may retry the creation of premise database see if you get the same error.

SidiPeng commented 1 year ago

But in any case, while recreating the LCIA methods failed without overwrite=True, create_default_biosphere passed, so you may retry the creation of premise database see if you get the same error.

Hi Romain. Thanks a lot for the reply. It worked for ecoinvent v3.9.1 successfully, but the same error arose as above for v3.7.1, unfortunately.

romainsacchi commented 1 year ago

Hi @SidiPeng ,

yes, it's an issue due to the incompatibility between the biospheres installed by bw2io 0.8.7 (which only works for ecoinvent up to and including 3.8) and bw2io 0.8.8 (which only works with ecoinvent 3.9) which hopefully may be resolved soon.