Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in writing superstructure #190

Open
OliverLyon opened this issue Nov 12, 2024 · 5 comments
Open

Error in writing superstructure #190

OliverLyon opened this issue Nov 12, 2024 · 5 comments

Comments

@OliverLyon
Copy link

I was trying to write the scenarios created from ecoinvent 3.7.1 based on the inbuilt scenarios using:
ndb.write_superstructure_db_to_brightway(name="test_superstructure"),

It gave me an error of:
UnknownObject: Exchange between ('biosphere3', 'e030108f-2125-4bcb-a73b-ad72130fcca3') and ('test_superstructure', '00110620-4d86-4fd5-82d3-3cf415a4b941') is invalid - one of these objects is unknown (i.e. doesn't exist as a process dataset)

Does anyone know what unknown object it is referring to and how to solve this problem?
Thanks

@romainsacchi
Copy link
Collaborator

Hi @OliverLyon, can you paste the script you used?

@romainsacchi
Copy link
Collaborator

@OliverLyon can you check that you have a flow called:

Nickel, ion with the compartment water, ground in your biosphere database in the project to which you are trying to expert the superstructure database?

@OliverLyon
Copy link
Author

Hi @OliverLyon, can you paste the script you used?

Hi @romainsacchi, the script is pasted below:

from bw2data import databases
print(databases)
from bw2data import Database
import bw2data as bw
bw.databases
import bw2calc as bc
import bw2io as bi
from premise import *
clear_inventory_cache()

ndb = NewDatabase(
scenarios = [
{"model": "REMIND", "pathway": "SSP1-NPi", "year": 2020},
{"model": "REMIND", "pathway": "SSP1-NPi", "year": 2030},
{"model": "REMIND", "pathway": "SSP1-NPi", "year": 2040},
{"model": "REMIND", "pathway": "SSP1-NPi", "year": 2050},
],
source_type="ecospold",
source_file_path=r"C:\Users\EcoInvent\ecoinvent 3.7.1_cutoff_ecoSpold02\datasets",
source_version="3.7.1",
key='tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',
use_cached_inventories=True, # This will use any cached inventories
keep_source_db_uncertainty=False, # False by default, set to True if you want to keep ecoinvent's uncertainty data
keep_imports_uncertainty=False, # False by default, set to True if you want to keep the uncertainty data of the additional inventories
use_absolute_efficiency=False, # False by default, set to True if you want to use the IAM's absolute efficiencies
)

ndb.write_superstructure_db_to_brightway(name="test_superstructure"),

@OliverLyon
Copy link
Author

OliverLyon commented Nov 18, 2024

cx

@OliverLyon can you check that you have a flow called:

Nickel, ion with the compartment water, ground in your biosphere database in the project to which you are trying to expert the superstructure database?

I used the following code to check the flow Nickel, ion:

import bw2data as bd
import bw2io

bd.projects.set_current('yourProject')

importer = SingleOutputEcospold2Importer(
r"C:\Users\Desktop\EcoInvent\ecoinvent 3.7.1_cutoff_ecoSpold02\datasets",
"ecoinvent_ecospold"
)
importer.apply_strategies()
importer.statistics()

importer.drop_unlinked(True)

importer.write_database()

bio = bd.Database(db_name)

nickel_ion_flows = bio.search('Nickel, ion')

filtered_flows = [flow for flow in nickel_ion_flows if 'water, ground' in flow['categories']]

if filtered_flows:
for flow in filtered_flows:
print(f"Flow code: {flow['code']}")
print(f"Flow details: {flow.dict}")
else:
print("No flows found for 'Nickel, ion' in 'water, ground'.")

I gave me an output of 'No flows found for 'Nickel, ion' in 'water, ground'.

Is it the correct way to check the flow?

@romainsacchi
Copy link
Collaborator

Not exactly. This flow should be found in your biosphere3 database, not the ecoinvent one. Your brightway project yourProject should contain a biosphere3 database listing all environmental flows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants