From 4eea471122ee26b54f8290bb62a16e1c8a334cb3 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Fri, 9 Oct 2026 10:18:49 -0700 Subject: [PATCH 01/15] projectedClimateYears defaults to 2017:2100 The tile 39 projected archive (CNRM-ESM2-1 ssp370, 2010 decade) lacks 2013-2016, and observed climate now covers 1901-2024, so projections before 2017 are not needed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv --- NEWS.md | 4 ++++ canClimateData.R | 7 +++++-- tests/testthat/test-metadata.R | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index ab016e3..626db9f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# canClimateData (development version) + +- `projectedClimateYears` now defaults to 2017:2100 instead of 2011:2100. The projected archive for tile 39 (CNRM-ESM2-1 ssp370) has no 2013-2016 files, and observed climate now covers 1901-2024, so projections before 2017 are not needed. + # canClimateData 1.1.0 canClimateData now uses the current climateData package to prepare its climate layers. It can run hindcasts as well as forecasts, it returns historical and projected climate as named lists, and a shared output folder can be set for climate files. The manual was updated, with links for exploring and comparing climate scenarios. diff --git a/canClimateData.R b/canClimateData.R index d84d294..a0846d9 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -51,9 +51,12 @@ defineModule(sim, list( defineParameter("projectedClimatePeriod", "character", NULL, NA, NA, paste("period to use for projected climate normals", "if `climateVariables` not supplied.")), - defineParameter("projectedClimateYears", "numeric", 2011:2100, NA, NA, + defineParameter("projectedClimateYears", "numeric", 2017:2100, NA, NA, paste("range of years captured by the projected climate data", - "if `climateVariables` not supplied.")), + "if `climateVariables` not supplied.", + "Starts in 2017 because the projected archive for tile 39", + "(CNRM-ESM2-1 ssp370) lacks 2013-2016, and observed climate", + "now covers 1901-2024, so earlier projections are not needed.")), defineParameter("projectedType", "character", "forecast", NA, NA, paste("one of 'forecast' or 'hindcast' to prepare either projected future,", "or sampled historical data for hindcast studies, respectively.")), diff --git a/tests/testthat/test-metadata.R b/tests/testthat/test-metadata.R index ce9aa30..42dfe74 100644 --- a/tests/testthat/test-metadata.R +++ b/tests/testthat/test-metadata.R @@ -44,3 +44,9 @@ test_that("parameters are the expected names", { "projectedClimateYears", "projectedType", "quickCheck")) ) }) + +test_that("projected climate years start in 2017", { + md <- SpaDES.core::moduleMetadata(module = moduleName, path = modulePath) + pars <- stats::setNames(md$parameters$default, md$parameters$paramName) + expect_identical(pars[["projectedClimateYears"]], 2017:2100) +}) From bb1caa2089cab8eb4b77982443adf08baf276b99 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 14 Oct 2026 16:31:16 -0700 Subject: [PATCH 02/15] init fails early when times are not calendar years Co-Authored-By: Claude Opus 5.5 --- NEWS.md | 4 ++++ canClimateData.R | 19 +++++++++++++++++++ tests/testthat/test-calendarYears.R | 25 +++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/testthat/test-calendarYears.R diff --git a/NEWS.md b/NEWS.md index ab016e3..8750962 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# canClimateData (development version) + +- `init` now stops, before preparing any climate data, when the run's start is not a calendar year from 1901 to 2100 (for example the model years 0-10 that `setupProject()` gives without `times`). The message says to set `times`, e.g. `times = list(start = 2020, end = 2120)`. The run may end after 2100. + # canClimateData 1.1.0 canClimateData now uses the current climateData package to prepare its climate layers. It can run hindcasts as well as forecasts, it returns historical and projected climate as named lists, and a shared output folder can be set for climate files. The manual was updated, with links for exploring and comparing climate scenarios. diff --git a/canClimateData.R b/canClimateData.R index d84d294..e684de3 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -141,7 +141,26 @@ climateRastersToRewrite <- function(projectedType) { if (identical(projectedType, "hindcast")) "projected" else character(0) } +#' Check that the run's times are calendar years the climate data can serve +#' +#' The climate data are by calendar year: historical from 1901, projections to 2100. A run +#' whose start is outside 1901-2100 (e.g. model years 0-10, which `setupProject()` gives when +#' `times` is not set) cannot be matched to any climate year. The run may end after 2100. +#' +#' @param start,end Start and end times of the simulation. +#' +#' @return `NULL` invisibly; an error otherwise. +checkCalendarYears <- function(start, end) { + if (start < 1901 || start > 2100) { + stop("canClimateData: times are model years ", start, "-", end, "; this module needs calendar years ", + "(the climate data cover 1901-2100, so `start` must be in that range), ", + "e.g. times = list(start = 2020, end = 2120).", call. = FALSE) + } + invisible(NULL) +} + Init <- function(sim) { + checkCalendarYears(start(sim), end(sim)) stopifnot(P(sim)$projectedType %in% c("forecast", "hindcast")) ## separate intermediate outputs from raw inputs, to reduce file conflicts on shared drives diff --git a/tests/testthat/test-calendarYears.R b/tests/testthat/test-calendarYears.R new file mode 100644 index 0000000..c52bc11 --- /dev/null +++ b/tests/testthat/test-calendarYears.R @@ -0,0 +1,25 @@ +## The climate data are by calendar year (historical from 1901, projections to 2100), so a run +## whose times are model years (setupProject() without `times` gives 0 to 10) cannot be served. + +test_that("calendar-year start times are accepted", { + expect_silent(checkCalendarYears(2020, 2120)) + expect_silent(checkCalendarYears(1901, 1950)) + expect_silent(checkCalendarYears(2100, 2100)) + expect_silent(checkCalendarYears(1985.5, 2020)) +}) + +test_that("model-year times fail with a message that says what to supply", { + expect_error(checkCalendarYears(0, 10), "model years 0-10.*calendar years.*times = list\\(start = 2020") + expect_error(checkCalendarYears(1900, 2000), "1901") + expect_error(checkCalendarYears(2101, 2200), "2100") +}) + +test_that("init stops on model-year times before touching any climate data", { + rtm <- terra::rast(nrows = 2, ncols = 2, vals = 1L, crs = "EPSG:3978") + sa <- sf::st_as_sf(terra::as.polygons(rtm)) + sim <- suppressMessages(SpaDES.core::simInit( + times = list(start = 0, end = 10), modules = moduleName, paths = testPaths, + objects = list(studyArea = sa, rasterToMatch = rtm, climateVariables = list(dummy = list())))) + expect_error(suppressMessages(SpaDES.core::spades(sim, debug = FALSE)), + "model years 0-10.*calendar years") +}) From 97f7e4e7642ffe6de6e3a90836ce74bdc09ef4ae Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 14 Oct 2026 17:05:22 -0700 Subject: [PATCH 03/15] Use climateData::checkCalendarYears(); canClimateData follow-ups Co-Authored-By: Claude Opus 5.5 --- NEWS.md | 2 +- canClimateData.R | 37 +++++++++++++---------------- tests/testthat/test-calendarYears.R | 33 +++++++++++++------------ 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8750962..39f4e55 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # canClimateData (development version) -- `init` now stops, before preparing any climate data, when the run's start is not a calendar year from 1901 to 2100 (for example the model years 0-10 that `setupProject()` gives without `times`). The message says to set `times`, e.g. `times = list(start = 2020, end = 2120)`. The run may end after 2100. +- `init` now stops, before preparing any climate data, when the run's start is outside the climate years this module is asked for (`historicalClimateYears` and `projectedClimateYears`, 1991 to 2100 by default), for example the model years 0-10 that `setupProject()` gives without `times`. With a supplied `climateVariables`, whose years are not known here, it stops when the start is not a calendar year from 1901 to 2100. The check is `climateData::checkCalendarYears()` (climateData >= 2.2.3.9009); the message says how to proceed. The run may end after the last year. # canClimateData 1.1.0 diff --git a/canClimateData.R b/canClimateData.R index e684de3..b8fc530 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -20,7 +20,7 @@ defineModule(sim, list( reqdPkgs = list("archive", "digest", "geodata", "googledrive", "purrr", "R.utils", "sf", "spatialEco", "terra", "dbplyr", # needed for prepClimateLayers - "PredictiveEcology/climateData@development (>= 2.2.3.9008)", + "PredictiveEcology/climateData@development (>= 2.2.3.9009)", "PredictiveEcology/fireSenseUtils@development (>= 0.0.5.9046)", "PredictiveEcology/LandR@development (>= 1.1.0.9064)", "PredictiveEcology/reproducible@development (>= 3.2.1.9060)", @@ -141,26 +141,20 @@ climateRastersToRewrite <- function(projectedType) { if (identical(projectedType, "hindcast")) "projected" else character(0) } -#' Check that the run's times are calendar years the climate data can serve -#' -#' The climate data are by calendar year: historical from 1901, projections to 2100. A run -#' whose start is outside 1901-2100 (e.g. model years 0-10, which `setupProject()` gives when -#' `times` is not set) cannot be matched to any climate year. The run may end after 2100. -#' -#' @param start,end Start and end times of the simulation. -#' -#' @return `NULL` invisibly; an error otherwise. -checkCalendarYears <- function(start, end) { - if (start < 1901 || start > 2100) { - stop("canClimateData: times are model years ", start, "-", end, "; this module needs calendar years ", - "(the climate data cover 1901-2100, so `start` must be in that range), ", - "e.g. times = list(start = 2020, end = 2120).", call. = FALSE) - } - invisible(NULL) -} - Init <- function(sim) { - checkCalendarYears(start(sim), end(sim)) + ## When this module builds `climateVariables` it fetches `historicalClimateYears` and + ## `projectedClimateYears`, so the run's start must fall within those. A supplied + ## `climateVariables` has years this module cannot read, so only calendar years are required. + ## (`.inputObjects` sets the flag; it does not run when every input was supplied.) + fromParams <- isTRUE(mod$climateVariablesFromParams) + checkCalendarYears(start(sim), end(sim), module = "canClimateData", + years = if (fromParams) + c(P(sim)$historicalClimateYears, P(sim)$projectedClimateYears), + hint = if (fromParams) { + "Set `times` inside those years, or change `historicalClimateYears`/`projectedClimateYears`." + } else { + "`climateVariables` was supplied, so its years are not known here: set `times` to calendar years." + }) stopifnot(P(sim)$projectedType %in% c("forecast", "hindcast")) ## separate intermediate outputs from raw inputs, to reduce file conflicts on shared drives @@ -309,7 +303,8 @@ Init <- function(sim) { datatype = "INT1U", overwrite = TRUE) } - if (!suppliedElsewhere("climateVariables", sim)) { + mod$climateVariablesFromParams <- !suppliedElsewhere("climateVariables", sim) + if (mod$climateVariablesFromParams) { historical_prd <- P(sim)$historicalClimatePeriod historical_yrs <- P(sim)$historicalClimateYears projected_yrs <- P(sim)$projectedClimateYears diff --git a/tests/testthat/test-calendarYears.R b/tests/testthat/test-calendarYears.R index c52bc11..8226b4d 100644 --- a/tests/testthat/test-calendarYears.R +++ b/tests/testthat/test-calendarYears.R @@ -1,25 +1,24 @@ -## The climate data are by calendar year (historical from 1901, projections to 2100), so a run -## whose times are model years (setupProject() without `times` gives 0 to 10) cannot be served. +## The climate data are by calendar year (see climateData::checkCalendarYears(), which has the rule +## and its unit tests), so a run whose times are model years (setupProject() without `times` gives +## 0 to 10) cannot be served. This module must stop before preparing any climate data. -test_that("calendar-year start times are accepted", { - expect_silent(checkCalendarYears(2020, 2120)) - expect_silent(checkCalendarYears(1901, 1950)) - expect_silent(checkCalendarYears(2100, 2100)) - expect_silent(checkCalendarYears(1985.5, 2020)) -}) - -test_that("model-year times fail with a message that says what to supply", { - expect_error(checkCalendarYears(0, 10), "model years 0-10.*calendar years.*times = list\\(start = 2020") - expect_error(checkCalendarYears(1900, 2000), "1901") - expect_error(checkCalendarYears(2101, 2200), "2100") -}) - -test_that("init stops on model-year times before touching any climate data", { +test_that("init stops, with a supplied climateVariables, on model-year times before touching any climate data", { rtm <- terra::rast(nrows = 2, ncols = 2, vals = 1L, crs = "EPSG:3978") sa <- sf::st_as_sf(terra::as.polygons(rtm)) sim <- suppressMessages(SpaDES.core::simInit( times = list(start = 0, end = 10), modules = moduleName, paths = testPaths, objects = list(studyArea = sa, rasterToMatch = rtm, climateVariables = list(dummy = list())))) expect_error(suppressMessages(SpaDES.core::spades(sim, debug = FALSE)), - "model years 0-10.*calendar years") + "canClimateData: times are model years 0-10.*calendar years.*climateVariables. was supplied") +}) + +test_that("init stops when the run starts before the climate years this module is asked for", { + rtm <- terra::rast(nrows = 2, ncols = 2, vals = 1L, crs = "EPSG:3978") + sa <- sf::st_as_sf(terra::as.polygons(rtm)) + sim <- suppressMessages(SpaDES.core::simInit( + times = list(start = 1950, end = 2020), modules = moduleName, paths = testPaths, + params = list(canClimateData = list(historicalClimateYears = 1991:2022, projectedClimateYears = 2011:2100)), + objects = list(studyArea = sa, rasterToMatch = rtm))) + expect_error(suppressMessages(SpaDES.core::spades(sim, debug = FALSE)), + "times are model years 1950-2020.*cover 1991-2100.*historicalClimateYears") }) From 7ce590c6b2b2958d6aa07c31b9fb2d2ff65c724c Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 21 Oct 2026 09:51:04 -0700 Subject: [PATCH 04/15] CI: run on modsForFireSense (our integration branch; fixes are PR'd into it) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6 --- .github/workflows/render-module-rmd.yaml | 2 ++ .github/workflows/testthat-module.yaml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/render-module-rmd.yaml b/.github/workflows/render-module-rmd.yaml index 5c27f8e..ce7819d 100644 --- a/.github/workflows/render-module-rmd.yaml +++ b/.github/workflows/render-module-rmd.yaml @@ -13,11 +13,13 @@ on: - main - master - development + - modsForFireSense push: branches: - main - master - development + - modsForFireSense paths: - .github/workflows/render-module-rmd.yaml - canClimateData.Rmd diff --git a/.github/workflows/testthat-module.yaml b/.github/workflows/testthat-module.yaml index 05f5653..235c469 100644 --- a/.github/workflows/testthat-module.yaml +++ b/.github/workflows/testthat-module.yaml @@ -5,9 +5,9 @@ name: testthat-module on: pull_request: - branches: [main, master, development] + branches: [main, master, development, modsForFireSense] push: - branches: [main, master, development] + branches: [main, master, development, modsForFireSense] paths: - .github/workflows/testthat-module.yaml - canClimateData.R From 54874463868b4c560d5881aca732f4ea51e1c99a Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Thu, 12 Nov 2026 14:34:41 -0700 Subject: [PATCH 05/15] init checks the climate year (climateYear) the run is at, not start(sim); loadOrder before climateYear; climateData@modsForFireSense A run in model years (NRV, 2720...) stopped in init because start(sim) is not a calendar year. With climateYear present, it is the year checked. Declaring the climateYear input reversed the init order (cycle with climateYear); loadOrder restores it. checkCalendarYears() exists only on climateData modsForFireSense. Co-Authored-By: Claude Opus 5.5 --- NEWS.md | 2 ++ canClimateData.R | 18 +++++++++++++++--- tests/testthat/test-calendarYears.R | 16 ++++++++++++++++ tests/testthat/test-loadOrder.R | 29 +++++++++++++++++++++++++++++ tests/testthat/test-metadata.R | 1 + 5 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 tests/testthat/test-loadOrder.R diff --git a/NEWS.md b/NEWS.md index 4f33b1b..261025f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # canClimateData (development version) +- For a run whose years are not calendar years (NRV), `init` now checks the climate year the run is at (`climateYear`, from the climateYear module) instead of the run's start. Before, such runs stopped at once, because a model year like 2720 is not a climate year. `climateYear` is a new optional input, and `loadOrder` keeps this module's `init` before climateYear's, as it was. +- `climateData` is now required from its modsForFireSense branch (>= 2.2.3.9011). `checkCalendarYears()` is only there; climateData development reached 2.2.3.9011 without it, so the old floor installed a climateData whose `init` failed with "could not find function". - `projectedClimateYears` now defaults to 2017:2100 instead of 2011:2100. The projected archive for tile 39 (CNRM-ESM2-1 ssp370) has no 2013-2016 files, and observed climate now covers 1901-2024, so projections before 2017 are not needed. - `init` now stops, before preparing any climate data, when the run's start is outside the climate years this module is asked for (`historicalClimateYears` and `projectedClimateYears`, 1991 to 2100 by default), for example the model years 0-10 that `setupProject()` gives without `times`. With a supplied `climateVariables`, whose years are not known here, it stops when the start is not a calendar year from 1901 to 2100. The check is `climateData::checkCalendarYears()` (climateData >= 2.2.3.9009); the message says how to proceed. The run may end after the last year. - Fixed: the `Cache()` of `prepClimateLayers()` in `Init()` (canClimateData.R) named the module's local variables (`climatePath`, `climatePathOut`) in `omitArgs` instead of the function's formal arguments (`srcdir`, `dstdir`), so nothing was omitted and the folder paths stayed in the cache key. Changing the input or output folder (a new per-study-area folder, a different mount on another machine) re-prepared the climate data. The cache key changes, so every study area re-prepares its climate data once. The result is file-backed under `dstdir`; `reproducible` restores it under the current `outputPath` (or the cache) on a hit, so omitting `dstdir` is safe. diff --git a/canClimateData.R b/canClimateData.R index 88313e7..6e37781 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -17,10 +17,11 @@ defineModule(sim, list( timeunit = "year", citation = list("citation.bib"), documentation = deparse(list("README.md", "canClimateData.Rmd")), + loadOrder = list(before = "climateYear"), reqdPkgs = list("archive", "digest", "geodata", "googledrive", "purrr", "R.utils", "sf", "spatialEco", "terra", "dbplyr", # needed for prepClimateLayers - "PredictiveEcology/climateData@development (>= 2.2.3.9009)", + "PredictiveEcology/climateData@modsForFireSense (>= 2.2.3.9011)", "PredictiveEcology/fireSenseUtils@development (>= 0.0.5.9046)", "PredictiveEcology/LandR@development (>= 1.1.0.9064)", "PredictiveEcology/reproducible@development (>= 3.2.1.9060)", @@ -94,6 +95,12 @@ defineModule(sim, list( "are set by module parameters and must be identical for all variables.", "See also for all available climate variables."), sourceURL = NA), + expectsInput("climateYear", "numeric", + desc = paste("Optional: the calendar year of climate the simulation is at (from the", + "`climateYear` module), when simulation years are not calendar years", + "(e.g. NRV runs). When present, it, not `start(sim)`, must be a year the", + "climate data cover."), + sourceURL = NA), expectsInput("rasterToMatch", "SpatRaster", desc = "template raster corresponding to `studyArea`.", sourceURL = NA), expectsInput("studyArea", "sf", @@ -149,11 +156,16 @@ Init <- function(sim) { ## `projectedClimateYears`, so the run's start must fall within those. A supplied ## `climateVariables` has years this module cannot read, so only calendar years are required. ## (`.inputObjects` sets the flag; it does not run when every input was supplied.) + ## A run whose years are not calendar years (NRV) maps them to climate years (`climateYear` + ## module); then the climate year it is at is what must be a calendar year. fromParams <- isTRUE(mod$climateVariablesFromParams) - checkCalendarYears(start(sim), end(sim), module = "canClimateData", + yrs <- if (is.null(sim$climateYear)) c(start(sim), end(sim)) else rep(sim$climateYear, 2) + checkCalendarYears(yrs[1], yrs[2], module = "canClimateData", years = if (fromParams) c(P(sim)$historicalClimateYears, P(sim)$projectedClimateYears), - hint = if (fromParams) { + hint = if (!is.null(sim$climateYear)) { + "That is `climateYear`, the climate year this run is at." + } else if (fromParams) { "Set `times` inside those years, or change `historicalClimateYears`/`projectedClimateYears`." } else { "`climateVariables` was supplied, so its years are not known here: set `times` to calendar years." diff --git a/tests/testthat/test-calendarYears.R b/tests/testthat/test-calendarYears.R index 8226b4d..cc0c476 100644 --- a/tests/testthat/test-calendarYears.R +++ b/tests/testthat/test-calendarYears.R @@ -22,3 +22,19 @@ test_that("init stops when the run starts before the climate years this module i expect_error(suppressMessages(SpaDES.core::spades(sim, debug = FALSE)), "times are model years 1950-2020.*cover 1991-2100.*historicalClimateYears") }) + +test_that("with a climateYear (a run in model years, e.g. NRV), the climate year is checked, not start(sim)", { + rtm <- terra::rast(nrows = 2, ncols = 2, vals = 1L, crs = "EPSG:3978") + sa <- sf::st_as_sf(terra::as.polygons(rtm)) + run <- function(climateYear) { + sim <- suppressMessages(SpaDES.core::simInit( + times = list(start = 2720, end = 2820), modules = moduleName, paths = testPaths, + objects = list(studyArea = sa, rasterToMatch = rtm, climateVariables = list(dummy = list()), + climateYear = climateYear))) + tryCatch({suppressMessages(SpaDES.core::spades(sim, debug = FALSE)); ""}, + error = function(e) conditionMessage(e)) + } + ## stops later, on the dummy climateVariables, but not on the years + expect_false(grepl("model years", run(2014))) + expect_match(run(1800), "model years 1800-1800") +}) diff --git a/tests/testthat/test-loadOrder.R b/tests/testthat/test-loadOrder.R new file mode 100644 index 0000000..12ec7c7 --- /dev/null +++ b/tests/testthat/test-loadOrder.R @@ -0,0 +1,29 @@ +## This module reads `climateYear` (from the climateYear module), and climateYear reads this +## module's climate rasters: a cycle, which SpaDES resolves with climateYear's init first. +## The `loadOrder` metadata keeps this module's init first, in either module order. The stub +## has climateYear's inputs, output and loadOrder; without this module's loadOrder it fails. + +test_that("init is scheduled before climateYear's, in either module order", { + mp <- withr::local_tempdir() + file.symlink(moduleRoot, file.path(mp, moduleName)) + dir.create(file.path(mp, "climateYear")) + writeLines(c( + 'defineModule(sim, list(name = "climateYear", description = "stub", keywords = "",', + ' authors = person("A", "B"), childModules = character(0), version = list(climateYear = "0.0.1"),', + ' timeframe = as.POSIXlt(c(NA, NA)), timeunit = "year", citation = list(), documentation = list(),', + ' loadOrder = list(before = "fireSense_dataPrepPredict"),', + ' reqdPkgs = list(), parameters = rbind(defineParameter(".useCache", "logical", FALSE, NA, NA, "stub")),', + ' inputObjects = bindrows(expectsInput("historicalClimateRasters", "list", "stub"),', + ' expectsInput("projectedClimateRasters", "list", "stub")),', + ' outputObjects = createsOutput("climateYear", "numeric", "stub")))', + 'doEvent.climateYear <- function(sim, eventTime, eventType) sim'), + file.path(mp, "climateYear", "climateYear.R")) + for (mods in list(c(moduleName, "climateYear"), c("climateYear", moduleName))) { + sim <- suppressMessages(SpaDES.core::simInit( + times = list(start = 2000, end = 2001), modules = mods, + paths = modifyList(testPaths, list(modulePath = mp)))) + ev <- SpaDES.core::events(sim) + inits <- ev$moduleName[ev$eventType == "init"] + expect_identical(inits[inits %in% mods], c(moduleName, "climateYear")) + } +}) diff --git a/tests/testthat/test-metadata.R b/tests/testthat/test-metadata.R index 42dfe74..30b62c3 100644 --- a/tests/testthat/test-metadata.R +++ b/tests/testthat/test-metadata.R @@ -18,6 +18,7 @@ test_that("inputs are the expected names and classes", { expect_identical( inputs[order(names(inputs))], c(climateVariables = "list", + climateYear = "numeric", rasterToMatch = "SpatRaster", studyArea = "sf") ) From 2a0d92baa737d4a118775cfd244376adb6c6fa09 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Thu, 12 Nov 2026 15:13:15 -0700 Subject: [PATCH 06/15] Year check of a rerun uses the run's climateYearRecord, not climateYear sim$climateYear is per-event state (in a replay, the last year's value). The record of the climate year used in each simulation year is climateYearRecord; when supplied (a rerun), its climate years for times are checked against the years this module prepares. In a normal run climateYear writes it after this module's init (loadOrder), so it is not read. Co-Authored-By: Claude Opus 5.5 --- NEWS.md | 2 +- canClimateData.R | 47 ++++++++++++++++++----------- tests/testthat/test-calendarYears.R | 19 +++++++----- tests/testthat/test-loadOrder.R | 4 +-- tests/testthat/test-metadata.R | 2 +- 5 files changed, 44 insertions(+), 30 deletions(-) diff --git a/NEWS.md b/NEWS.md index 261025f..037e111 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # canClimateData (development version) -- For a run whose years are not calendar years (NRV), `init` now checks the climate year the run is at (`climateYear`, from the climateYear module) instead of the run's start. Before, such runs stopped at once, because a model year like 2720 is not a climate year. `climateYear` is a new optional input, and `loadOrder` keeps this module's `init` before climateYear's, as it was. +- Rerunning this module on a finished run whose years are not calendar years (NRV) no longer stops on the year check. When that run's `climateYearRecord` (from the climateYear module) is supplied, `init` checks the climate years it recorded for `times` against `historicalClimateYears`/`projectedClimateYears` (when this module builds `climateVariables`), not `times` itself. `climateYearRecord` is a new optional input; in a normal run climateYear writes it after this module's `init`, and `loadOrder` keeps that order. - `climateData` is now required from its modsForFireSense branch (>= 2.2.3.9011). `checkCalendarYears()` is only there; climateData development reached 2.2.3.9011 without it, so the old floor installed a climateData whose `init` failed with "could not find function". - `projectedClimateYears` now defaults to 2017:2100 instead of 2011:2100. The projected archive for tile 39 (CNRM-ESM2-1 ssp370) has no 2013-2016 files, and observed climate now covers 1901-2024, so projections before 2017 are not needed. - `init` now stops, before preparing any climate data, when the run's start is outside the climate years this module is asked for (`historicalClimateYears` and `projectedClimateYears`, 1991 to 2100 by default), for example the model years 0-10 that `setupProject()` gives without `times`. With a supplied `climateVariables`, whose years are not known here, it stops when the start is not a calendar year from 1901 to 2100. The check is `climateData::checkCalendarYears()` (climateData >= 2.2.3.9009); the message says how to proceed. The run may end after the last year. diff --git a/canClimateData.R b/canClimateData.R index 6e37781..6ad7505 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -95,11 +95,13 @@ defineModule(sim, list( "are set by module parameters and must be identical for all variables.", "See also for all available climate variables."), sourceURL = NA), - expectsInput("climateYear", "numeric", - desc = paste("Optional: the calendar year of climate the simulation is at (from the", - "`climateYear` module), when simulation years are not calendar years", - "(e.g. NRV runs). When present, it, not `start(sim)`, must be a year the", - "climate data cover."), + expectsInput("climateYearRecord", "data.table", + desc = paste("Optional, for rerunning this module on a finished run whose simulation years", + "are not calendar years (e.g. NRV): that run's record (`simYear`, `climateYear`)", + "of the climate year used in each simulation year, from the `climateYear` module.", + "When supplied, those climate years, not `times`, are checked against the years", + "this module prepares. In a normal run `climateYear` writes it after this", + "module's `init`, so it is not read."), sourceURL = NA), expectsInput("rasterToMatch", "SpatRaster", desc = "template raster corresponding to `studyArea`.", sourceURL = NA), @@ -156,20 +158,29 @@ Init <- function(sim) { ## `projectedClimateYears`, so the run's start must fall within those. A supplied ## `climateVariables` has years this module cannot read, so only calendar years are required. ## (`.inputObjects` sets the flag; it does not run when every input was supplied.) - ## A run whose years are not calendar years (NRV) maps them to climate years (`climateYear` - ## module); then the climate year it is at is what must be a calendar year. + ## A rerun of a finished run in model years (NRV) supplies that run's `climateYearRecord`; the + ## climate years it used for these times are what this module must serve. In a normal run the + ## record does not exist yet here (`climateYear` writes it, after this `init`; see `loadOrder`). fromParams <- isTRUE(mod$climateVariablesFromParams) - yrs <- if (is.null(sim$climateYear)) c(start(sim), end(sim)) else rep(sim$climateYear, 2) - checkCalendarYears(yrs[1], yrs[2], module = "canClimateData", - years = if (fromParams) - c(P(sim)$historicalClimateYears, P(sim)$projectedClimateYears), - hint = if (!is.null(sim$climateYear)) { - "That is `climateYear`, the climate year this run is at." - } else if (fromParams) { - "Set `times` inside those years, or change `historicalClimateYears`/`projectedClimateYears`." - } else { - "`climateVariables` was supplied, so its years are not known here: set `times` to calendar years." - }) + rec <- sim$climateYearRecord + if (NROW(rec)) { + used <- unique(rec$climateYear[rec$simYear >= start(sim) & rec$simYear <= end(sim)]) + missingYrs <- if (fromParams) + setdiff(used, c(P(sim)$historicalClimateYears, P(sim)$projectedClimateYears)) + if (length(missingYrs)) + stop("canClimateData: `climateYearRecord` uses climate years ", paste(sort(missingYrs), collapse = ", "), + " for times ", start(sim), "-", end(sim), ", which are not in `historicalClimateYears`/", + "`projectedClimateYears`. Add them, or supply `climateVariables` with those years.", call. = FALSE) + } else { + checkCalendarYears(start(sim), end(sim), module = "canClimateData", + years = if (fromParams) + c(P(sim)$historicalClimateYears, P(sim)$projectedClimateYears), + hint = if (fromParams) { + "Set `times` inside those years, or change `historicalClimateYears`/`projectedClimateYears`." + } else { + "`climateVariables` was supplied, so its years are not known here: set `times` to calendar years." + }) + } stopifnot(P(sim)$projectedType %in% c("forecast", "hindcast")) ## separate intermediate outputs from raw inputs, to reduce file conflicts on shared drives diff --git a/tests/testthat/test-calendarYears.R b/tests/testthat/test-calendarYears.R index cc0c476..cc948f6 100644 --- a/tests/testthat/test-calendarYears.R +++ b/tests/testthat/test-calendarYears.R @@ -23,18 +23,21 @@ test_that("init stops when the run starts before the climate years this module i "times are model years 1950-2020.*cover 1991-2100.*historicalClimateYears") }) -test_that("with a climateYear (a run in model years, e.g. NRV), the climate year is checked, not start(sim)", { +test_that("a rerun with the run's climateYearRecord checks the climate years it used, not times", { rtm <- terra::rast(nrows = 2, ncols = 2, vals = 1L, crs = "EPSG:3978") sa <- sf::st_as_sf(terra::as.polygons(rtm)) - run <- function(climateYear) { + rec <- data.table::data.table(simYear = c(2719, 2720, 2721), climateYear = c(2001, 1987, 2001)) + run <- function(objs) { sim <- suppressMessages(SpaDES.core::simInit( - times = list(start = 2720, end = 2820), modules = moduleName, paths = testPaths, - objects = list(studyArea = sa, rasterToMatch = rtm, climateVariables = list(dummy = list()), - climateYear = climateYear))) + times = list(start = 2720, end = 2720), modules = moduleName, paths = testPaths, + params = list(canClimateData = list(historicalClimateYears = 1991:2022, projectedClimateYears = integer(0))), + objects = c(list(studyArea = sa, rasterToMatch = rtm, climateYearRecord = rec), objs))) tryCatch({suppressMessages(SpaDES.core::spades(sim, debug = FALSE)); ""}, error = function(e) conditionMessage(e)) } - ## stops later, on the dummy climateVariables, but not on the years - expect_false(grepl("model years", run(2014))) - expect_match(run(1800), "model years 1800-1800") + ## built from params: 1987 (the climate year of 2720 only) is not among them + expect_match(run(list()), "climate years 1987 for times 2720-2720") + ## supplied climateVariables: years not known here, so no year check (it stops later, on the dummy) + err <- run(list(climateVariables = list(dummy = list()))) + expect_false(grepl("climate years|model years", err)) }) diff --git a/tests/testthat/test-loadOrder.R b/tests/testthat/test-loadOrder.R index 12ec7c7..19e2915 100644 --- a/tests/testthat/test-loadOrder.R +++ b/tests/testthat/test-loadOrder.R @@ -1,4 +1,4 @@ -## This module reads `climateYear` (from the climateYear module), and climateYear reads this +## This module reads `climateYearRecord` (from the climateYear module), and climateYear reads this ## module's climate rasters: a cycle, which SpaDES resolves with climateYear's init first. ## The `loadOrder` metadata keeps this module's init first, in either module order. The stub ## has climateYear's inputs, output and loadOrder; without this module's loadOrder it fails. @@ -15,7 +15,7 @@ test_that("init is scheduled before climateYear's, in either module order", { ' reqdPkgs = list(), parameters = rbind(defineParameter(".useCache", "logical", FALSE, NA, NA, "stub")),', ' inputObjects = bindrows(expectsInput("historicalClimateRasters", "list", "stub"),', ' expectsInput("projectedClimateRasters", "list", "stub")),', - ' outputObjects = createsOutput("climateYear", "numeric", "stub")))', + ' outputObjects = createsOutput("climateYearRecord", "data.table", "stub")))', 'doEvent.climateYear <- function(sim, eventTime, eventType) sim'), file.path(mp, "climateYear", "climateYear.R")) for (mods in list(c(moduleName, "climateYear"), c("climateYear", moduleName))) { diff --git a/tests/testthat/test-metadata.R b/tests/testthat/test-metadata.R index 30b62c3..0fe5b54 100644 --- a/tests/testthat/test-metadata.R +++ b/tests/testthat/test-metadata.R @@ -18,7 +18,7 @@ test_that("inputs are the expected names and classes", { expect_identical( inputs[order(names(inputs))], c(climateVariables = "list", - climateYear = "numeric", + climateYearRecord = "data.table", rasterToMatch = "SpatRaster", studyArea = "sf") ) From 7d1272a9a9a2a4aecdb9da47d6d52a2259008351 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Thu, 12 Nov 2026 16:23:46 -0700 Subject: [PATCH 07/15] Rerun: prepare the climate years the record holds for the simulation years inputs(sim) loads at climateVarsForRecord() replaces the years of each climateVariables element with the climateYearRecord's climate years for rerunSimYears() (the load times of inputs(sim) within times; alreadyRun loads the finished run's outputs at their save times). Normals and calcCumMDC (consecutive years) keep theirs. Replayed 6.6.2_NRV_370_1 with a bird-like module, times 2720-3020: load times 2720, 2820, 2920, 3020 -> climate years 1991, 2002, 2013, 2014. Co-Authored-By: Claude Opus 5.5 --- NEWS.md | 2 +- canClimateData.R | 57 +++++++++++++++++++++-------- tests/testthat/test-calendarYears.R | 53 +++++++++++++++++++-------- 3 files changed, 80 insertions(+), 32 deletions(-) diff --git a/NEWS.md b/NEWS.md index 037e111..36e6425 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # canClimateData (development version) -- Rerunning this module on a finished run whose years are not calendar years (NRV) no longer stops on the year check. When that run's `climateYearRecord` (from the climateYear module) is supplied, `init` checks the climate years it recorded for `times` against `historicalClimateYears`/`projectedClimateYears` (when this module builds `climateVariables`), not `times` itself. `climateYearRecord` is a new optional input; in a normal run climateYear writes it after this module's `init`, and `loadOrder` keeps that order. +- Rerunning this module on a finished run whose years are not calendar years (NRV), with that run's `climateYearRecord` (from the climateYear module), now prepares the climate years the record holds for the simulation years the rerun serves (the load times of its inputs, `inputs(sim)`, which `alreadyRun` sets to the finished run's save times), not the years in `climateVariables` or `historicalClimateYears`/`projectedClimateYears`. Variables by period, and `calcCumMDC` ones (which need consecutive years), keep their years. `times` are not checked as calendar years then. `climateYearRecord` is a new optional input; in a normal run climateYear writes it after this module's `init`, and `loadOrder` keeps that order. - `climateData` is now required from its modsForFireSense branch (>= 2.2.3.9011). `checkCalendarYears()` is only there; climateData development reached 2.2.3.9011 without it, so the old floor installed a climateData whose `init` failed with "could not find function". - `projectedClimateYears` now defaults to 2017:2100 instead of 2011:2100. The projected archive for tile 39 (CNRM-ESM2-1 ssp370) has no 2013-2016 files, and observed climate now covers 1901-2024, so projections before 2017 are not needed. - `init` now stops, before preparing any climate data, when the run's start is outside the climate years this module is asked for (`historicalClimateYears` and `projectedClimateYears`, 1991 to 2100 by default), for example the model years 0-10 that `setupProject()` gives without `times`. With a supplied `climateVariables`, whose years are not known here, it stops when the start is not a calendar year from 1901 to 2100. The check is `climateData::checkCalendarYears()` (climateData >= 2.2.3.9009); the message says how to proceed. The run may end after the last year. diff --git a/canClimateData.R b/canClimateData.R index 6ad7505..dc6999d 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -153,25 +153,50 @@ climateRastersToRewrite <- function(projectedType) { if (identical(projectedType, "hindcast")) "projected" else character(0) } +## The simulation years a rerun serves: the load times of its inputs (`inputs(sim)`; `alreadyRun` +## loads each saved output of the finished run at its save time) within `start`-`end`; all of +## `start`-`end` if there are none. +rerunSimYears <- function(inputs, start, end) { + lt <- as.numeric(inputs$loadTime) + yrs <- sort(unique(floor(lt[!is.na(lt) & lt >= start & lt <= end]))) + if (length(yrs)) yrs else seq(floor(start), floor(end)) +} + +## `climateVariables` with the years of each element replaced by the climate years `record` +## (`simYear`, `climateYear`) holds for `simYears`: historical up to the latest historical year, +## projected after. Elements by period (normals) are left alone, and so are those whose `fun` needs +## consecutive years from their own first year (`calcCumMDC`: each year starts from the previous +## October's drought code), whose values would otherwise differ from the finished run's. +climateVarsForRecord <- function(climateVariables, record, simYears) { + missingYrs <- setdiff(simYears, record$simYear) + if (length(missingYrs)) + stop("canClimateData: `climateYearRecord` has no climate year for simulation year(s) ", + paste(missingYrs, collapse = ", "), call. = FALSE) + climYrs <- sort(unique(record$climateYear[record$simYear %in% simYears])) + latest <- latestHistoricalYear() + lapply(climateVariables, function(v) { + if (identical(v$fun, quote(calcCumMDC))) return(v) + if (!is.null(v$.dots$historical_years)) v$.dots$historical_years <- climYrs[climYrs <= latest] + if (!is.null(v$.dots$future_years)) v$.dots$future_years <- climYrs[climYrs > latest] + v + }) +} + Init <- function(sim) { - ## When this module builds `climateVariables` it fetches `historicalClimateYears` and - ## `projectedClimateYears`, so the run's start must fall within those. A supplied - ## `climateVariables` has years this module cannot read, so only calendar years are required. - ## (`.inputObjects` sets the flag; it does not run when every input was supplied.) - ## A rerun of a finished run in model years (NRV) supplies that run's `climateYearRecord`; the - ## climate years it used for these times are what this module must serve. In a normal run the - ## record does not exist yet here (`climateYear` writes it, after this `init`; see `loadOrder`). - fromParams <- isTRUE(mod$climateVariablesFromParams) + ## A rerun of a finished run in model years (NRV) supplies that run's `climateYearRecord`: the + ## climate years that run used at the times its outputs are loaded here, and only those, are + ## prepared, whatever years `climateVariables` names. In a normal run the record does not exist yet + ## here (`climateYear` writes it, after this `init`; see `loadOrder`), so it is not read. + climateVars <- sim$climateVariables rec <- sim$climateYearRecord if (NROW(rec)) { - used <- unique(rec$climateYear[rec$simYear >= start(sim) & rec$simYear <= end(sim)]) - missingYrs <- if (fromParams) - setdiff(used, c(P(sim)$historicalClimateYears, P(sim)$projectedClimateYears)) - if (length(missingYrs)) - stop("canClimateData: `climateYearRecord` uses climate years ", paste(sort(missingYrs), collapse = ", "), - " for times ", start(sim), "-", end(sim), ", which are not in `historicalClimateYears`/", - "`projectedClimateYears`. Add them, or supply `climateVariables` with those years.", call. = FALSE) + climateVars <- climateVarsForRecord(climateVars, rec, rerunSimYears(inputs(sim), start(sim), end(sim))) } else { + ## When this module builds `climateVariables` it fetches `historicalClimateYears` and + ## `projectedClimateYears`, so the run's start must fall within those. A supplied + ## `climateVariables` has years this module cannot read, so only calendar years are required. + ## (`.inputObjects` sets the flag; it does not run when every input was supplied.) + fromParams <- isTRUE(mod$climateVariablesFromParams) checkCalendarYears(start(sim), end(sim), module = "canClimateData", years = if (fromParams) c(P(sim)$historicalClimateYears, P(sim)$projectedClimateYears), @@ -225,7 +250,7 @@ Init <- function(sim) { SSP <- P(sim)$climateSSP climateRasters <- prepClimateLayers( - climateVarsList = sim$climateVariables, + climateVarsList = climateVars, srcdir = climatePath, ## 'src' is the place for raw inputs, downloaded from Google Drive dstdir = climatePathOut, ## 'dst' is the place for intermediate + final outputs gcm = GCM, diff --git a/tests/testthat/test-calendarYears.R b/tests/testthat/test-calendarYears.R index cc948f6..f408c05 100644 --- a/tests/testthat/test-calendarYears.R +++ b/tests/testthat/test-calendarYears.R @@ -23,21 +23,44 @@ test_that("init stops when the run starts before the climate years this module i "times are model years 1950-2020.*cover 1991-2100.*historicalClimateYears") }) -test_that("a rerun with the run's climateYearRecord checks the climate years it used, not times", { +test_that("a rerun serves the simulation years its inputs load at (inputs(sim)), within times", { + inp <- data.frame(objectName = c("a", "b", "a", "a", "a", "a"), + loadTime = c(2720, 2720, 2820, 2920, 3020, 3120)) + expect_identical(rerunSimYears(inp, 2720, 3020), c(2720, 2820, 2920, 3020)) + expect_identical(rerunSimYears(inp, 2720, 2720), 2720) + ## no inputs: every year of times + expect_equal(rerunSimYears(data.frame(loadTime = numeric(0)), 2720, 2722), c(2720, 2721, 2722)) +}) + +test_that("a rerun prepares only the climate years the record holds for those simulation years", { + latest <- climateData::latestHistoricalYear() + rec <- data.table::data.table(simYear = 2719:2821, + climateYear = c(1990, 2001, rep(1995, 99), 1987, latest + 5)) + cv <- list( + historical_CMD = list(vars = "historical_CMD", fun = quote(calcAsIs), .dots = list(historical_years = 1986:2024)), + historical_CMI_normal = list(vars = "historical_CMI_normal", fun = quote(calcAsIs), + .dots = list(historical_period = "1981_2010")), + historical_cumMDC = list(vars = "historical_PPT01", fun = quote(calcCumMDC), .dots = list(historical_years = 1981:2024)), + projected_MDC = list(vars = "future_PPT04", fun = quote(calcMDC), .dots = list(future_years = 2017:2100))) + out <- climateVarsForRecord(cv, rec, c(2720, 2820, 2821)) + expect_identical(out$historical_CMD$.dots$historical_years, c(1987, 2001)) + expect_identical(out$projected_MDC$.dots$future_years, latest + 5) + ## by period, and consecutive-year (calcCumMDC), left alone + expect_identical(out$historical_CMI_normal, cv$historical_CMI_normal) + expect_identical(out$historical_cumMDC, cv$historical_cumMDC) + expect_error(climateVarsForRecord(cv, rec, c(2720, 2900)), "no climate year for simulation year\\(s\\) 2900") +}) + +test_that("with a climateYearRecord, init does not check times (model years) against calendar years", { rtm <- terra::rast(nrows = 2, ncols = 2, vals = 1L, crs = "EPSG:3978") sa <- sf::st_as_sf(terra::as.polygons(rtm)) - rec <- data.table::data.table(simYear = c(2719, 2720, 2721), climateYear = c(2001, 1987, 2001)) - run <- function(objs) { - sim <- suppressMessages(SpaDES.core::simInit( - times = list(start = 2720, end = 2720), modules = moduleName, paths = testPaths, - params = list(canClimateData = list(historicalClimateYears = 1991:2022, projectedClimateYears = integer(0))), - objects = c(list(studyArea = sa, rasterToMatch = rtm, climateYearRecord = rec), objs))) - tryCatch({suppressMessages(SpaDES.core::spades(sim, debug = FALSE)); ""}, - error = function(e) conditionMessage(e)) - } - ## built from params: 1987 (the climate year of 2720 only) is not among them - expect_match(run(list()), "climate years 1987 for times 2720-2720") - ## supplied climateVariables: years not known here, so no year check (it stops later, on the dummy) - err <- run(list(climateVariables = list(dummy = list()))) - expect_false(grepl("climate years|model years", err)) + rec <- data.table::data.table(simYear = 2720, climateYear = 1987) + sim <- suppressMessages(SpaDES.core::simInit( + times = list(start = 2720, end = 2720), modules = moduleName, paths = testPaths, + objects = list(studyArea = sa, rasterToMatch = rtm, climateVariables = list(dummy = list()), + climateYearRecord = rec))) + err <- tryCatch({suppressMessages(SpaDES.core::spades(sim, debug = FALSE)); ""}, + error = function(e) conditionMessage(e)) + ## stops later, on the dummy climateVariables, not on the years + expect_false(grepl("model years|climate year", err)) }) From 459b77faacd585e2db5324522ecd353e28a3a809 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 00:32:06 +0000 Subject: [PATCH 08/15] Re-build canClimateData.Rmd --- canClimateData.md | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/canClimateData.md b/canClimateData.md index a13b009..6256332 100644 --- a/canClimateData.md +++ b/canClimateData.md @@ -1,7 +1,7 @@ --- title: "canClimateData Manual" -subtitle: "v.1.0.3" -date: "Last updated: 2024-07-29" +subtitle: "v.1.1.0.9000" +date: "Last updated: 2026-11-14" output: bookdown::html_document2: toc: true @@ -47,7 +47,7 @@ Currently supports study areas across Canada, for some CMIP6 climate scenarios ( **Available data sets:** - + ``` r @@ -64,7 +64,7 @@ available("historical")[["years"]] ## [76] 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 ## [91] 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 ## [106] 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 -## [121] 2021 2022 +## [121] 2021 2022 2023 2024 ``` ``` r @@ -110,7 +110,7 @@ Table \@ref(tab:moduleInputs-canClimateData) shows the full list of module input See `?climateData::prepClimateLayers` for examples constructing a custom `climateVariables` object to use to add arbitrary climate variables to the output lists of climate rasters. - +
@@ -124,7 +124,13 @@ See `?climateData::prepClimateLayers` for examples constructing a custom `climat - + + + + + + + @@ -147,7 +153,7 @@ See `?climateData::prepClimateLayers` for examples constructing a custom `climat Table \@ref(tab:moduleParams-canClimateData) shows the full list of module parameters. -
(\#tab:moduleInputs-canClimateData)(\#tab:moduleInputs-canClimateData)List of (ref:canClimateData) input objects and their description.
climateVariables list a list, named by climate variable using 'projected_' or 'historical_' prefixes, with each list element containing a list of three arguments: vars - the raw variables used to derive the target variable, fun - the quoted function used to derive the target variable, where 'quote(calcAsIs)' denotes target variables that ARE the raw variable, and dots - additional arguments passed to 'fun'. See the .inputObjects for examples of how to build this object and ?climateData::prepClimateLayers for how it is used . The GCM, SSP, and selected years, whether projected or historical, are set by module parameters and must be identical for all variables a list, named by climate variable using `'projected_'` or `'historical_'` prefixes, with each list element containing a list of three arguments: `vars` - the raw variables used to derive the target variable; `fun` - the quoted function used to derive the target variable, where `'quote(calcAsIs)'` denotes target variables that ARE the raw variable; and `dots` - additional arguments passed to `fun`. See `.inputObjects` for examples of how to build this object, and `?climateData::prepClimateLayers` for how it is used. The GCM, SSP, and selected years, whether projected or historical, are set by module parameters and must be identical for all variables. See also <https://climatena.ca/Help2#_var> for all available climate variables. NA
climateYearRecord data.table Optional, for rerunning this module on a finished run whose simulation years are not calendar years (e.g. NRV): that run's record (`simYear`, `climateYear`) of the climate year used in each simulation year, from the `climateYear` module. When supplied, those climate years, not `times`, are checked against the years this module prepares. In a normal run `climateYear` writes it after this module's `init`, so it is not read. NA
+
@@ -157,6 +163,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -167,6 +174,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -175,6 +183,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -183,6 +192,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -191,6 +201,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -199,6 +210,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -207,6 +219,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -215,14 +228,16 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + - + - + + @@ -231,6 +246,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -239,6 +255,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -247,6 +264,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -255,6 +273,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -263,6 +282,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -271,6 +291,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -279,6 +300,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param + @@ -287,6 +309,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param +
(\#tab:moduleParams-canClimateData)(\#tab:moduleParams-canClimateData)List of (ref:canClimateData) parameters and their description.
min max paramDesc cacheKey
NA NA Distance (m) to buffer `studyArea` and `rasterToMatch` to mitigate edge effects for simulation. TRUE
climateGCM NA NA Global Circulation Model to use for climate projections: currently 'CanESM5' or 'CNRM-ESM2-1'. TRUE
climateSSP NA NA SSP emissions scenario for `climateGCM`: one of 245, 370, or 585. TRUE
historicalClimatePeriod NA NA period to use for historical climate normals if `climateVariables` not supplied. TRUE
historicalClimateYears NA NA range of years captured by the historical climate data if `climateVariables` not supplied. TRUE
outputDir NA NA Directory path for prepared climate data rasters. User should specify a shared directory (e.g., when running multiple simulation replicates) to avoid multiple copies of the climate data. If not specified by the user, a subdirectory of the simulation output directory will be used (i.e., `file.path(outputPath(sim), 'climate')`. TRUE
projectedClimatePeriod NA NA period to use for projected climate normals if `climateVariables` not supplied. TRUE
projectedClimateYears numeric 2011, 20.... 2017, 20.... NA NA range of years captured by the projected climate data if `climateVariables` not supplied. range of years captured by the projected climate data if `climateVariables` not supplied. Starts in 2017 because the projected archive for tile 39 (CNRM-ESM2-1 ssp370) lacks 2013-2016, and observed climate now covers 1901-2024, so earlier projections are not needed. TRUE
projectedType NA NA one of 'forecast' or 'hindcast' to prepare either projected future, or sampled historical data for hindcast studies, respectively. TRUE
quickCheck NA NA `prepClimateData` uses `prepInputs` internally; set this to `TRUE` to avoid the slow process of digesting potentially MANY files. This will use `file.size` only, if `TRUE`. TRUE
.studyAreaName NA NA User-defined label for the current study area. If `NA`, a hash of `studyArea` will be used. TRUE
.plotInitialTime NA NA Describes the simulation time at which the first plot event should occur. TRUE
.plotInterval NA NA Describes the simulation time interval between plot events. TRUE
.saveInitialTime NA NA Describes the simulation time at which the first save event should occur. TRUE
.saveInterval NA NA This describes the simulation time interval between save events. TRUE
.useCache NA NA Should this entire module be run with caching activated? This is generally intended for data-type modules, where stochasticity and time are not relevant. TRUE
@@ -299,7 +322,7 @@ This module consists of a single `init` event that performs all data preparation Description of the module outputs (Table \@ref(tab:moduleOutputs-canClimateData)). - +
From 47128a49ae1f9e900032ad7851a11fab7b089dfe Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Mon, 16 Nov 2026 12:43:17 -0700 Subject: [PATCH 09/15] Leave outputDir out of the event cache keys (defineParameter cacheKey = FALSE) A path or core count that differs between machines made the same run a cache miss on another machine. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6 --- NEWS.md | 1 + canClimateData.R | 5 +++-- tests/testthat/test-metadata.R | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index ffc2cbf..9f60f67 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # canClimateData (development version) +- `outputDir` is no longer part of the module's event cache keys (`defineParameter(cacheKey = FALSE)`; SpaDES.core >= 3.2.1.9047). It only says where the prepared climate files go, and `Init()` already left it out of the `prepClimateLayers()` key, so a cache built on one machine can match on another with a different folder. The event cache keys of this module change once. - Rerunning this module on a finished run whose years are not calendar years (NRV), with that run's `climateYearRecord` (from the climateYear module), now prepares the climate years the record holds for the simulation years the rerun serves (the load times of its inputs, `inputs(sim)`, which `alreadyRun` sets to the finished run's save times), not the years in `climateVariables` or `historicalClimateYears`/`projectedClimateYears`. Variables by period, and `calcCumMDC` ones (which need consecutive years), keep their years. `times` are not checked as calendar years then. `climateYearRecord` is a new optional input; in a normal run climateYear writes it after this module's `init`, and `loadOrder` keeps that order. - `climateData` is now required from its modsForFireSense branch (>= 2.2.3.9011). `checkCalendarYears()` is only there; climateData development reached 2.2.3.9011 without it, so the old floor installed a climateData whose `init` failed with "could not find function". - `projectedClimateYears` now defaults to 2017:2100 instead of 2011:2100. The projected archive for tile 39 (CNRM-ESM2-1 ssp370) has no 2013-2016 files, and observed climate now covers 1901-2024, so projections before 2017 are not needed. diff --git a/canClimateData.R b/canClimateData.R index fc077a8..87e7ab0 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -25,7 +25,7 @@ defineModule(sim, list( "PredictiveEcology/fireSenseUtils@development (>= 0.0.5.9046)", "PredictiveEcology/LandR@development (>= 1.1.0.9064)", "PredictiveEcology/reproducible@development (>= 3.2.1.9060)", - "PredictiveEcology/SpaDES.core@development (>= 2.1.5)", + "PredictiveEcology/SpaDES.core@development (>= 3.2.1.9047)", # defineParameter(cacheKey = FALSE) "PredictiveEcology/SpaDES.tools@development (>= 2.0.4.9002)"), parameters = rbind( defineParameter("bufferDist", "numeric", 20000, NA, NA, @@ -48,7 +48,8 @@ defineModule(sim, list( "(e.g., when running multiple simulation replicates)", "to avoid multiple copies of the climate data.", "If not specified by the user, a subdirectory of the simulation output", - "directory will be used (i.e., `file.path(outputPath(sim), 'climate')`.")), + "directory will be used (i.e., `file.path(outputPath(sim), 'climate')`."), + cacheKey = FALSE), # only where the files go: `prepClimateLayers()` leaves `dstdir` out of its key too defineParameter("projectedClimatePeriod", "character", NULL, NA, NA, paste("period to use for projected climate normals", "if `climateVariables` not supplied.")), diff --git a/tests/testthat/test-metadata.R b/tests/testthat/test-metadata.R index 0fe5b54..c5b78df 100644 --- a/tests/testthat/test-metadata.R +++ b/tests/testthat/test-metadata.R @@ -51,3 +51,11 @@ test_that("projected climate years start in 2017", { pars <- stats::setNames(md$parameters$default, md$parameters$paramName) expect_identical(pars[["projectedClimateYears"]], 2017:2100) }) + +test_that("`outputDir` is not part of the module's cache keys", { + ## it only says where the prepared climate files go (`Init()` leaves `dstdir` out of the + ## `prepClimateLayers()` key too), so a cache built on one machine can match on another + p <- SpaDES.core::moduleMetadata(module = moduleName, path = modulePath)$parameters + expect_false(p$cacheKey[p$paramName == "outputDir"]) + expect_true(all(p$cacheKey[p$paramName != "outputDir"])) +}) From af7472bc797c6f4f0ef32e41138b51bdbae14374 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Mon, 16 Nov 2026 13:04:10 -0700 Subject: [PATCH 10/15] outputDir: pass asPath(dir, nParentDirs) to key the event on the folder's last components; drop cacheKey = FALSE An outputDir that is a shared hindcast climate folder must still miss for another folder, as a hit writes nothing there. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6 --- NEWS.md | 2 +- canClimateData.R | 11 +++++-- tests/testthat/test-metadata.R | 8 ----- tests/testthat/test-outputDirKey.R | 49 ++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 tests/testthat/test-outputDirKey.R diff --git a/NEWS.md b/NEWS.md index 9f60f67..ded1241 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # canClimateData (development version) -- `outputDir` is no longer part of the module's event cache keys (`defineParameter(cacheKey = FALSE)`; SpaDES.core >= 3.2.1.9047). It only says where the prepared climate files go, and `Init()` already left it out of the `prepClimateLayers()` key, so a cache built on one machine can match on another with a different folder. The event cache keys of this module change once. +- `outputDir` may be a `reproducible::asPath(dir, nParentDirs)`: the event cache keys then hold only the last `nParentDirs + 1` components of the folder, so a cache built on one machine matches on another where the folder has a different prefix, while a different folder (e.g. another hindcast) still gives a different key. A plain path is keyed in full, as before. Nothing in the module changed; the parameter description says how to pass it. - Rerunning this module on a finished run whose years are not calendar years (NRV), with that run's `climateYearRecord` (from the climateYear module), now prepares the climate years the record holds for the simulation years the rerun serves (the load times of its inputs, `inputs(sim)`, which `alreadyRun` sets to the finished run's save times), not the years in `climateVariables` or `historicalClimateYears`/`projectedClimateYears`. Variables by period, and `calcCumMDC` ones (which need consecutive years), keep their years. `times` are not checked as calendar years then. `climateYearRecord` is a new optional input; in a normal run climateYear writes it after this module's `init`, and `loadOrder` keeps that order. - `climateData` is now required from its modsForFireSense branch (>= 2.2.3.9011). `checkCalendarYears()` is only there; climateData development reached 2.2.3.9011 without it, so the old floor installed a climateData whose `init` failed with "could not find function". - `projectedClimateYears` now defaults to 2017:2100 instead of 2011:2100. The projected archive for tile 39 (CNRM-ESM2-1 ssp370) has no 2013-2016 files, and observed climate now covers 1901-2024, so projections before 2017 are not needed. diff --git a/canClimateData.R b/canClimateData.R index 87e7ab0..64628a6 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -25,7 +25,7 @@ defineModule(sim, list( "PredictiveEcology/fireSenseUtils@development (>= 0.0.5.9046)", "PredictiveEcology/LandR@development (>= 1.1.0.9064)", "PredictiveEcology/reproducible@development (>= 3.2.1.9060)", - "PredictiveEcology/SpaDES.core@development (>= 3.2.1.9047)", # defineParameter(cacheKey = FALSE) + "PredictiveEcology/SpaDES.core@development (>= 2.1.5)", "PredictiveEcology/SpaDES.tools@development (>= 2.0.4.9002)"), parameters = rbind( defineParameter("bufferDist", "numeric", 20000, NA, NA, @@ -48,8 +48,13 @@ defineModule(sim, list( "(e.g., when running multiple simulation replicates)", "to avoid multiple copies of the climate data.", "If not specified by the user, a subdirectory of the simulation output", - "directory will be used (i.e., `file.path(outputPath(sim), 'climate')`."), - cacheKey = FALSE), # only where the files go: `prepClimateLayers()` leaves `dstdir` out of its key too + "directory will be used (i.e., `file.path(outputPath(sim), 'climate')`.", + "Event cache keys hold this value as given, so a different folder", + "is a different key, and a machine-specific prefix is part of it.", + "To let the same folder match on another machine, pass", + "`reproducible::asPath(dir, nParentDirs)`: the key then holds only", + "`dir`'s last `nParentDirs + 1` components, e.g.", + "`asPath(dir, 2)` for `//climate`.")), defineParameter("projectedClimatePeriod", "character", NULL, NA, NA, paste("period to use for projected climate normals", "if `climateVariables` not supplied.")), diff --git a/tests/testthat/test-metadata.R b/tests/testthat/test-metadata.R index c5b78df..0fe5b54 100644 --- a/tests/testthat/test-metadata.R +++ b/tests/testthat/test-metadata.R @@ -51,11 +51,3 @@ test_that("projected climate years start in 2017", { pars <- stats::setNames(md$parameters$default, md$parameters$paramName) expect_identical(pars[["projectedClimateYears"]], 2017:2100) }) - -test_that("`outputDir` is not part of the module's cache keys", { - ## it only says where the prepared climate files go (`Init()` leaves `dstdir` out of the - ## `prepClimateLayers()` key too), so a cache built on one machine can match on another - p <- SpaDES.core::moduleMetadata(module = moduleName, path = modulePath)$parameters - expect_false(p$cacheKey[p$paramName == "outputDir"]) - expect_true(all(p$cacheKey[p$paramName != "outputDir"])) -}) diff --git a/tests/testthat/test-outputDirKey.R b/tests/testthat/test-outputDirKey.R new file mode 100644 index 0000000..8bb8bf9 --- /dev/null +++ b/tests/testthat/test-outputDirKey.R @@ -0,0 +1,49 @@ +## `outputDir` is part of the event cache keys, so an absolute path with a machine-specific prefix +## (the hindcast climate folder, /outputs/hindcast//climate) made a cache built +## on one machine miss on another. `outputDir` may be `reproducible::asPath(dir, nParentDirs)`, which +## the key holds as only `dir`'s last `nParentDirs + 1` components. A different folder must still miss: +## a hit writes nothing into the new folder. + +test_that("Init() uses a Path outputDir as the folder the climate files go to", { + withr::local_options(reproducible.useCache = FALSE, reproducible.useNewDigestAlgorithm = 2) + root <- withr::local_tempdir() + dir <- file.path(root, "outputs", "hindcastX", "9.1", "climate") + sim <- runInit(path = withr::local_tempdir(), params = list(outputDir = reproducible::asPath(dir, 2))) + expect_true(all(startsWith(normalizePath(terra::sources(sim$historicalClimateRasters[[1]])), + normalizePath(dir)))) +}) + +## a module with this module's parameter and a cached init, to read the key from the cache +writeKeyModule <- function(modulePath) { + dir.create(file.path(modulePath, "m"), recursive = TRUE) + cat(file = file.path(modulePath, "m", "m.R"), sep = "", ' +defineModule(sim, list(name = "m", description = "", keywords = "", authors = person("A", "B"), + childModules = character(0), version = list(m = "0.0.1"), timeframe = as.POSIXlt(c(NA, NA)), + timeunit = "year", citation = list(), documentation = list(), reqdPkgs = list(), + parameters = rbind( + defineParameter("outputDir", "character", NA_character_, NA, NA, "d"), + defineParameter(".useCache", "character", "init", NA, NA, "c")), + inputObjects = bindrows(), outputObjects = bindrows())) +doEvent.m <- function(sim, eventTime, eventType, debug = FALSE) invisible(sim) +') +} + +test_that("a Path outputDir keys the event on its last components: same under another base, different for another folder", { + skip_if_not_installed("SpaDES.core") + withr::local_options(spades.loadReqdPkgs = FALSE, spades.moduleCodeChecks = FALSE, spades.useRequire = FALSE, + reproducible.useMemoise = FALSE, spades.saveSimOnExit = FALSE) + modulePath <- withr::local_tempdir(); cachePath <- withr::local_tempdir() + writeKeyModule(modulePath) + nKeys <- function(outputDir) { + s <- suppressMessages(SpaDES.core::simInit(modules = "m", times = list(start = 0, end = 1), + params = list(m = list(outputDir = outputDir)), + paths = list(modulePath = modulePath, cachePath = cachePath))) + suppressMessages(SpaDES.core::spades(s, debug = FALSE)) + length(unique(reproducible::showCache(cachePath, verbose = -2)$cacheId)) + } + asP <- function(base, hindcast) reproducible::asPath(file.path(base, "outputs", hindcast, "9.1", "climate"), 2) + expect_identical(nKeys(asP("/machineA", "hindcastX")), 1L) + expect_identical(nKeys(asP("/other/machineB", "hindcastX")), 1L) # same relative folder: a hit + expect_identical(nKeys(asP("/machineA", "hindcastY")), 2L) # another folder: a miss + expect_identical(nKeys(file.path("/machineA", "outputs", "hindcastX", "9.1", "climate")), 3L) # a plain path is keyed in full +}) From ae6cd24e8027524f60414f024cce97cf34a1d753 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Mon, 16 Nov 2026 13:15:12 -0700 Subject: [PATCH 11/15] Bump to 1.1.1.9001 (after #33) [skip ci] Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6 --- canClimateData.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/canClimateData.R b/canClimateData.R index 64628a6..89d2187 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -12,7 +12,7 @@ defineModule(sim, list( person("Tati", "Micheletti", email = "tati.micheletti@gmail.com", role = "ctb") ), childModules = character(0), - version = list(canClimateData = "1.1.1.9000"), + version = list(canClimateData = "1.1.1.9001"), timeframe = as.POSIXlt(c(NA, NA)), timeunit = "year", citation = list("citation.bib"), From 0596ef6abee229279153139249429c6f1228f245 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:23:06 +0000 Subject: [PATCH 12/15] Re-build canClimateData.Rmd --- canClimateData.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/canClimateData.md b/canClimateData.md index 52975f2..ddeedc5 100644 --- a/canClimateData.md +++ b/canClimateData.md @@ -1,7 +1,7 @@ --- title: "canClimateData Manual" subtitle: "v.1.1.1.9000" -date: "Last updated: 2026-11-14" +date: "Last updated: 2026-11-16" output: bookdown::html_document2: toc: true @@ -218,7 +218,7 @@ Table \@ref(tab:moduleParams-canClimateData) shows the full list of module param - + From 604cd4b1f22be76257d0a57663d910bfdf3f7d99 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Mon, 16 Nov 2026 14:20:22 -0700 Subject: [PATCH 13/15] Require SpaDES.core >= 3.2.1.9070 (inputs(sim)$loadTime in the simulation unit, SpaDES.core#527) Co-Authored-By: Claude Opus 5.5 --- NEWS.md | 1 + canClimateData.R | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index ded1241..e66ca96 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # canClimateData (development version) +- Requires SpaDES.core >= 3.2.1.9070. A rerun reads the years it serves from `inputs(sim)$loadTime`; before SpaDES.core #527 the rows of objects passed to `simInit(objects = )` held seconds (e.g. 85836672000 for 2720), so the rerun asked the record for years it does not have. - `outputDir` may be a `reproducible::asPath(dir, nParentDirs)`: the event cache keys then hold only the last `nParentDirs + 1` components of the folder, so a cache built on one machine matches on another where the folder has a different prefix, while a different folder (e.g. another hindcast) still gives a different key. A plain path is keyed in full, as before. Nothing in the module changed; the parameter description says how to pass it. - Rerunning this module on a finished run whose years are not calendar years (NRV), with that run's `climateYearRecord` (from the climateYear module), now prepares the climate years the record holds for the simulation years the rerun serves (the load times of its inputs, `inputs(sim)`, which `alreadyRun` sets to the finished run's save times), not the years in `climateVariables` or `historicalClimateYears`/`projectedClimateYears`. Variables by period, and `calcCumMDC` ones (which need consecutive years), keep their years. `times` are not checked as calendar years then. `climateYearRecord` is a new optional input; in a normal run climateYear writes it after this module's `init`, and `loadOrder` keeps that order. - `climateData` is now required from its modsForFireSense branch (>= 2.2.3.9011). `checkCalendarYears()` is only there; climateData development reached 2.2.3.9011 without it, so the old floor installed a climateData whose `init` failed with "could not find function". diff --git a/canClimateData.R b/canClimateData.R index 89d2187..b2e8ab3 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -25,7 +25,7 @@ defineModule(sim, list( "PredictiveEcology/fireSenseUtils@development (>= 0.0.5.9046)", "PredictiveEcology/LandR@development (>= 1.1.0.9064)", "PredictiveEcology/reproducible@development (>= 3.2.1.9060)", - "PredictiveEcology/SpaDES.core@development (>= 2.1.5)", + "PredictiveEcology/SpaDES.core@development (>= 3.2.1.9070)", "PredictiveEcology/SpaDES.tools@development (>= 2.0.4.9002)"), parameters = rbind( defineParameter("bufferDist", "numeric", 20000, NA, NA, From 03b71b8b1240ab1cbfb8c7e6bb11ef30ba158506 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Mon, 16 Nov 2026 14:33:36 -0700 Subject: [PATCH 14/15] Bump to 1.1.1.9002 (after #34) [skip ci] Co-Authored-By: Claude Opus 5.5 --- canClimateData.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/canClimateData.R b/canClimateData.R index b2e8ab3..00511d8 100644 --- a/canClimateData.R +++ b/canClimateData.R @@ -12,7 +12,7 @@ defineModule(sim, list( person("Tati", "Micheletti", email = "tati.micheletti@gmail.com", role = "ctb") ), childModules = character(0), - version = list(canClimateData = "1.1.1.9001"), + version = list(canClimateData = "1.1.1.9002"), timeframe = as.POSIXlt(c(NA, NA)), timeunit = "year", citation = list("citation.bib"), From 2030c5261b962175b74660ecd690a6a96d69b7dc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 21:41:47 +0000 Subject: [PATCH 15/15] Re-build canClimateData.Rmd --- canClimateData.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/canClimateData.md b/canClimateData.md index ddeedc5..3bce21d 100644 --- a/canClimateData.md +++ b/canClimateData.md @@ -1,6 +1,6 @@ --- title: "canClimateData Manual" -subtitle: "v.1.1.1.9000" +subtitle: "v.1.1.1.9001" date: "Last updated: 2026-11-16" output: bookdown::html_document2:
(\#tab:moduleOutputs-canClimateData)(\#tab:moduleOutputs-canClimateData)List of (ref:canClimateData) outputs and their description.
NA NA NA Directory path for prepared climate data rasters. User should specify a shared directory (e.g., when running multiple simulation replicates) to avoid multiple copies of the climate data. If not specified by the user, a subdirectory of the simulation output directory will be used (i.e., `file.path(outputPath(sim), 'climate')`. Directory path for prepared climate data rasters. User should specify a shared directory (e.g., when running multiple simulation replicates) to avoid multiple copies of the climate data. If not specified by the user, a subdirectory of the simulation output directory will be used (i.e., `file.path(outputPath(sim), 'climate')`. Event cache keys hold this value as given, so a different folder is a different key, and a machine-specific prefix is part of it. To let the same folder match on another machine, pass `reproducible::asPath(dir, nParentDirs)`: the key then holds only `dir`'s last `nParentDirs + 1` components, e.g. `asPath(dir, 2)` for `<hindcast>/<ELF>/climate`. TRUE