From debc2bdc74c6d56deee8801509ebba7598ee2235 Mon Sep 17 00:00:00 2001 From: davidho Date: Thu, 9 Nov 2023 15:31:13 +0100 Subject: [PATCH 1/8] added switch to turn off yield calib --- config/default.cfg | 9 +++++++++ modules/14_yields/managementcalib_aug19/input.gms | 2 ++ modules/14_yields/managementcalib_aug19/preloop.gms | 11 ++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index ecb455b574..ecb5b0f0c1 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -56,6 +56,9 @@ cfg$force_download <- FALSE cfg$force_replace <- FALSE # Settings for the yield calibration +# For this preprocessing yield calibration to function +# the switch s14_use_yield_calib needs to be turned on. (Default is off) +# 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 @@ -316,6 +319,12 @@ 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 from the preprocessing in the model 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.) +cfg$gms$s14_use_yield_calib <- 0 # def = 0 + # ***--------------------- 15_food --------------------------------------- # * (anthropometrics_jan18): estimates food using scenario dependent regression # * and demography drivers diff --git a/modules/14_yields/managementcalib_aug19/input.gms b/modules/14_yields/managementcalib_aug19/input.gms index 62e1a60cb6..ffab5eb9ee 100644 --- a/modules/14_yields/managementcalib_aug19/input.gms +++ b/modules/14_yields/managementcalib_aug19/input.gms @@ -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 / diff --git a/modules/14_yields/managementcalib_aug19/preloop.gms b/modules/14_yields/managementcalib_aug19/preloop.gms index b7649dfa3c..9785cbea2a 100644 --- a/modules/14_yields/managementcalib_aug19/preloop.gms +++ b/modules/14_yields/managementcalib_aug19/preloop.gms @@ -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; ); From 27d3f4a954914408437bb99ac402c24625b771f1 Mon Sep 17 00:00:00 2001 From: DavidhoPIK <101278418+DavidhoPIK@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:53:15 +0100 Subject: [PATCH 2/8] Update default.cfg --- config/default.cfg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index ecb5b0f0c1..36076e1363 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -56,8 +56,10 @@ cfg$force_download <- FALSE cfg$force_replace <- FALSE # Settings for the yield calibration -# For this preprocessing yield calibration to function -# the switch s14_use_yield_calib needs to be turned on. (Default is off) +# For this preprocessing yield calibration triggered by the recalibrate switch +# to function 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 From ed2cb51c420bb1c11db003dbd660c965e39d747e Mon Sep 17 00:00:00 2001 From: DavidhoPIK <101278418+DavidhoPIK@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:54:03 +0100 Subject: [PATCH 3/8] Update default.cfg --- config/default.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/default.cfg b/config/default.cfg index 36076e1363..1f56b7f20f 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -325,6 +325,8 @@ cfg$gms$s14_degradation <- 0 # def = 0 # 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 --------------------------------------- From 1094ec0d8cdc47874d053b4f36303960448a4f46 Mon Sep 17 00:00:00 2001 From: davidho Date: Thu, 9 Nov 2023 16:12:24 +0100 Subject: [PATCH 4/8] changed comments and fsec scenario --- CHANGELOG.md | 1 + config/scenario_fsec.csv | 1 + scripts/start/extra/recalibrate_FSEC.R | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c68602a951..e3b753dd5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 the preprocessing. 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. diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 3728e722ad..4768afbbce 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -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;;;;;;;;;;;;;;; diff --git a/scripts/start/extra/recalibrate_FSEC.R b/scripts/start/extra/recalibrate_FSEC.R index 5833ccaf5b..22c894b2d1 100644 --- a/scripts/start/extra/recalibrate_FSEC.R +++ b/scripts/start/extra/recalibrate_FSEC.R @@ -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 From 5b8d758deffc9366611bbc554395199caca3412c Mon Sep 17 00:00:00 2001 From: davidho Date: Thu, 9 Nov 2023 16:16:31 +0100 Subject: [PATCH 5/8] changed default of yield recalibration --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 1f56b7f20f..6a9fea54c8 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -65,7 +65,7 @@ cfg$force_replace <- FALSE # * (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? From 025f7941c0a3e6424fb46ea03375e26d7ce665a9 Mon Sep 17 00:00:00 2001 From: DavidhoPIK <101278418+DavidhoPIK@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:46:11 +0100 Subject: [PATCH 6/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3b753dd5d..35f2a5a968 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +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 the preprocessing. The switch s14_use_yield_calib can optionally reenable the use of yield calibration factors. +- **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. From 955af0c052fd4458a49650ea5a3a02a1e1b3cb84 Mon Sep 17 00:00:00 2001 From: DavidhoPIK <101278418+DavidhoPIK@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:51:27 +0100 Subject: [PATCH 7/8] Update default.cfg --- config/default.cfg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 6a9fea54c8..63038e34b4 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -56,8 +56,9 @@ cfg$force_download <- FALSE cfg$force_replace <- FALSE # Settings for the yield calibration -# For this preprocessing yield calibration triggered by the recalibrate switch -# to function the switch s14_use_yield_calib needs to be turned on. (Default is off) +# For this yield calibration (that uses results from a special MAgPIE calibration run +# triggered by the recalibrate switch) to function 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. @@ -321,7 +322,7 @@ 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 from the preprocessing in the model run. +# 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.) From 1db56be5b363c8860d072497b575cb73a560ec0e Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Fri, 10 Nov 2023 10:10:19 +0100 Subject: [PATCH 8/8] Update default.cfg --- config/default.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 63038e34b4..f0cc0aa48a 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -57,10 +57,11 @@ 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 function the switch s14_use_yield_calib needs +# 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