Skip to content
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

Bugfix in grasslands_apr22 pasture realization. #614

Merged
merged 4 commits into from
Nov 27, 2023

Conversation

alexkoberle
Copy link
Contributor

@alexkoberle alexkoberle commented Nov 17, 2023

🐦 Description of this PR 🐦

  • Briefly explain the purpose of this pull request

🔧 Checklist for PR creator 🔧

  • Label pull request from the label list.

    • Low risk: Simple bugfixes (missing files, updated documentation, typos) or changes in start or output scripts
    • Medium risk: Uncritical changes in the model core (e.g. moderate modifications in non-default realizations)
    • High risk: Critical changes in model core or default settings (e.g. changing a model default or adjusting a core mechanic in the model)
  • Self-review own code

    • No hard coded numbers and cluster/country/region names.
    • The new code doesn't contain declared but unused parameters or variables.
    • magpie4 R library has been updated accordingly and backwards compatible where necessary.
    • scenario_config.csv has been updated accordingly (important if default.cfg has been updated)
  • Document changes

    • Add changes to CHANGELOG.md
    • Where relevant, put In-code documentation comments
    • Properly address updates in interfaces in the module documentations
    • run goxygen::goxygen() and verify the modified code is properly documented
  • Perform test runs

    • Low risk:
      • Run a compilation check via Rscript start.R --> "compilation check"
    • Medium risk:
      • Run test runs via Rscript start.R --> "test runs"
      • Check logs for errors/warnings
    • High risk:
      • Run test runs via Rscript start.R --> "test runs"
      • Check logs for errors/warnings
      • Default run from the PR target branch for comparison
      • Provide relevant comparison plots (land-use, emissions, food prices, land-use intensity,...)

📉 Performance changes 📈

  • Current develop branch default : ** mins
  • This PR's default : ** mins

🚨 Checklist for reviewer 🚨

  • PR is labeled correctly
  • Code changes look reasonable
    • No hard coded numbers and cluster/country/region names.
    • No unnecessary increase in module interfaces
    • model behavior/performance is satisfactory.
  • Changes are properly documented
    • CHANGELOG is updated correctly
    • Updates in interfaces have been properly addressed in the module documentations
    • In-code documentation looks appropriate
  • content review done (at least 1)
  • RSE review done (at least 1)

Alexandre Koberle added 2 commits November 17, 2023 16:05
…pecific input files, required minor change in default.cfg.
Copy link
Member

@tscheypidi tscheypidi left a comment

Choose a reason for hiding this comment

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

looks good overall. Just some requests for modifications.

In addition to the ones mentioned it is also important to update the default.cfg to a newer data revision as soon as the new, compatible input data is available! Till then this PR should not be merged.

CHANGELOG.md Outdated
@@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **14_yields_and_config** The new default is to not use yield calibration factors from a calibration run. The switch s14_use_yield_calib can optionally reenable the use of yield calibration factors.
- **scripts** LUH2_disaggregation output script was modified. Specifically, flooded area was made compatible with the LUH definition, cropland and grazing land were added to the states.nc file, and specific naming/details (datatype, zname, xname, and yname) were added when creating the .nc files.
- **scripts** For the emulator scripts select a different bioenergy demand variable that excludes bioenergy sources other than second generation bioenergy crops. Set the minimal bioenergy demand to zero. Both avoid artificial clustering of data points and allow for better fits.
- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario.
Copy link
Member

Choose a reason for hiding this comment

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

removal of switches fits better into the "removed" category

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to "removed" section of CHANGELOG.md

i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j)
* set values to 1995 if nocc scenario is used, or to sm_fix_cc after sm_fix_cc if nocc_hist is used
$if "%c31_grassl_yld_scenario%" == "nocc" i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j);
$if "%c31_grassl_yld_scenario%" == "nocc_hist" i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = i31_manpast_suit(t_all,j)$(m_year(t_all) = sm_fix_cc);
Copy link
Member

Choose a reason for hiding this comment

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

why has this been moved here? input.gms should only contain switch declarations and read statements for input files, not calculations like this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed @k4rst3ns recommendation to do this, following same logic as for f31_grassl_yld a few lines down (L41-42), and as done for the the yield module: https://github.com/magpiemodel/magpie/blob/master/modules/14_yields/managementcalib_aug19/input.gms

Copy link
Member

Choose a reason for hiding this comment

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

ok, in that case lets keep it here

@alexkoberle
Copy link
Contributor Author

New input data created: rev4.95 ready to be used. Input vector updated in default.cfg. No new calibration file was generated in RSE folder so it was not changed from rev4.94

Copy link
Member

@tscheypidi tscheypidi left a comment

Choose a reason for hiding this comment

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

Looks good

@k4rst3ns
Copy link
Member

New input data created: rev4.95 ready to be used. Input vector updated in default.cfg. No new calibration file was generated in RSE folder so it was not changed from rev4.94

If you change the input revision, you also have to record the changes in the preprocessing, leading to a new input data revision. Please have a look here: https://gitlab.pik-potsdam.de/landuse/preprocessing-magpie/-/blob/main/CHANGELOG.md?ref_type=heads

Copy link
Contributor

@pvjeetze pvjeetze left a comment

Choose a reason for hiding this comment

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

Looks good to me! (But consider comment by @k4rst3ns)

@alexkoberle
Copy link
Contributor Author

New input data created: rev4.95 ready to be used. Input vector updated in default.cfg. No new calibration file was generated in RSE folder so it was not changed from rev4.94

If you change the input revision, you also have to record the changes in the preprocessing, leading to a new input data revision. Please have a look here: https://gitlab.pik-potsdam.de/landuse/preprocessing-magpie/-/blob/main/CHANGELOG.md?ref_type=heads

Done. Just pushed to pre-processing repo.

@alexkoberle alexkoberle merged commit 96c23d4 into magpiemodel:develop Nov 27, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants