Skip to content

refactor: iamc export - #158

Merged
leonieschweiger merged 13 commits into
pik-piam:mainfrom
leonieschweiger:refactor_iamc_export
Jul 21, 2026
Merged

refactor: iamc export#158
leonieschweiger merged 13 commits into
pik-piam:mainfrom
leonieschweiger:refactor_iamc_export

Conversation

@leonieschweiger

@leonieschweiger leonieschweiger commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

This PR aims to streamline the iamc export of the different material models and to make adding new variables easier.
As much code as possible was moved to common_export.py, now only the mapping of flows to iamc variables is done in the material_export.py. The PR also addresses https://github.com/pik-piam/remind-mfa/issues/82
What do you think? I am happy to hear your feedback :)

TODO

  • create a common .mif with the iamc output from all material models
  • agree on a nomenclature - currently we are using variables from the PRISMA project, however they are quite limited and I have added new ones for plastics. Another option would be to use the CIRCOMOD nomenclature, they have more variables.

@leonieschweiger leonieschweiger changed the title Refactor iamc export refactor: iamc export Jul 17, 2026
@leonieschweiger

Copy link
Copy Markdown
Collaborator Author

I added a vibecoded script plot_iamc_vs_validation.py that plots the iamc outputs of REMIND-MFA against the newly created validation.mif (see pik-piam/mrmfa#65). If you prefer not to merge this, let me know.

@bennet21 bennet21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such great work Leonie. Thanks a lot! This will make documenting our model results (and their progression over time as the model improves) much easier! And it is one more important step towards aligning our materials and making material specifics easier to understand!
The comments I have are basically all optional and preference based. Some of them just reflect what would've helped me a bit to understand what's going on.

Comment thread remind_mfa/common/common_export.py Outdated
Comment thread remind_mfa/common/common_export.py Outdated
Comment thread remind_mfa/common/common_export.py Outdated
Comment thread remind_mfa/common/common_export.py Outdated
Comment thread remind_mfa/common/common_export.py Outdated
Comment thread remind_mfa/common/common_export.py Outdated
Comment thread remind_mfa/common/common_export.py Outdated
Comment thread remind_mfa/common/common_export.py
def model_name(self) -> str:
"""Model identifier for the IAMC "model" column, including the REMIND-MFA version."""
try:
return f"REMIND-MFA {version('remind-mfa')}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB:
In some cases, we may want this to actually say "REMIND X.X.X".
We could then pass an optional parameter with the version in the config or so.
Nothing to worry about now :-)

Comment thread remind_mfa/common/common_export.py Outdated
else:
df["variable"] = spec.variable
variables = list(dict.fromkeys(df["variable"]))
return pyam.IamDataFrame(df, unit=spec.unit, **constants), variables

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just notice that the export is called IAM and not IAMC df. Should we drop the "s" everywhere, too?

@JakobBD JakobBD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great stuff indeed!

As for which variables to include:

Sounds good to follow the Circomod template for new variables.
This might create inconsistencies with the current prisma variables. Maybe we add a source (i.e., which template we took each variable from) to at least keep track of that.

NB: The R package piamInterfaces is designed to convert REMIND mifs to project-specific templates. So if we create one comprehensive mif, we can add mappings to other variable nomenclatures over there.

Don't do all the work of adding variables yourself now.
Just add the ones you need, and maybe add instructions for future users how to add new variables (The circomod excel file isn't public, but we could upload it to gitlab or the cloud).

As for combining the three materials:

I wouldn't worry about that now.
It's just concatenating three files. Add a minimal script to the scripts folder, if you like.

NB: In the long run, we may want a script that also appends these to the REMIND mif. We may want to ask RSE about that.

Comment thread scripts/plot_iamc_vs_validation.py Outdated
@@ -0,0 +1,240 @@
"""Plot a material model's IAMC outputs against the curated validation data.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Go wild in the scripts folder. Maybe add a note/warning in this doc string that it's un-reviewed vibe-coding.

NB: cs2 does the same job, just with different kinds of plots and manual selection/layout for each variable.
Also added functionality, e.g. stacked bars showing multiple variables in one plot.
I would still keep this light-weight script, though.

def model_name(self) -> str:
"""Model identifier for the IAMC "model" column, including the REMIND-MFA version."""
try:
return f"REMIND-MFA {version('remind-mfa')}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB:
In some cases, we may want this to actually say "REMIND X.X.X".
We could then pass an optional parameter with the version in the config or so.
Nothing to worry about now :-)

Comment thread remind_mfa/common/common_export.py
Comment thread remind_mfa/common/common_export.py Outdated
@leonieschweiger

Copy link
Copy Markdown
Collaborator Author

That's great stuff indeed!

As for which variables to include:

Sounds good to follow the Circomod template for new variables. This might create inconsistencies with the current prisma variables. Maybe we add a source (i.e., which template we took each variable from) to at least keep track of that.

NB: The R package piamInterfaces is designed to convert REMIND mifs to project-specific templates. So if we create one comprehensive mif, we can add mappings to other variable nomenclatures over there.

Don't do all the work of adding variables yourself now. Just add the ones you need, and maybe add instructions for future users how to add new variables (The circomod excel file isn't public, but we could upload it to gitlab or the cloud).

As for combining the three materials:

I wouldn't worry about that now. It's just concatenating three files. Add a minimal script to the scripts folder, if you like.

NB: In the long run, we may want a script that also appends these to the REMIND mif. We may want to ask RSE about that.

I added both the circomod and prisma templates to our Cloud folder under data/iamc_nomenclature. Should I add instructions for future users how to add new variables to the remind-mfa docs or just add a note to the docstring?

@JakobBD

JakobBD commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Should I add instructions for future users how to add new variables to the remind-mfa docs or just add a note to the docstring?

The latter!

@leonieschweiger
leonieschweiger merged commit f575550 into pik-piam:main Jul 21, 2026
1 check passed
tobiasdiez pushed a commit that referenced this pull request Jul 21, 2026
This PR aims to streamline the iamc export of the different material
models and to make adding new variables easier.
As much code as possible was moved to common_export.py, now only the
mapping of flows to iamc variables is done in the material_export.py.
The PR also addresses https://github.com/pik-piam/remind-mfa/issues/82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants