Closed CeresBarros closed 3 months ago
Here's a reprex.
Many species have a non-error/non-character GC, with tables full of NA's, but GC$NonLinearModel == NULL
GC
GC$NonLinearModel == NULL
repos <- c("predictiveecology.r-universe.dev", getOption("repos")) install.packages(c("SpaDES.project"), repos = repos) library(SpaDES.project) out <- setupProject( ## INPUT OBJECTS ----------------------------------- ## these need to come *before* any formal arguments, as they are needed for params.R sppEquivCol = "Boreal", vegLeadingProportion = 0, successionTimestep = 10L, eventCaching = c(".inputObjects", "init"), useParallel = FALSE, paths = list("packagePath" = "packages/", "projectPath" = "~/tutos/LandRDemo_coreVeg"), packages = c( ## these are needed but don't load "PredictiveEcology/SpaDES.experiment@development (HEAD)", "terra" ), options = list( "reproducible.destinationPath" = paths$inputPath, "spades.inputPath" = paths$inputPath, "spades.moduleCodeChecks" = FALSE ), modules = c( # "PredictiveEcology/Biomass_speciesData@development", # "PredictiveEcology/Biomass_borealDataPrep@development", # "PredictiveEcology/Biomass_speciesParameters@development", # "PredictiveEcology/Biomass_core@development", # "PredictiveEcology/Biomass_validationKNN@development" "Biomass_speciesData", "Biomass_borealDataPrep", "Biomass_speciesParameters", "Biomass_core", "Biomass_validationKNN" ), ## SIMULATION SETUP ------------------------------------ times = list(start = 2001, end = 2031), params = "PredictiveEcology/PredictiveEcology.org@training-book/tutos/LandRDemo_coreVeg/params.R", ## (more) INPUT OBJECTS ----------------------------------- ## these come after, so that we don't need to pre-install/load LandR ## species lists/traits sppEquiv = { data("sppEquivalencies_CA", package = "LandR") sppEquivalencies_CA[grep("Pin", LandR), `:=`(EN_generic_short = "Pine", EN_generic_full = "Pine", Leading = "Pine leading")] sppEquivalencies_CA[grep("Betu_pap", LandR), `:=`(EN_generic_short = "Birch", EN_generic_full = "Birch", Leading = "Birch leading")] ## all Popu will be merged sppEquivalencies_CA[grep("Popu_", LandR), `:=`(EN_generic_short = "Poplar", EN_generic_full = "Poplar", Leading = "Poplar leading")] sppEquivalencies_CA[grep("Popu_", LandR), Boreal := "Popu_Spp"] ## define spp column to use for model sppEquivalencies_CA <- sppEquivalencies_CA[!"", on = sppEquivCol] sppEquivalencies_CA <- na.omit(sppEquivalencies_CA, sppEquivCol) sppEquivalencies_CA }, speciesParams = { list( "shadetolerance" = list( Betu_Pap = 1 , Lari_Lar = 1 , Pice_Gla = 2 , Pice_Mar = 3 , Pinu_Ban = 1.5 , Popu_Spp = 1 ) ) }, studyArea = { originalcrs <- "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0" Biomass_corecrs <- "+proj=lcc +lat_1=49 +lat_2=77 +lat_0=0 +lon_0=-95 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0" smallExtent <- c(xmin = -104.757, xmax = -104.48835, ymin = 55.68663, ymax = 55.94491) studyAreaS <- terra::vect(terra::ext(smallExtent)) studyAreaS <- terra::vect(terra::geom(studyAreaS), "polygons", crs = originalcrs, atts = data.frame(id = 1:length(studyAreaS))) studyAreaS <- terra::project(studyAreaS, Biomass_corecrs) studyAreaS }, studyAreaLarge = { originalcrs <- "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0" Biomass_corecrs <- "+proj=lcc +lat_1=49 +lat_2=77 +lat_0=0 +lon_0=-95 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0" largeExtent <- c(xmin = -104.757, xmax = -104.2197, ymin = 55.68663, ymax = 56.20319) studyAreaL <- terra::vect(terra::ext(largeExtent)) studyAreaL <- terra::vect(terra::geom(studyAreaL), "polygons", crs = originalcrs, atts = data.frame(id = 1:length(studyAreaL))) studyAreaL <- terra::project(studyAreaL, Biomass_corecrs) studyAreaL } ) out$modules <- out$modules[out$modules != "Biomass_validationKNN"] ## initialise simulation and cache simInitOut <- do.call(SpaDES.core::simInit, out) |> reproducible::Cache(useCache = "overwrite") simOut <- SpaDES.core::spades(simInitOut)
proposed fix #42 , but maybe worth checking why GC$NonLinearModel is NULL, rather than class error
GC$NonLinearModel
fixed in #42
Here's a reprex.
Many species have a non-error/non-character
GC
, with tables full of NA's, butGC$NonLinearModel == NULL