Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pathways' into pathways
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Aug 6, 2024
2 parents 160888e + 88196e3 commit 7eafd3b
Show file tree
Hide file tree
Showing 28 changed files with 1,321 additions and 1,250 deletions.
803 changes: 139 additions & 664 deletions docs/extract.rst

Large diffs are not rendered by default.

1,263 changes: 757 additions & 506 deletions docs/transform.rst

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions premise/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def adjust_battery_mass(self) -> None:
[mean_2020_energy_density, mean_2050_energy_density],
),
0,
1,
None,
)

scaling_factor_min = minimum_2020_energy_density / np.clip(
Expand All @@ -247,7 +247,7 @@ def adjust_battery_mass(self) -> None:
[minimum_2020_energy_density, minimum_2050_energy_density],
),
0,
1,
None,
)

scaling_factor_max = maximum_2020_energy_density / np.clip(
Expand All @@ -257,7 +257,7 @@ def adjust_battery_mass(self) -> None:
[maximum_2020_energy_density, maximum_2050_energy_density],
),
0,
1,
None,
)

if "log parameters" not in ds:
Expand Down
41 changes: 41 additions & 0 deletions premise/clean_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,42 @@ def remove_categories(database: List[dict]) -> List[dict]:
return database


def strip_string_from_spaces(database: List[dict]) -> List[dict]:
"""
Strip strings from spaces in the dataset of the wurst inventory database.
Modifies in place (does not return anything).
:param database: wurst inventory database
:type database: list
"""
for dataset in database:
dataset["name"] = dataset["name"].strip()
# also check for unicode characters like \xa0
dataset["name"] = dataset["name"].replace("\xa0", "")

dataset["reference product"] = dataset["reference product"].strip()
dataset["location"] = dataset["location"].strip()
for exc in dataset["exchanges"]:
exc["name"] = exc["name"].strip()
# also check for unicode characters like \xa0
exc["name"] = exc["name"].replace("\xa0", "")
if exc.get("product"):
exc["product"] = exc["product"].strip()
# also check for unicode characters like \xa0
exc["product"] = exc["product"].replace("\xa0", "")
if exc.get("reference product"):
exc["reference product"] = exc["reference product"].strip()
# also check for unicode characters like \xa0
exc["reference product"] = exc["reference product"].replace("\xa0", "")
if exc.get("location"):
exc["location"] = exc["location"].strip()
if exc.get("unit"):
exc["unit"] = exc["unit"].strip()

return database


class DatabaseCleaner:
"""
Class that cleans the datasets contained in the inventory database for further processing.
Expand All @@ -163,6 +199,8 @@ def __init__(
)
self.database = wurst.extract_brightway2_databases(source_db)
self.database = remove_categories(self.database)
# strip strings form spaces
self.database = strip_string_from_spaces(self.database)

if source_type == "ecospold":
# The ecospold data needs to be formatted
Expand All @@ -171,6 +209,9 @@ def __init__(
)
ecoinvent.apply_strategies()
self.database = ecoinvent.data
# strip strings form spaces
self.database = strip_string_from_spaces(self.database)

# Location field is added to exchanges
self.add_location_field_to_exchanges()
# Product field is added to exchanges
Expand Down
Binary file modified premise/data/additional_inventories/lci-PV-GaAs.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-PV-perovskite.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-battery-capacity.xlsx
Binary file not shown.
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.
Binary file modified premise/data/additional_inventories/lci-two_wheelers.xlsx
Binary file not shown.
6 changes: 3 additions & 3 deletions premise/data/battery/energy_density.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Li-S:
# value for 2050 from https://www.nature.com/articles/s41560-020-00748-8/figures/1
2050:
mean: 0.340
minimum: 0.185
minimum: 0.270
maximum: 0.500

SiB:
Expand All @@ -221,8 +221,8 @@ SiB:
# future values from https://doi.org/10.3390/batteries9070379.
2050:
mean: 0.200
minimum: 0.160
maximum: 0.220
minimum: 0.150
maximum: 0.230

VRFB:
ecoinvent_aliases:
Expand Down
2 changes: 1 addition & 1 deletion premise/data/consequential/leadtimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Wind Onshore: 2
Wind Offshore: 3
Wave: 3
Storage, Hydrogen: 3
Storage, Flow Battery: 3
Storage, Battery: 3
diesel: 3
gasoline: 3
diesel, synthetic, from wood: 3
Expand Down
2 changes: 1 addition & 1 deletion premise/data/consequential/lifetimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ daccs_sorbent: 20
biomass - residual: 35
biomass crops - purpose grown: 35
Storage, Hydrogen: 20
Storage, Flow Battery: 20
Storage, Battery: 20
8 changes: 8 additions & 0 deletions premise/data/utils/logging/reporting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,14 @@ premise_battery:
name: SIB market share
description: Market share of SIB
unit: 0-1
VRFB market share:
name: VRFB market share
description: Market share of VRFB
unit: 0-1
LEAD-ACID market share:
name: LEAD-ACID market share
description: Market share of LEAD-ACID
unit: 0-1
tab: Battery

premise_wind_turbine:
Expand Down
2 changes: 1 addition & 1 deletion premise/electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ def create_region_specific_power_plants(self):
# "Oil CC",
"Coal CF 80-20",
"Coal CF 50-50",
"Storage, Flow Battery",
"Storage, Battery",
"Storage, Hydrogen",
]

Expand Down
2 changes: 1 addition & 1 deletion premise/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def import_heating_inventories(
version_out=self.version,
path=LCI_HEAT,
system_model=self.system_model,
keep_uncertainty_data=False,
keep_uncertainty_data=True,
)
datasets = inventory.merge_inventory()
self.database.extend(datasets)
Expand Down
21 changes: 13 additions & 8 deletions premise/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,9 +960,7 @@ def check_geographical_linking(scenario, original_database):
return scenario


def prepare_db_for_export(
scenario, name, original_database, keep_uncertainty_data=False, biosphere_name=None
):
def prepare_db_for_export(scenario, name, original_database, biosphere_name=None):
"""
Prepare a database for export.
"""
Expand All @@ -979,7 +977,6 @@ def prepare_db_for_export(
original_database=original_database,
database=scenario["database"],
db_name=name,
keep_uncertainty_data=keep_uncertainty_data,
biosphere_name=biosphere_name,
)
validator.run_all_checks()
Expand All @@ -991,15 +988,13 @@ def _prepare_database(
scenario,
db_name,
original_database,
keep_uncertainty_data,
biosphere_name,
):

scenario["database"] = prepare_db_for_export(
scenario,
name=db_name,
original_database=original_database,
keep_uncertainty_data=keep_uncertainty_data,
biosphere_name=biosphere_name,
)

Expand Down Expand Up @@ -1169,6 +1164,10 @@ def create_B_matrix_coordinates(self):
"Cannot find the biosphere flow",
exc["name"],
exc["categories"],
"in ",
ds["name"],
ds["reference product"],
ds["location"],
)
row = ()
list_rows.append(row)
Expand Down Expand Up @@ -1523,7 +1522,7 @@ def export_db_to_simapro(self, olca_compartments=False):
if item == "System description":
writer.writerow(["Ecoinvent v3"])
if item == "Infrastructure":
writer.writerow(["Yes"])
writer.writerow(["No"])
if item == "External documents":
writer.writerow(
[
Expand Down Expand Up @@ -1798,7 +1797,13 @@ def export_db_to_simapro(self, olca_compartments=False):
print(x)

if len(self.unmatched_category_flows) > 0:
print(f"{len(self.unmatched_category_flows)} unmatched flow categories.")
print(
f"{len(self.unmatched_category_flows)} unmatched flow categories. Check unlinked.log."
)
# save the list of unmatched flow to unlinked.log
with open("unlinked.log", "a") as f:
for item in self.unmatched_category_flows:
f.write(f"{item}\n")

print(f"Simapro CSV file saved in {self.filepath}.")

Expand Down
15 changes: 0 additions & 15 deletions premise/iam_variables_mapping/constants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ SUPPORTED_PATHWAYS:
- SSP5-PkBudg500
- static

LIST_TRANSF_FUNC:
- update_biomass
- update_electricity
- update_dac
- update_cement
- update_steel
- update_two_wheelers
- update_cars
- update_trucks
- update_buses
- update_fuels
- update_heat
- update_external_scenario
- update_emissions

LIST_MESSAGE_REGIONS:
- AFR
- CHN
Expand Down
4 changes: 2 additions & 2 deletions premise/iam_variables_mapping/electricity_variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,10 @@ Solar PV Residential:
gcam: Secondary Energy|Electricity|rooftop_pv
image: Secondary Energy|Electricity|Solar|PV|2
tiam-ucl: Secondary Energy|Electricity|Concentrated Solar PV decentralised
Storage, Flow Battery:
Storage, Battery:
ecoinvent_aliases:
fltr:
- electricity supply, high voltage, from vanadium-redox flow battery system
- electricity supply, from stationary battery (CONT scenario)
iam_aliases:
image: Secondary Energy|Electricity|Storage
message: Secondary Energy|Electricity|Storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# for which constructive_geometries
# cannot find an IAM equivalent
---
Europe without Austria:
Europe without Switzerland and Austria:
remind: EUR
image: WEU
message: WEU
tiam-ucl: WEU
gcam: EU-15
Europe without Switzerland and Austria:
Europe without Austria:
remind: EUR
image: WEU
message: WEU
Expand Down
Loading

0 comments on commit 7eafd3b

Please sign in to comment.