Skip to content

Commit

Permalink
Align wrt master
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi authored and romainsacchi committed Jul 9, 2024
1 parent 60b3ff8 commit b5f2c30
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion premise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"clear_inventory_cache",
"get_regions_definition",
)
__version__ = (2, 1, 1, "dev2")
__version__ = (2, 1, 1, "dev4")


from premise.new_database import NewDatabase
Expand Down
Binary file modified premise/data/additional_inventories/lci-buses.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-carbon-capture.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-fuel_cell.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-hydrogen-electrolysis.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-pass_cars.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-trucks.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion premise/data/additional_inventories/migration_map.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1275,4 +1275,4 @@ from,to,name_from,ref_prod_from,location_from,name_to,ref_prod_to,location_to
37,310,"treatment of waste polyvinylfluoride, municipal incineration","waste polyvinylfluoride","CH","treatment of waste polyvinylfluoride, municipal incineration FAE","waste polyvinylfluoride",CH
38,310,"treatment of waste polyvinylfluoride, municipal incineration","waste polyvinylfluoride","CH","treatment of waste polyvinylfluoride, municipal incineration FAE","waste polyvinylfluoride",CH
39,310,"treatment of waste polyvinylfluoride, municipal incineration","waste polyvinylfluoride","CH","treatment of waste polyvinylfluoride, municipal incineration FAE","waste polyvinylfluoride",CH
39,310,market for blast furnace slag,blast furnace slag,GLO,,,RoW
39,310,market for blast furnace slag,blast furnace slag,GLO,,,RoW
12 changes: 7 additions & 5 deletions premise/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,10 @@ def create_markets(self) -> None:
r for r in regions if r not in market_vars["except regions"]
]

# remove World region from regions
if "World" in regions and len(regions) > 1:
regions.remove("World")

# Loop through regions
for region in regions:
# Create market dictionary
Expand Down Expand Up @@ -1273,14 +1277,12 @@ def create_markets(self) -> None:
# if there's more than one region,
# we create a World region
create_world_region = True
if (
"World" in regions
or "World" in market_vars.get("except regions", [])
or len(regions) == 1
if len(regions) <= 1 or "World" in market_vars.get(
"except regions", []
):
create_world_region = False

if create_world_region:
if create_world_region is True:
world_market = self.fill_in_world_market(
market=market_vars,
regions=regions,
Expand Down
16 changes: 14 additions & 2 deletions premise/external_data_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,19 @@ def flag_activities_to_adjust(
:return: dataset with additional info on variables to adjust
"""

regions = scenario_data["production volume"].region.values.tolist()
if "production volume variable" not in dataset_vars:
regions = scenario_data["production volume"].region.values.tolist()
else:
data = scenario_data["production volume"].sel(
variables=dataset_vars["production volume variable"]
)
# fetch regions which do not contain nan data
regions = [
r
for r in data.region.values.tolist()
if not np.isnan(data.sel(region=r).values).all()
]

if "except regions" in dataset_vars:
regions = [r for r in regions if r not in dataset_vars["except regions"]]

Expand Down Expand Up @@ -279,7 +291,7 @@ def check_inventories(
"except regions": val.get(
"except regions",
[
"World",
# "World",
],
),
"efficiency": val.get("efficiency", []),
Expand Down
8 changes: 4 additions & 4 deletions premise/fuels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2248,11 +2248,12 @@ def generate_regional_fuel_market(
string = ""

# if the sum is zero, we need to select a provider
if (
if np.isclose(
self.iam_fuel_markets.sel(region=region, variables=prod_vars)
.interp(year=self.year)
.sum(dim=["variables"])
== 0
.sum(dim=["variables"]),
0,
atol=1e-3,
):
if "hydrogen" in dataset["name"].lower():
prod_vars = [
Expand All @@ -2266,7 +2267,6 @@ def generate_regional_fuel_market(
prod_var, tuple(vars_map[fuel_category]), region, period
)
sum_share += share

else:
share = 1.0
sum_share = 1.0
Expand Down
10 changes: 8 additions & 2 deletions premise/iam_variables_mapping/fuels_variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ hydrogen, from natural gas:
remind: Tech|Hydrogen|Gas|w/o CC|Efficiency
ecoinvent_aliases:
fltr: hydrogen production, steam methane reforming
mask:
name:
- biomethane
- CCS

hydrogen, from natural gas, with CCS:
lhv: 120
Expand All @@ -647,8 +651,10 @@ hydrogen, from biogas:
co2: 0
biogenic_share: 1
ecoinvent_aliases:
fltr:
- hydrogen production, steam methane reforming, from biomethane
fltr: hydrogen production, steam methane reforming, from biomethane
mask:
name:
- CCS

hydrogen, from biogas, with CCS:
lhv: 120
Expand Down
4 changes: 1 addition & 3 deletions premise/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,7 @@ def select_multiple_suppliers(
suppliers = list(
ws.get_many(
subset or self.database,
ws.either(
*[ws.contains("name", sup) for sup in possible_names]
),
ws.either(*[ws.equals("name", sup) for sup in possible_names]),
(
ws.either(
*[
Expand Down

0 comments on commit b5f2c30

Please sign in to comment.