-
Notifications
You must be signed in to change notification settings - Fork 164
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
Automatic sets in 56_ghg_policy and 60_bioenergy and update of GHG emission policies #254
Conversation
scripts/start_functions.R
Outdated
content <- c(content,';') | ||
|
||
gms::replace_in_file("modules/56_ghg_policy/price_jan20/sets.gms",content,subject) | ||
|
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.
overall approach looks good to me, but code needs some streamlining:
you are re-using here code which is used to modify our core/sets.gms
file. Instead of duplicating that code by copying it I would like to ask you to ousource that part into a function and call that function where needed. Doing so will ensure that bugfixes in that part will be deployed automatically to all places where it is used and the code will become easier readable.
From what I can see the function would require three inputs: the file to be modied, the set name and description, and the set elements.
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.
Unfortunately, this is not possible because the sets cannot be written to sets.gms in sequence. All sets have to be written at once, otherwise only the last set written will be in the code. But I can move the .tmp function and the modification header into functions that are called from within .update_sets and .update_sets_bioen_ghgprice_scen. What do you suggest?
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 added .set_modification and .set_formatting. If you have further suggestions for streamlining, just let me know.
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.
Why not write a function then which writes all sets at once? (set entries could be provided as a list of entries and the function would simply 1) write the header 2) loop through the sets and write them 3) write the footer)
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.
(the set mappings in core/sets.gms should also fit in this scheme if you treat each set mapping (e.g. CAZ . (AUS,CAN,HMD,NZL,SPM)
) as single set element and put that paste-magic which is creating these mappings outside of that function)
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.
Done. I hope this is fine now.
Please fill following information
(Add additional info if you think its important and not covered by this Pull Request (PR)):
Purpose of this PR
Performance loss/gain from current default behavior
Type of change
How Has This Been Tested?
test_runs.R
).test_runs.R
but with the changes from PR.Additions or Changes to default configuration (default.cfg):
Additions are the introduction of new model components in default config
Changes are deletion or updates to the existing model components in default config
Checklist:
CHANGELOG.md
goxygen::goxygen()
for the new/updated parts.magpie4
R library for post processing of model output (ideally backward compatible).Special comments/warnings