Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi authored and romainsacchi committed Jul 1, 2024
2 parents 2fd40e2 + 46c72fa commit a3a7968
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 13 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-pass_cars.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-trucks.xlsx
Binary file not shown.
6 changes: 4 additions & 2 deletions premise/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ def create_markets(self) -> None:
]

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

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

if create_world_region is True:
Expand Down
14 changes: 13 additions & 1 deletion 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
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 a3a7968

Please sign in to comment.