Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.3.0.dev' into 2.3.0.dev
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Dec 22, 2024
2 parents b74c4ff + db87fee commit 2be4c90
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions premise/pathways.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,16 @@ def add_variables_mapping(self):
if "configurations" in scenario:
configurations = scenario["configurations"]
for key, val in configurations.items():
for variable, variable_details in val.get("production pathways", {}).items():
for variable, variable_details in val.get(
"production pathways", {}
).items():
if variable not in mapping:
variable_scenario_name = variable_details.get("production volume", {}).get("variable", 0)
mapping[variable] = {"scenario variable": variable_scenario_name}
variable_scenario_name = variable_details.get(
"production volume", {}
).get("variable", 0)
mapping[variable] = {
"scenario variable": variable_scenario_name
}
filters = variable_details.get("ecoinvent alias")
mask = variable_details.get("ecoinvent alias").get("mask")

Expand All @@ -256,14 +262,14 @@ def add_variables_mapping(self):
]

if len(mapping[variable]["dataset"]) == 0:
print(f"No dataset found for {variable} in {variable_scenario_name}")
print(
f"No dataset found for {variable} in {variable_scenario_name}"
)
print(f"Filters: {filters}")
print(f"Mask: {mask}")
continue

variables = list(
val["production pathways"].keys()
)
variables = list(val["production pathways"].keys())
variables.remove(variable)
# remove datasets which names are in list of variables
# except for the current variable
Expand Down Expand Up @@ -322,7 +328,7 @@ def add_scenario_data(self):
# split the columns "scenarios" into "model" and "pathway"
df[["model", "pathway"]] = df["scenario"].str.split(" - ", n=1, expand=True)
# remove any spaces in the "pathway" column
#df["pathway"] = df["pathway"].str.replace(" ", "")
# df["pathway"] = df["pathway"].str.replace(" ", "")
df = df.drop(columns=["scenario"])

self.scenario_names = df["pathway"].unique().tolist()
Expand Down

0 comments on commit 2be4c90

Please sign in to comment.