Skip to content

Commit

Permalink
Merge pull request #609 from DavidhoPIK/addYieldCalibrationSwitch
Browse files Browse the repository at this point in the history
added a switch to turn off the use of yield calibration factors from calibration runs
  • Loading branch information
DavidhoPIK authored Nov 10, 2023
2 parents 64172d1 + 1db56be commit c592d61
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### changed
- **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.
- **inputdata** There was another bug (terra default na.rm changed) in the inputdata that was fixed with rev4.93
- **inputdata** There was a major bug (related to proj/terra) in the rev4.91 inputdata that was fixed with rev4.92
- **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.
Expand Down
17 changes: 16 additions & 1 deletion config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,18 @@ cfg$force_download <- FALSE
cfg$force_replace <- FALSE

# Settings for the yield calibration
# For this yield calibration (that uses results from a special MAgPIE calibration run
# triggered by the recalibrate switch) to be activated the switch s14_use_yield_calib needs
# to be turned on. (Default is off)
# This switch should only be activated for penalty_apr22 crop realization.
# For other realizations, it is recommended not to use this yield calibration.
#
# Switch to turn on/off recalibration of yields.
# * (TRUE): Yield calibration will be performed
# * (ifneeded): Yield calibration will only be executed if input data is
# * downloaded from repository
# * (FALSE): Yield calibration will not be performed
cfg$recalibrate <- "ifneeded" # def = "ifneeded"
cfg$recalibrate <- FALSE # def = FALSE
# Up to which accuracy shall be recalibrated?
cfg$calib_accuracy <- 0.05 # def = 0.05
# What is the maximum number of iterations if the precision goal is not reached?
Expand Down Expand Up @@ -316,6 +323,14 @@ cfg$gms$s14_calib_ir2rf <- 1 # def = 1
# * 0 (land degradation is switched off)
cfg$gms$s14_degradation <- 0 # def = 0

# Switch to toggle the use of yield calibration factors (that resulted from a calibration run).
# If 0, no yield calibration factors are used, meaning all calibration factors are set to 1.
# If 1, yield calibration factors are used. (For this option to function, either an existing calibration file
# must be supplied in the input directory, or yields must be recalibrated during preprocessing.)
# This switch should only be activated for penalty_apr22 crop realization.
# For other realizations, it is recommended not to use this yield calibration.
cfg$gms$s14_use_yield_calib <- 0 # def = 0

# ***--------------------- 15_food ---------------------------------------
# * (anthropometrics_jan18): estimates food using scenario dependent regression
# * and demography drivers
Expand Down
1 change: 1 addition & 0 deletions config/scenario_fsec.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ gms$c09_pal_scenario;;;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gms$s12_interest_lic;;;0.06;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gms$s12_interest_hic;;;0.04;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gms$food;anthro_iso_jun22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gms$s14_use_yield_calib;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gms$s15_exo_waste;;;;;;;;0;0;0;0;0;0;0;0;1;;;;;;;;;;;;;;;;;0;1;;;;;;;;;;;;;;;
gms$s15_exo_diet;;;;;;;;1;1;1;1;1;1;1;1;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;;
gms$c15_kcal_scen;;;;;;;;no_underweight;half_overweight;endo;endo;endo;endo;endo;endo;endo;;;;;;;;;;;;;;;;;no_underweight_half_overweight;no_underweight_half_overweight;;;;;;;;;;;;;;;
Expand Down
2 changes: 2 additions & 0 deletions modules/14_yields/managementcalib_aug19/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ scalar s14_calib_ir2rf Switch to calibrate rainfed to irrigated yield ratios (

scalar s14_degradation Switch to include yield impacts of land degradation(0=no degradation 1=with degradation) / 0 /;

scalar s14_use_yield_calib Switch for using or not using yield calibration factors from the preprocessing (1=use facs 0=not use facs) / 0 /;

scalars
s14_yld_past_switch Spillover parameter for translating technological change in the crop sector into pasture yield increases (1) / 0.25 /
s14_yld_reduction_soil_loss Decline of land productivity in areas with severe soil loss (1) / 0.08 /
Expand Down
11 changes: 6 additions & 5 deletions modules/14_yields/managementcalib_aug19/preloop.gms
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,14 @@ if ((s14_calib_ir2rf = 1),
***YIELD CALIBRATION***********************************************************************

*' @code
*' Calibrated yields are additionally adjusted by calibration factors 'f14_yld_calib'
*' Calibrated yields can additionally be adjusted by calibration factors 'f14_yld_calib'
*' determined in a calibration run. As MAgPIE optimizes yield patterns and FAO regional
*' yields are outlier corrected, historical production and croparea can only be reproduced
*' with this additional step of correction:
*' yields are outlier corrected, historical production and croparea can in some cases
*' be better represented with this additional correction:

* set default values in case of missing input file
if(sum((i,ltype14),f14_yld_calib(i,ltype14)) = 0,
* set yield calib factors to 1 in case of no use of yield calibration factors (s14_use_yield_calib = 0)
* or missing input file
if(s14_use_yield_calib = 0 OR sum((i,ltype14),f14_yld_calib(i,ltype14)) = 0,
f14_yld_calib(i,ltype14) = 1;
);

Expand Down
2 changes: 1 addition & 1 deletion scripts/start/extra/recalibrate_FSEC.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ source("scripts/projects/fsec.R")
cfg <- fsecScenario(scenario = "c_BAU")
cfg$title <- "FSEC24Mar23"
cfg$results_folder <- "output/:title:"
cfg$recalibrate <- TRUE
cfg$recalibrate <- TRUE # required when penality_apr22 activated
cfg$best_calib <- TRUE
cfg$recalibrate_landconversion_cost <- TRUE
cfg$best_calib_landconversion_cost <- FALSE
Expand Down

0 comments on commit c592d61

Please sign in to comment.