Skip to content

Commit

Permalink
Fix issue with GLO hydrogen market.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Aug 7, 2023
1 parent 6c69c13 commit d6815ce
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion premise/cement.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
logger = create_logger("cement")


def _update_cement(scenario, version, system_model, modified_datasets, cache):
def _update_cement(scenario, version, system_model, modified_datasets, cache=None):
cement = Cement(
database=scenario["database"],
model=scenario["model"],
Expand Down
Binary file modified premise/data/additional_inventories/lci-hydrogen-electrolysis.xlsx
Binary file not shown.
24 changes: 18 additions & 6 deletions premise/fuels.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def update_dataset(dataset, supplier_key, amount):
return dataset


def _update_fuels(scenario, version, system_model, modified_datasets, cache):
def _update_fuels(scenario, version, system_model, modified_datasets, cache=None):
fuels = Fuels(
database=scenario["database"],
iam_data=scenario["iam data"],
Expand Down Expand Up @@ -1936,7 +1936,7 @@ def fetch_fuel_share(
)

if np.isnan(fuel_share):
print(f"Incorrect fuel share for {fuel} in {region}")
print(f"Incorrect fuel share for {fuel} in {region}.")
fuel_share = 0

return float(fuel_share)
Expand Down Expand Up @@ -2074,7 +2074,7 @@ def generate_world_fuel_market(

# Calculate share of production volume for each region
for r in d_act.keys():
if r == "World":
if r == "World" or (dataset["name"], r) not in self.new_fuel_markets:
continue

share = (
Expand Down Expand Up @@ -2192,10 +2192,21 @@ def generate_regional_fuel_market(

string = ""

# if the sum is zero, we need to select a provider

if self.iam_fuel_markets.sel(region=region, variables=prod_vars, year=self.year).sum(dim=["variables"]) == 0:
print("No fuel market for", dataset["name"], "in", region)

if "hydrogen" in dataset["name"].lower():
prod_vars = ["hydrogen, nat. gas", ]

for prod_var in prod_vars:
share = fuel_providers[prod_var]["find_share"](
prod_var, tuple(vars_map[fuel_category]), region, period
)
if len(prod_vars) > 1:
share = fuel_providers[prod_var]["find_share"](
prod_var, tuple(vars_map[fuel_category]), region, period
)
else:
share = 1.0

if np.isnan(share) or share <= 0:
continue
Expand Down Expand Up @@ -2498,6 +2509,7 @@ def generate_fuel_markets(self):

new_datasets.append(dataset)


# add to database
self.database.extend(new_datasets)

Expand Down
2 changes: 1 addition & 1 deletion premise/steel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
logger = create_logger("steel")


def _update_steel(scenario, version, system_model, modified_datasets, cache):
def _update_steel(scenario, version, system_model, modified_datasets, cache=None):
steel = Steel(
database=scenario["database"],
model=scenario["model"],
Expand Down

0 comments on commit d6815ce

Please sign in to comment.