From ec286f00df1a0aa29d422eba336408e72360eedc Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Wed, 1 Mar 2023 14:02:02 -0500 Subject: [PATCH 1/3] comment out code that sets defaults in config.xml --- models/ed/R/write.configs.ed.R | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/models/ed/R/write.configs.ed.R b/models/ed/R/write.configs.ed.R index 104cdd4f2de..e7f1ad5c8ba 100644 --- a/models/ed/R/write.configs.ed.R +++ b/models/ed/R/write.configs.ed.R @@ -459,22 +459,22 @@ write.config.xml.ED2 <- function(settings, trait.values, defaults = settings$con # a new history file, add the .csv file to models/ed/data-raw and run the # sysdata.R script in that folder - if(is.null(settings$model$revision)) { - PEcAn.logger::logger.debug("--- Using Generic ED2 History File") - edhistory <- history - } else { - histfile <- paste0("history.r", settings$model$revision) - edhistory <- try(eval(str2lang(histfile)), silent = TRUE) - } - - if(inherits(edhistory, "try-error")) { - PEcAn.logger::logger.debug("--- Using Generic ED2 History File") - edhistory <- history - } else { - PEcAn.logger::logger.debug(paste0("--- Using ED2 History File: ", histfile)) - } - - edtraits <- names(edhistory) + # if(is.null(settings$model$revision)) { + # PEcAn.logger::logger.debug("--- Using Generic ED2 History File") + # edhistory <- history + # } else { + # histfile <- paste0("history.r", settings$model$revision) + # edhistory <- try(eval(str2lang(histfile)), silent = TRUE) + # } + # + # if(inherits(edhistory, "try-error")) { + # PEcAn.logger::logger.debug("--- Using Generic ED2 History File") + # edhistory <- history + # } else { + # PEcAn.logger::logger.debug(paste0("--- Using ED2 History File: ", histfile)) + # } + # + # edtraits <- names(edhistory) pftmapping <- PEcAn.ED2::pftmapping ## Get ED2 specific model settings and put into output config xml file @@ -542,13 +542,14 @@ write.config.xml.ED2 <- function(settings, trait.values, defaults = settings$con } else { ## Get default trait values from ED history - vals <- as.list(edhistory[edhistory$num == pft.number, ]) + # vals <- as.list(edhistory[edhistory$num == pft.number, ]) ## Convert trait values to ED units converted.trait.values <- convert.samples.ED(trait.values[[i]]) ## Selectively replace defaults with trait values - vals <- modifyList(vals, converted.trait.values) + # vals <- modifyList(vals, converted.trait.values) + vals <- converted.trait.values ## Convert settings constants to ED units converted.defaults <- convert.samples.ED(defaults[[pft]]$constants) From 162d1f092c49834da0266c0934b8ab7261c30c6c Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Wed, 1 Mar 2023 15:25:52 -0500 Subject: [PATCH 2/3] keep ED2 pft number --- models/ed/R/write.configs.ed.R | 1 + 1 file changed, 1 insertion(+) diff --git a/models/ed/R/write.configs.ed.R b/models/ed/R/write.configs.ed.R index e7f1ad5c8ba..a79dcaccdb3 100644 --- a/models/ed/R/write.configs.ed.R +++ b/models/ed/R/write.configs.ed.R @@ -550,6 +550,7 @@ write.config.xml.ED2 <- function(settings, trait.values, defaults = settings$con ## Selectively replace defaults with trait values # vals <- modifyList(vals, converted.trait.values) vals <- converted.trait.values + vals$num <- pft.number #keep the ED2 pft number ## Convert settings constants to ED units converted.defaults <- convert.samples.ED(defaults[[pft]]$constants) From bf6b2cc4d9dacb3f37dfbd663452b6bbc8754ba8 Mon Sep 17 00:00:00 2001 From: "Eric R. Scott" Date: Thu, 16 Mar 2023 11:02:17 -0400 Subject: [PATCH 3/3] comment out test --- .../ed/tests/testthat/test.write.configs.ed.R | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/models/ed/tests/testthat/test.write.configs.ed.R b/models/ed/tests/testthat/test.write.configs.ed.R index 9609c739edd..d976e6d7a0e 100644 --- a/models/ed/tests/testthat/test.write.configs.ed.R +++ b/models/ed/tests/testthat/test.write.configs.ed.R @@ -183,34 +183,34 @@ test_that("New ED2IN tags get added at bottom of file", { }) -test_that("write.config.xml.ED2() uses correct history file", { - #1. read in pecan.xml in data/pecan_checked.xml - settings <- PEcAn.settings::read.settings("data/pecan_checked.xml") - #for debugging: - # settings <- PEcAn.settings::read.settings("models/ed/tests/testthat/data/pecan_checked.xml") - - #2. Set rundir to tempdir - rundir <- tempfile() - dir.create(rundir) - on.exit(unlink(rundir, recursive = TRUE)) - settings$rundir <- rundir - run.id <- "ENS-00001-76" - dir.create(file.path(rundir, run.id)) - #3. set revision to 81 - settings$model$revision <- "81" - - x <- capture.output( - write.config.xml.ED2( - settings = settings, - trait.values = trait.values, - defaults = defaults - ), - type = "message" - ) - - expect_true(any(stringr::str_detect(x, "history.r81"))) - -}) +# test_that("write.config.xml.ED2() uses correct history file", { +# #1. read in pecan.xml in data/pecan_checked.xml +# settings <- PEcAn.settings::read.settings("data/pecan_checked.xml") +# #for debugging: +# # settings <- PEcAn.settings::read.settings("models/ed/tests/testthat/data/pecan_checked.xml") +# +# #2. Set rundir to tempdir +# rundir <- tempfile() +# dir.create(rundir) +# on.exit(unlink(rundir, recursive = TRUE)) +# settings$rundir <- rundir +# run.id <- "ENS-00001-76" +# dir.create(file.path(rundir, run.id)) +# #3. set revision to 81 +# settings$model$revision <- "81" +# +# x <- capture.output( +# write.config.xml.ED2( +# settings = settings, +# trait.values = trait.values, +# defaults = defaults +# ), +# type = "message" +# ) +# +# expect_true(any(stringr::str_detect(x, "history.r81"))) +# +# }) ## test_that("remove.configs.ED2 works with remote host",{