polca / premise

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

A problem with "ndb.update_external_scenario()" #172

Closed MMahdi97 closed 1 month ago

MMahdi97 commented 1 month ago

Hello everyone, I am trying to run the hydrogen example case that can be found here (https://github.com/premise-community-scenarios/hydrogen-prospective-scenarios) and here is the code I am using

from premise import *
import bw2data
from datapackage import Package
import brightway2 as bw

bw2data.projects.set_current("test")    

fp = r"Z:\Uni-LUT\Thesis\Code\Hydrogen example\datapackage.json"
hydrogen = Package(fp)

ndb = NewDatabase(
            scenarios = [
                {"model":"remind", "pathway":"SSP2-Base", "year":2050},
                {"model":"remind", "pathway":"SSP2-PkBudg1150", "year":2050},
           ],           
            source_type="ecospold", # <--- this is NEW
            source_file_path=r"C:\Users\z132387\Ecoinvent39_cut_off\ecoinvent 3.9_cutoff_ecoSpold02\datasets", # <-- this is NEW
            source_version="3.9",
            key='tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',
            external_scenarios=[
               hydrogen, # <-- list datapackages here
            ] 
)

ndb.update_external_scenario()

but after running ndb.update_external_scenario(), I will have an error (the following picture) image

Could someone please help me understand how to update the external scenario? Thank you so much.

MMahdi97 commented 1 month ago

I also used ndb.update("external"), but it did not change anything in the results!! Could someone help me?

romainsacchi commented 1 month ago

Since v.2.0.0 this method no longer exists. You need to use .update() instead. You are saying that using .update() leads to the same error message?

MMahdi97 commented 1 month ago

I realized that when I am using the following code for an external scenario, I have to add "external scenarios": external_scenarios at the end of each scenario model. If I don't add this, nothing will happen after using .update("external"). Is it correct?

fp = r"Z:\Uni-LUT\Thesis\Code\Hydrogen example\datapackage.json"
hydrogen = Package(fp)

external_scenarios = [
    {"scenario": "Ambitious", "data": hydrogen},
]

ndb = NewDatabase(
            scenarios = [
                {"model":"remind", "pathway":"SSP2-PkBudg1150", "year":2030, "external scenarios": external_scenarios},
                {"model":"remind", "pathway":"SSP2-PkBudg1150", "year":2050, "external scenarios": external_scenarios},
           ],           
            source_type="ecospold", # <--- this is NEW
            source_file_path=r"C:\Users\z132387\Ecoinvent39_cut_off\ecoinvent 3.9_cutoff_ecoSpold02\datasets", # <-- this is NEW
            source_version="3.9",
            key='tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',
)
romainsacchi commented 1 month ago

Yes, as shown in the examples notebook and documentation.