From 7ee4d9b764dae82561e84d27bd9a2a26c63f85e1 Mon Sep 17 00:00:00 2001 From: davidho Date: Thu, 7 Dec 2023 14:34:09 +0100 Subject: [PATCH 1/4] added consistency check for yield calibration run without use of calibration factors --- scripts/start_functions.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 55bda9ae88..bf8630bc91 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -433,6 +433,19 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) } # Yield calibration + + # check for inconsistent settings + if((cfg$recalibrate == TRUE || cfg$recalibrate == "ifneeded") + && cfg$gms$s14_use_yield_calib == 0) { + stop("Recalibration of yields with a calibration run is requested (if needed), + but the resulting factors from this run are specified to not be used in the model. + This combination of settings is inconsistent and assumed to be unintended. + Please check the config and either set `cfg$gms$s14_use_yield_calib <- 1` + if yield calibration is desired, or `cfg$recalibrate <- FALSE` if not. + Note that the current default is to not use yield calibration.") + } + + # decide if calibration is needed if "ifneeded" is specified calib_file <- "modules/14_yields/input/f14_yld_calib.csv" if(cfg$recalibrate=="ifneeded") { if(!file.exists(calib_file)) { From fe96303b3ae0a92e9258bb58f527e3dee5340df7 Mon Sep 17 00:00:00 2001 From: davidho Date: Thu, 7 Dec 2023 14:58:37 +0100 Subject: [PATCH 2/4] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a63682fe4..09405b9b20 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 +- **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib - **inputdata** Now using inputdata rev4.94 which is based on 67420 cells (67k, previously 59k) - **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. From 72079da988cd90afb2c5809694467aa2def78e34 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:18:25 +0100 Subject: [PATCH 3/4] Update start_functions.R Reformulated error message. --- scripts/start_functions.R | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/start_functions.R b/scripts/start_functions.R index bf8630bc91..4f98b1417b 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -437,10 +437,9 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) # check for inconsistent settings if((cfg$recalibrate == TRUE || cfg$recalibrate == "ifneeded") && cfg$gms$s14_use_yield_calib == 0) { - stop("Recalibration of yields with a calibration run is requested (if needed), - but the resulting factors from this run are specified to not be used in the model. - This combination of settings is inconsistent and assumed to be unintended. - Please check the config and either set `cfg$gms$s14_use_yield_calib <- 1` + stop("The combination of the switches `cfg$recalibrate <- TRUE/ifneeded` + and `cfg$gms$s14_use_yield_calib <- 0` is inconsistent. + Please check the config and set `cfg$gms$s14_use_yield_calib <- 1` if yield calibration is desired, or `cfg$recalibrate <- FALSE` if not. Note that the current default is to not use yield calibration.") } From 11b4ac3a2d8e4d8d239b5dd180e1644e80de97b1 Mon Sep 17 00:00:00 2001 From: DavidhoPIK <101278418+DavidhoPIK@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:58:41 +0100 Subject: [PATCH 4/4] Update start_functions.R --- scripts/start_functions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 4f98b1417b..a6d47fe389 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -437,7 +437,7 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) # check for inconsistent settings if((cfg$recalibrate == TRUE || cfg$recalibrate == "ifneeded") && cfg$gms$s14_use_yield_calib == 0) { - stop("The combination of the switches `cfg$recalibrate <- TRUE/ifneeded` + stop("The combination of the switch configurations `cfg$recalibrate <- TRUE/ifneeded` and `cfg$gms$s14_use_yield_calib <- 0` is inconsistent. Please check the config and set `cfg$gms$s14_use_yield_calib <- 1` if yield calibration is desired, or `cfg$recalibrate <- FALSE` if not.