Skip to content

Commit

Permalink
Merge pull request #617 from DavidhoPIK/develop
Browse files Browse the repository at this point in the history
added consistency check that prevents yield calibration runs without using the resulting factors in the magrun
  • Loading branch information
DavidhoPIK authored Dec 7, 2023
2 parents 2ad2d02 + 11b4ac3 commit 597c63b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 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
- **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.
Expand Down
12 changes: 12 additions & 0 deletions scripts/start_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,18 @@ 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("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.
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)) {
Expand Down

0 comments on commit 597c63b

Please sign in to comment.