From 1bc62f3b3dd97dbd87028a12514f03d6f36b18df Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Mon, 22 Jan 2024 10:50:23 -0800 Subject: [PATCH] cohortDefinitionCols -- rm ad hoc addition; must be in metadata --- Biomass_core.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Biomass_core.R b/Biomass_core.R index 2b179e1..5420d4e 100644 --- a/Biomass_core.R +++ b/Biomass_core.R @@ -43,7 +43,7 @@ defineModule(sim, list( "If NULL, then will skip all summaryBGM related events")), defineParameter("calibrate", "logical", FALSE, desc = "Do calibration? Defaults to `FALSE`"), - defineParameter("cohortDefinitionCols", "character", c("pixelGroup", "speciesCode", "age"), NA, NA, + defineParameter("cohortDefinitionCols", "character", c("pixelGroup", "speciesCode", "age", "ecoregionGroup", "B"), NA, NA, desc = paste("`cohortData` columns that determine what constitutes a cohort", "This parameter should only be modified if additional modules are adding columns to cohortData")), defineParameter("cutpoint", "numeric", 1e10, NA, NA, @@ -944,7 +944,11 @@ Init <- function(sim, verbose = getOption("LandR.verbose", TRUE)) { sim$simulatedBiomassMap <- rasterizeReduced(pixelAll, pixelGroupMap, "uniqueSumB") } - colsToKeep <- unique(c(P(sim)$cohortDefinitionCols, "ecoregionGroup", "B")) + # can't add ecoregionGroup and B here in an adhoc way Eliot: Jan 19, 2024 ... the other modules + # don't add them in adhoc ways, so they will not match ... the parameters must be the same in + # all modules that use cohortDefinitionCols + # colsToKeep <- unique(c(P(sim)$cohortDefinitionCols, "ecoregionGroup", "B")) + colsToKeep <- unique(c(P(sim)$cohortDefinitionCols)) sim$cohortData <- cohortData[, .SD, .SDcol = colsToKeep] sim$cohortData[, c("mortality", "aNPPAct") := 0L] # sim$cohortData <- cohortData[, .(pixelGroup, ecoregionGroup, speciesCode, age, B, mortality = 0L, aNPPAct = 0L)]