Skip to content

Commit

Permalink
Allow directional timeseries data (region-to-region) (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann authored Mar 1, 2024
1 parent 4332f93 commit 4e4de1a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@
def main(df: pyam.IamDataFrame) -> pyam.IamDataFrame:
"""Project/instance-specific workflow for scenario processing"""

# Run the validation and region-processing
# initialize the codelists and region-processing
dsd = DataStructureDefinition(
here / "definitions", dimensions=["scenario", "region", "variable"]
)
processor = RegionProcessor.from_directory(path=here / "mappings", dsd=dsd)

# check if directional data exists in the scenario data, add to region codelist
if any([r for r in df.region if ">" in r]):
for r in df.region:
if r in definition.region:
continue
r_split = r.split(">")
if len(r_split) > 2:
raise ValueError(
f"Directional data other than `origin>destination` not allowed: {r}"
)
elif len(r_split) == 2:
if all([_r in definition.region for _r in r_split]):
# add the directional-region to the codelist (without attributes)
definition.region[r] = None

# run the validation and region-processing
df = process(df, dsd, processor=processor)

# assign meta indicator for scenario "work package" category
Expand Down

0 comments on commit 4e4de1a

Please sign in to comment.