premise-community-scenarios / scenario-example-bread

This is an example of a repository containing a custom prospective scenario for bread, to be used in premise
2 stars 3 forks source link

Error message, when creating fuel supply chains #1

Closed marcosdbw closed 2 years ago

marcosdbw commented 2 years ago

Hi! After successfully running the code that adds an external scenario (bread scenario), I applied the ndb.update_all() function.

Then, after a while, I got an error message when the code was updating the fuel supply chains (I copied and pasted below what I got). I would like to know how to solve it so that I can write the database with the bread scenario. Thanks a lot!

..... ////////////////////////////// FUELS /////////////////////////////// Generate region-specific direct air capture processes. Generate region-specific hydrogen production pathways.

IndexError Traceback (most recent call last) Input In [6], in ----> 1 ndb.update_all()

File ~\Miniconda3\envs\bw2\lib\site-packages\premise\ecoinvent_modification.py:983, in NewDatabase.update_all(self) 981 self.update_cement() 982 self.update_steel() --> 983 self.update_fuels() 984 self.update_external_scenario()

File ~\Miniconda3\envs\bw2\lib\site-packages\premise\ecoinvent_modification.py:781, in NewDatabase.update_fuels(self) 771 if "exclude" not in scenario or "update_fuels" not in scenario["exclude"]: 773 fuels = Fuels( 774 database=scenario["database"], 775 iam_data=scenario["iam data"], (...) 779 version=self.version, 780 ) --> 781 fuels.generate_fuel_markets() 782 scenario["database"] = fuels.database

File ~\Miniconda3\envs\bw2\lib\site-packages\premise\fuels.py:1507, in Fuels.generate_fuel_markets(self) 1503 """Create new fuel supply chains 1504 and update existing fuel markets""" 1506 # Create new fuel supply chains -> 1507 self.generate_fuel_supply_chains() 1509 print("Generate new fuel markets.") 1511 # we start by creating region-specific "diesel, burned in" markets

File ~\Miniconda3\envs\bw2\lib\site-packages\premise\fuels.py:1488, in Fuels.generate_fuel_supply_chains(self) 1486 # hydrogen 1487 print("Generate region-specific hydrogen production pathways.") -> 1488 self.generate_hydrogen_activities() 1490 # biogas 1491 print("Generate region-specific biogas and syngas supply chains.")

File ~\Miniconda3\envs\bw2\lib\site-packages\premise\fuels.py:311, in Fuels.generate_hydrogen_activities(self) 307 hydrogen_sources = fetch_mapping(HYDROGEN_SOURCES) 309 for hydrogen_type, hydrogen_activity in hydrogen_sources.items(): --> 311 new_ds = self.fetch_proxies( 312 name=hydrogen_activity["name"], 313 ref_prod="Hydrogen", 314 production_variable=hydrogen_activity["var"], 315 relink=True, 316 ) 318 for region, dataset in new_ds.items(): 319 320 # we adjust the electrolysis efficiency 321 if hydrogen_type == "from electrolysis":

File ~\Miniconda3\envs\bw2\lib\site-packages\premise\transformation.py:381, in BaseTransformation.fetch_proxies(self, name, ref_prod, production_variable, relink, regions) 362 def fetch_proxies( 363 self, name, ref_prod, production_variable=None, relink=True, regions=None 364 ) -> Dict[str, dict]: 365 """ 366 Fetch dataset proxies, given a dataset name and reference product. 367 Store a copy for each IAM region. (...) 378 :return: dictionary with IAM regions as keys, proxy datasets as values. 379 """ --> 381 d_iam_to_eco = self.region_to_proxy_dataset_mapping( 382 name=name, ref_prod=ref_prod, regions=regions 383 ) 385 d_act = {} 387 ds_name, ds_ref_prod = [None, None]

File ~\Miniconda3\envs\bw2\lib\site-packages\premise\transformation.py:358, in BaseTransformation.region_to_proxy_dataset_mapping(self, name, ref_prod, regions) 356 fallback_loc = "GLO" 357 else: --> 358 fallback_loc = list(d_map.values())[0] 360 return {region: d_map.get(region, fallback_loc) for region in regions}

IndexError: list index out of range

marcosdbw commented 2 years ago

I solved this problem by applying the commands below

clear_cache() from premise_gwp import add_premise_gwp | add_premise_gwp()