Skip to content

Commit

Permalink
Align wrt pathways
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi authored and romainsacchi committed Aug 12, 2024
1 parent 2fadd36 commit 8272971
Show file tree
Hide file tree
Showing 11 changed files with 743 additions and 313 deletions.
739 changes: 522 additions & 217 deletions dev/Untitled1.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/transform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ These datasets provide 1 kWh of battery capacity, and the technology
shares are adjusted over time with values found
under https://github.com/polca/premise/blob/master/premise/data/battery/scenario.csv.
.. _Degen: https://doi.org/10.1016/j.joule.2023.01.001
.. _Degen: https://www.nature.com/articles/s41560-023-01355-z
Stationary batteries
Expand Down
9 changes: 4 additions & 5 deletions premise/clean_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ def remove_uncertainty(database):

for dataset in database:
for exchange in dataset["exchanges"]:
if not exchange.get("preserve uncertainty", False):
exchange["uncertainty type"] = 0
exchange["loc"] = exchange["amount"]
for key in uncertainty_keys:
exchange[key] = nan_value
exchange["uncertainty type"] = 0
exchange["loc"] = exchange["amount"]
for key in uncertainty_keys:
exchange[key] = nan_value

return database

Expand Down
Binary file modified premise/data/additional_inventories/lci-battery-capacity.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-hydrogen-turbine.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion premise/data/fuels/hydrogen_efficiency_parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from electrolysis:
var: hydrogen, from electrolysis
feedstock name: electricity, low voltage
feedstock unit: kilowatt hour
floor value: 48.0
floor value: 48.9
from SMR of biogas, with CCS:
name: hydrogen production, steam methane reforming, from biomethane, with CCS
var: hydrogen, from biogas, with CCS
Expand Down
33 changes: 33 additions & 0 deletions premise/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging
import math
import uuid
from collections import defaultdict
from functools import lru_cache
Expand Down Expand Up @@ -1461,6 +1462,21 @@ def relink_to_new_datasets(
if isinstance(new_loc, str):
new_loc = [(new_loc, 1.0)]

def redefine_loc(e):
if e.get("uncertainty type") in [0, 3, 4]:
return e["amount"] * ratio * share

elif e.get("uncertainty type") == 5:
return e.get("loc", 0) * (
e["amount"] * ratio * share / e["amount"]
)

elif e.get("uncertainty type") == 2:
return math.log(e["amount"] * ratio * share)

else:
return None

if len(new_loc) > 0:
for loc, share in new_loc:
# add new exchange
Expand All @@ -1472,6 +1488,23 @@ def relink_to_new_datasets(
"location": loc,
"name": new_name,
"product": new_ref,
"uncertainty type": exc.get("uncertainty type", 0),
"loc": redefine_loc(exc),
"scale": (
exc.get("scale", 0) if "scale" in exc else None
),
"minimum": (
exc.get("minimum", 0)
* (exc["amount"] * ratio * share / exc["amount"])
if "minimum" in exc
else None
),
"maximum": (
exc.get("maximum", 0)
* (exc["amount"] * ratio * share / exc["amount"])
if "maximum" in exc
else None
),
}
)

Expand Down
12 changes: 12 additions & 0 deletions premise/inventory_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@ def check_uncertainty_data(data, filename):
]
)

if exc["uncertainty type"] == 2:
if exc["amount"] < 0:
if exc.get("negative") is not True:
rows.append(
[
dataset["name"][:30],
exc["name"][:30],
exc["uncertainty type"],
"'negative' should be TRUE",
]
)

# if distribution is triangular, make sure that `minimum`
# and `maximum` are not equal and are comprising the `loc`
if exc["uncertainty type"] == 5:
Expand Down
Loading

0 comments on commit 8272971

Please sign in to comment.