From e6b71b5857c208d2e8ef7387337f90876ea1ae29 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Mon, 16 Nov 2026 16:16:46 -0700 Subject: [PATCH 1/2] Spread covariates for a ~ 1 spread fit: no climate layer to select Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6 --- NEWS.md | 2 ++ fireSense_dataPrepPredict.R | 26 ++++++++++++++++++-------- tests/testthat/test-covariates.R | 13 +++++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9b21cd3..3de2aeb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # fireSense_dataPrepPredict (development version) +* A hindcast or forecast with a `~ 1` spread fit (no spread climate variable, so `climateVariablesForFire$spread` is empty) stopped when the covariates were built (`terra` cannot select no layer). The spread covariate table now has `pixelID` and `youngAge` and the fuels, with no climate column; the ignition covariates are unchanged. Together with `fireSenseUtils::climateRasterToDataTable()` returning a table for no raster (PredictiveEcology/fireSenseUtils, null-arm hindcasts of `fireSense_dataPrepFit`). + * A hindcast of year Y built `youngAge` differently from the fit, for the spread and the ignition covariates: it used the cohort ages and the data year's time since disturbance as they were, and did not see a fire between the data year and Y (youngAge was 2.8% of burned pixels in ELF 6.6.2 in 2010, 1.5% in the fit). It now resolves it as `fireSense_dataPrepFit` does: the data year's time since disturbance aged to Y and every fire after it, from `fireSenseUtils::youngAgeAtYear()` (spread) and `fireSenseUtils::prepare_FuelCovsCoarseByYear()` (ignition), with the fires from `historicalFireRaster`, else `firePolysForAge` (`fireSenseUtils::firePixelsByYear()`, as the fit chooses). Fuel, non-forest land cover and treed wetland are cleared where `youngAge` is 1 in the covariate table itself (`fireSenseUtils::clearYoungAge()`, which the ignition fit uses), so a fit on log-scale fuel, for which `fireSense_spreadPredict` clears only the indicators, is right too. A hindcast with `nonForestCanBeYoungAge = FALSE` stops, as the fit does (`fireSenseUtils::stopIfNonForestCannotBeYoung()`). New inputs `firePolysForAge` and `historicalFireRaster` (from `fireSense_dataPrepFit`); a hindcast with neither stops. Hindcast covariates, and so their cache keys, change. Forecasts (a module simulates `cohortData`) are unchanged. Needs the fireSenseUtils version after PredictiveEcology/fireSenseUtils#239 merges; the `reqdPkgs` floor is set after that merge's version bump. * New parameters `replaySave` (default `FALSE`) and `replayFrom` (default `NA`): no change unless set. `replaySave = TRUE` writes, once after the first covariate build, the spread-prediction inputs that do not depend on the spread parameters to `outputPath(sim)` through SpaDES.core's `outputs()` (its `save` event): `fireSense_SpreadCovariates`, `flammableRTM`, `rasterToMatch`, `rasterToMatchELF`, `rasterToMatchLargeELF`, `studyAreaWithSpreadParams`, `nonEscapedFireSizesHa`, `ignitionFirePoints` and `firePolys` (those present), as `replay__year