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 committed Oct 15, 2023
2 parents 9703072 + 94f0c8b commit 103c28a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 13 deletions.
67 changes: 55 additions & 12 deletions premise/ecoinvent_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,11 @@ def update_electricity(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_electricity(
Expand Down Expand Up @@ -906,7 +910,11 @@ def update_dac(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_dac(
Expand Down Expand Up @@ -941,7 +949,11 @@ def update_fuels(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_fuels(
Expand Down Expand Up @@ -976,7 +988,11 @@ def update_cement(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_cement(
Expand Down Expand Up @@ -1011,7 +1027,11 @@ def update_steel(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_steel(
Expand Down Expand Up @@ -1047,7 +1067,11 @@ def update_cars(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_vehicles(
Expand Down Expand Up @@ -1084,7 +1108,11 @@ def update_two_wheelers(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_vehicles(
Expand Down Expand Up @@ -1123,7 +1151,11 @@ def update_trucks(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_vehicles(
Expand Down Expand Up @@ -1161,7 +1193,11 @@ def update_buses(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets, _ = _update_vehicles(
Expand Down Expand Up @@ -1245,7 +1281,11 @@ def update_emissions(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets = _update_emissions(
Expand Down Expand Up @@ -1289,7 +1329,11 @@ def update_all(self) -> None:

for s, scenario in enumerate(self.scenarios):
self.scenarios[s] = results[s][0]
self.modified_datasets[(scenario["model"], scenario["pathway"], scenario["year"])] = results[s][1][(scenario["model"], scenario["pathway"], scenario["year"])]
self.modified_datasets[
(scenario["model"], scenario["pathway"], scenario["year"])
] = results[s][1][
(scenario["model"], scenario["pathway"], scenario["year"])
]
else:
for scenario in self.scenarios:
scenario, self.modified_datasets = _update_all(
Expand Down Expand Up @@ -1401,7 +1445,6 @@ def write_db_to_brightway(self, name: [str, List[str]] = None):

cache = {}


for scenario in self.scenarios:
scenario, cache = _prepare_database(
scenario=scenario,
Expand Down
4 changes: 3 additions & 1 deletion premise/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,9 @@ def build_datapackage(df, inventories, list_scenarios, ei_version, name):

# check that directory exists, otherwise create it
Path(DIR_DATAPACKAGE_TEMP).mkdir(parents=True, exist_ok=True)
df.to_csv(DIR_DATAPACKAGE_TEMP / "scenario_data.csv", index=False, encoding="utf-8-sig")
df.to_csv(
DIR_DATAPACKAGE_TEMP / "scenario_data.csv", index=False, encoding="utf-8-sig"
)
write_formatted_data(
name=name, data=inventories, filepath=DIR_DATAPACKAGE_TEMP / "inventories.csv"
)
Expand Down

0 comments on commit 103c28a

Please sign in to comment.