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

Update land conversion cost calibration for cropland - FAO as target data set #772

Merged
merged 18 commits into from
Feb 7, 2025

Conversation

flohump
Copy link
Contributor

@flohump flohump commented Feb 3, 2025

🐦 Description of this PR 🐦

  • scripts land conversion cost calibration for cropland - FAO as target data set instead of MAgPIEown
  • default.cfg settings for land conversion cost calibration updated

The file f39_calib.csv now includes meta information on the settings used for generating the calibration factors:
image

🔧 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,...)

Resources_Land_Cover_Cropland-133
Resources_Land_Cover_Cropland-134
Productivity_Landuse_Intensity_Indicator_Tau-110
Emissions_CO2_Land_Land_use_Change-121

📉 Performance changes 📈

  • Current develop branch default : 28.8 mins
  • This PR's default : 26.5 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)

@flohump flohump added Minor Smaller modifications High risk Higher risk and removed Medium risk labels Feb 3, 2025
@flohump flohump marked this pull request as ready for review February 3, 2025 19:56
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.

Thanks for these great improvements. Adding the calibration settings to the calib file is also really nice!

I only have some questions of understanding.

@@ -95,20 +95,24 @@ cfg$recalibrate_landconversion_cost <- "ifneeded" #def "ifneeded"
# Up to which accuracy shall be recalibrated?
cfg$calib_accuracy_landconversion_cost <- 0.01 # def = 0.01
# What is the maximum number of iterations if the precision goal is not reached?
cfg$calib_maxiter_landconversion_cost <- 40 # def = 40
cfg$calib_maxiter_landconversion_cost <- 20 # def = 20
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you briefly explain why the settings have changed here?

E.g. why is it safe to only have a maximum of 20 iterations instead of 40? Can we be sure that under most circumstances the calibration will have finished?

Same goes with other settings, for example the calib_max and calib_min settings.

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 revised the calculation of cropland reduction for the reward.
Previously, this was one factor for the whole period 1995-2015.
Now this is calcuated annually, which allows to choose the reward much more targeted than before.
Also, there are less jumps in the reward between the iterations. Therefore, I set the lowpass filter to zero.
I made tests with 20 and 40 iterations. The calib factors don't change much after 20 iterations. Also, the model results are very similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The range of calib_min and calib_max was 0.05-3 before.
To avoid very low or very high land conversion costs that avoid any land-use change I reduced the range to 0.2-2.5.
I also tested with 0.2-2. But in this case, we see an implausible strong increase of cropland in IND.

# Target data set that will be used for cropland calibration at regional level
# * "MAgPIEown": same data set as used for initialization of cropland
# * "FAO": Data from FAOSTAT on cropland area
cfg$cost_calib_hist_data <- "FAO" # def = "FAO"
Copy link
Contributor

Choose a reason for hiding this comment

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

Really nice that you added the switch here!

@flohump flohump merged commit cc314f0 into magpiemodel:develop Feb 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High risk Higher risk Minor Smaller modifications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants