-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move compareScenarios core framework to piamPlotComparison #578
Conversation
NAMESPACE
Outdated
export(calc_CES_marginals) | ||
export(calc_regionSubset_sums) | ||
export(checkVsCalibData) | ||
export(colorScenConf) | ||
export(compareCalibrationTargets) | ||
export(compareScenConf) | ||
export(compareScenarios2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, I think we should keep remind2::compareScenarios2()
as long as remindmodel master
calls it. But maybe we should decide more generally if we strive for compatibility of the latest remindmodel release with the most recent remind2
version. Given my experience in ENGAGE, ELEVATE and NGFS, I would strongly opt for making sure that works, because most projects seems to start from the release and then add some changes to it that require adding stuff to remind2. The most convenient way to avoid divergence of project work and model development is to just push that to the remind2
master and work with that. But if compareScenarios2 is broken then, this workflow impossible – which I think creates more problems and unnecessary double-work compared to making sure we allow for backwards compatibility. Maybe we should discuss that more generally within the remind team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I am not a fan of coding for hypothetical causes. I have a hard time wrapping my head around a specific use case where you cannot simply merge the latest REMIND and remind2 into your project branches (unless you never want to merge your work back into the master branches).
On the other hand, I am very familiar with the technological debt created by writing and maintaining code for all eventualities. So I personally would recommend to merge this and offer help to any project that actually ends up struggling with this on a case by case basis.
As I want this to be merged, I am bringing back compareScenarios2
for now, but will raise this topic with RSE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not hypothetical. It is the usual workflow in every single project I'm involved in (NGFS, ELEVATE, COMMITTED) and I guess everywhere when you want to use a validated REMIND version. The current develop
is neither validated nor stable and I would not recommend to use it for project work. But yes, please discuss that within RSE and I think we should discuss that in the REMIND meeting.
it is hypothetical for me, because I don't know any specific use case yet.
What kind of changes would you add to your REMIND project branch that
Wouldn't it be in fact be better to add these changes to your remind2 project branch, as you cannot be sure that they work well with REMIND develop? |
Btw, in this specific case of compareScenarios, it would be much easier to fix the call of compareScenarios in the REMIND R script (https://github.com/remindmodel/remind/blob/develop/scripts/cs2/run_compareScenarios2.R) of your project branch if your run into compatibility issues than writing a reexport function to remind2. |
Also, wouldn't you risk running into inconsistencies anyways if you update remind2 to latest develop (assuming it adds new features that need the REMIND develop updates), but keep to the latest REMIND release version + your own changes? |
Ok, that is fine as well. But then we should announce that at the REMIND meeting and in mattermost, telling projects to cherry-pick those changes if they work with the newest remind2 version.
Of course, we merge these things back to remindmodel when we commit to remind2. But that does not imply we take over everything going on in REMIND develop to our project branches. Example: this commit. We add a new variable that requires this PR in remindmodel. But to avoid that all people using remind2 after our commit on runs that are some days old, we put them behind a conditional to avoid fails for other people.
Yes, maybe. Still, the existing tests in remind2 should make sure the latest master release is still supported (at least does not create errors). Overall, I'm not sure our workflow is ideal. It is the workflow I got used to because my first work here was to merge hundreds of changes made by Christoph and Jerome back to remind2 and remindmodel |
Turns out the most straightforward way is to bring back |
|
||
This tutorial explains how to visually compare the results of multiple runs of the IAM [REMIND](https://github.com/remindmodel/remind) using the framework [piamPlotComparison](https://github.com/pik-piam/piamPlotComparison). | ||
|
||
The common use case is creating plots after your REMIND runs have finished, using the [`remind/output.R`](https://github.com/remindmodel/remind/blob/develop/output.R) script: Execute `Rscript output.R` in the REMIND folder, select `Comparison across runs` and then `compareScenarios2`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we keep compareScenarios2
here or should we move to compareScenarios
as well in remindmodel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind renaming it in the future. The rationale behind keeping the name compareScenarios2 / cs2 for now is that it could be useful to differentiate between:
piamPlotComparison::compareScenarios
: a generic function independent of the reporting library (remind2, reporttransport, reportbrick, ...)compareScenarios2
a function to call the compareScenarios framework in the context of the remind2 reporting library comparing REMIND runs
|
||
The underlying framework used can be found in the R library [piamPlotComparison](https://github.com/pik-piam/piamPlotComparison). | ||
|
||
The sections of the resulting pdf file are rendered Rmarkdown-files (Rmd-files). Rmd-files may contain R-code (e.g., for creating plots, creating tables) as well as descriptive text (in this case, mostly section titles). The Rmd-files to be rendered are part of the `remind2`-package. In the development state of the package, the main Rmd-files can be found in the folder [`remind2/inst/compareScenarios/`](https://github.com/pik-piam/remind2/tree/master/inst/compareScenarios). Some optional section may be placed in the REMIND repository at [`remind/scripts/cs2/`](https://github.com/remindmodel/remind/tree/develop/scripts/cs2). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here with cs2
|
||
7. Open the section-Rmd-file in which you want to add the plot. The files are in the folder `inst/compareScenarios/` and have names of the form `cs_NN_XXXX.Rmd`, where `NN` is a two digit number and `XXXX` resembles the section title. | ||
8. You should be able to execute any chunk in the section Rmd by clicking the play button in its top right corner. | ||
9. Insert a new chunk by copying an old one or by pressing `CTRL+ALT+I`. Note: It is better to not assign names to the chunks as cs2 will crash if you used the same name twice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But most chunks have names, see https://github.com/pik-piam/remind2/blob/master/inst/markdown/compareScenarios2/cs2_02_macro.Rmd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, this text was written for the vignette by Christof when creating compareScenarios2 and I migrated all the parts that are not outdated to the new vignette. In practice, they did not stick to this convention. I think, it is meant as a warning for users when introducing new chunks so they are aware that this might be a source of compilation errors. We could rephrase it to make that clearer, but I think we want to keep the existing chunk names.
This PR moves the generic logic to create a compareScenarios pdf to the library piamPlotComparison.
The following files are no longer needed:
R/compareScenarios2.R
(moved to piamPlotComparison)inst/markdown/compareScenarios2/cs2_main.Rmd
(moved to piamPlotComparison, remind2 specific preprocesing code was moved toinst/compareScenarios/preprocessing.R
)inst/markdown/compareScenarios2/cs2_latex_template.tex
andinst/markdown/compareScenarios2/cs_pdf_header_include.tex
(moved to piamPlotComparison)The section markdowns used to generate the current pdf are remind2 specific and remain in this repo. To work with the new framework, they were moved to the folder
/inst/compareScenarios/
and renamed tocs_NN_TEXT.Rmd
(e.g.inst/markdown/compareScenarios2/cs2_01_summary.Rmd
->inst/compareScenarios/cs_01_summary.Rmd
).General-purpose files moved to piamPlotComparison
R/calcTimeSeriesStats.R
R/showStatsTable.R
R/getCs2Profiles.R
Related PR in REMIND: remindmodel/remind#1661