From 5e370605098d1215b86d5d6a0a1d21c0b8bcf324 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Mon, 28 Sep 2026 14:39:36 -0700 Subject: [PATCH] Fix: nonflammableLCC default did not include SCANFI's rock/exposed code fireSense_dataPrepPredict.R:46 hard-coded nonflammableLCC = c(0, 20, 31, 32, 33), the NTEMS non-flammable codes, missing 30 (SCANFI's rock/exposed class). Land cover built from SCANFI by fireSenseUtils::makeFireSenseLCC() carries that code, so rock entered predictions as flammable non-forest. The default now comes from fireSenseUtils::fireSenseNonflammableLCC, the single source of truth makeFireSenseLCC() also uses (fireSenseUtils PR #103). reqdPkgs floors fireSenseUtils@development (>= 0.2.3.9060). Version 1.0.4.9005. Rmd docs re-rendered. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv --- NEWS.md | 4 ++++ fireSense_dataPrepPredict.R | 9 +++++---- fireSense_dataPrepPredict.html | 10 +++++----- fireSense_dataPrepPredict.md | 4 ++-- tests/testthat/test-nonflammableLCC.R | 25 +++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 tests/testthat/test-nonflammableLCC.R diff --git a/NEWS.md b/NEWS.md index 558e002..cf5989c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # fireSense_dataPrepPredict (development version) +- Fixed: `nonflammableLCC`'s default (`c(0, 20, 31, 32, 33)`) missed SCANFI's rock/exposed code + (`30`), so rock entered predictions as flammable non-forest. The default now comes from + `fireSenseUtils::fireSenseNonflammableLCC`, the single source of truth `makeFireSenseLCC()` + also uses. Needs `fireSenseUtils@development (>= 0.2.3.9060)`. Version 1.0.4.9005. - `prepare_SpreadPredict()` now passes `rstLCC` to `fireSenseCovariatesCreate()` (previously never passed, so `treedWetland` never appeared). It now also reads `sim$studyAreaWithSpreadParams` (the fitted SpreadFit ledger rows `fireSense_ELFs` supplies, also read undeclared by diff --git a/fireSense_dataPrepPredict.R b/fireSense_dataPrepPredict.R index f2d1de8..3a1742d 100644 --- a/fireSense_dataPrepPredict.R +++ b/fireSense_dataPrepPredict.R @@ -10,7 +10,7 @@ defineModule(sim, list( person("Alex M", "Chubaty", role = "ctb", email = "achubaty@for-cast.ca") ), childModules = character(0), - version = list(fireSense_dataPrepPredict = "1.0.4.9004"), + version = list(fireSense_dataPrepPredict = "1.0.4.9005"), timeframe = as.POSIXlt(c(NA, NA)), timeunit = "year", citation = list("citation.bib"), @@ -19,7 +19,7 @@ defineModule(sim, list( "fireSense_IgnitionFit", "fireSense_SpreadFit")), reqdPkgs = list( "data.table", - "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9057)", + "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9060)", "terra" ), parameters = rbind( @@ -43,10 +43,11 @@ defineModule(sim, list( defineParameter("igAggFactor", "numeric", 4, 1, NA, paste("Aggregation factor for the ignition and escape covariates.", "Overwritten in `init` by the value set in other modules.")), - defineParameter("nonflammableLCC", "numeric", c(0, 20, 31, 32, 33), NA, NA, + defineParameter("nonflammableLCC", "numeric", fireSenseUtils::fireSenseNonflammableLCC, NA, NA, desc = paste( "Non-flammable landcover classes, used to create `flammableRTM` and the default landcover", - "if not supplied. Defaults are water, snow/ice, rock and barren land in NTEMS LCC." + "if not supplied. The default, `fireSenseUtils::fireSenseNonflammableLCC`, is no data,", + "water, rock, snow/ice and barren land." ) ), defineParameter("nonForestCanBeYoungAge", "logical", TRUE, NA, NA, diff --git a/fireSense_dataPrepPredict.html b/fireSense_dataPrepPredict.html index 31c6312..2f56acc 100644 --- a/fireSense_dataPrepPredict.html +++ b/fireSense_dataPrepPredict.html @@ -2994,7 +2994,7 @@

fireSense_dataPrepPredict Manual

-

v.1.0.4.9004

+

v.1.0.4.9005

Last updated: 2026-09-28

@@ -3004,7 +3004,7 @@

Last updated: 2026-09-28

fireSense_dataPrepPredict Module

-

made-with-Markdown

+

made-with-Markdown

Authors:

@@ -3015,7 +3015,7 @@

Authors:

Module Overview

Module summary

-

Prepares, each year, the covariate tables that the fireSense (Marchal, Steve G. Cumming, et al. 2017b; Marchal, Steve G. Cumming, et al. 2017a; Marchal et al. 2019) predict modules use:

+

Prepares, each year, the covariate tables that the fireSense (Marchal, Cumming, and McIntire 2017b; Marchal, Cumming, and McIntire 2017a; Marchal, Cumming, and McIntire 2019) predict modules use:

  • fireSense_igAndEscapePred_Covariates for fireSense_IgnitionPredict and fireSense_EscapePredict: fuel classes, non-forest landcover, youngAge, ignition climate and lightning days, aggregated by igAggFactor.
  • fireSense_SpreadCovariates for fireSense_SpreadPredict: the same fuel, landcover and youngAge columns plus spread climate, at the resolution of flammableRTM.
  • @@ -3546,7 +3546,7 @@

    Module inputs and parameters

    NA -Non-flammable landcover classes, used to create flammableRTM and the default landcover if not supplied. Defaults are water, snow/ice, rock and barren land in NTEMS LCC. +Non-flammable landcover classes, used to create flammableRTM and the default landcover if not supplied. The default, fireSenseUtils::fireSenseNonflammableLCC, is no data, water, rock, snow/ice and barren land. @@ -3776,7 +3776,7 @@

    References

    Marchal, Jean, Steve G Cumming, and Eliot J B McIntire. 2017b. “Land Cover, More Than Monthly Fire Weather, Drives Fire-Size Distribution in Southern Québec Forests: Implications for Fire Risk Management.” PLoS ONE 12 (6): 1–17. https://doi.org/10.1371/journal.pone.0179294.
-Marchal, Jean, Steven G. Cumming, and Eliot J. B. McIntire. 2019. “Turning Down the Heat: Vegetation Feedbacks Limit Fire Regime Responses to Global Warming.” Ecosystems, ahead of print, May. https://doi.org/10.1007/s10021-019-00398-2. +Marchal, Jean, Steven G. Cumming, and Eliot J. B. McIntire. 2019. “Turning Down the Heat: Vegetation Feedbacks Limit Fire Regime Responses to Global Warming.” Ecosystems, May. https://doi.org/10.1007/s10021-019-00398-2.
diff --git a/fireSense_dataPrepPredict.md b/fireSense_dataPrepPredict.md index f1f29b1..12c99d2 100644 --- a/fireSense_dataPrepPredict.md +++ b/fireSense_dataPrepPredict.md @@ -1,6 +1,6 @@ --- title: "fireSense_dataPrepPredict Manual" -subtitle: "v.1.0.4.9004" +subtitle: "v.1.0.4.9005" date: "Last updated: 2026-09-28" output: bookdown::html_document2: @@ -278,7 +278,7 @@ Summary of user-visible parameters (Table \@ref(tab:moduleParams-fireSense-dataP 0, 20, 3.... NA NA - Non-flammable landcover classes, used to create `flammableRTM` and the default landcover if not supplied. Defaults are water, snow/ice, rock and barren land in NTEMS LCC. + Non-flammable landcover classes, used to create `flammableRTM` and the default landcover if not supplied. The default, `fireSenseUtils::fireSenseNonflammableLCC`, is no data, water, rock, snow/ice and barren land. nonForestCanBeYoungAge diff --git a/tests/testthat/test-nonflammableLCC.R b/tests/testthat/test-nonflammableLCC.R new file mode 100644 index 0000000..60f7dba --- /dev/null +++ b/tests/testthat/test-nonflammableLCC.R @@ -0,0 +1,25 @@ +## Root cause: fireSense_dataPrepPredict.R:46 hard-coded `nonflammableLCC = c(0, 20, 31, 32, 33)`, +## the NTEMS non-flammable codes, missing SCANFI's combined rock/exposed code (30). Land cover +## built by `fireSenseUtils::makeFireSenseLCC()` from SCANFI carries that code, so rock entered +## predictions as flammable non-forest. The default now comes from +## `fireSenseUtils::fireSenseNonflammableLCC`, the single source of truth `makeFireSenseLCC()` +## itself also uses. + +test_that("nonflammableLCC defaults to fireSenseUtils::fireSenseNonflammableLCC", { + md <- SpaDES.core::moduleMetadata(module = moduleName, path = modulePath) + default <- md$parameters$default[md$parameters$paramName == "nonflammableLCC"][[1]] + expect_identical(default, fireSenseUtils::fireSenseNonflammableLCC) +}) + +test_that("the flammability step marks SCANFI rock/exposed (class 30) non-flammable", { + md <- SpaDES.core::moduleMetadata(module = moduleName, path = modulePath) + default <- md$parameters$default[md$parameters$paramName == "nonflammableLCC"][[1]] + + ## Toy land cover: coniferous forest (flammable), SCANFI rock/exposed, water. + toyLCC <- terra::rast(nrows = 1, ncols = 3, xmin = 0, xmax = 3, ymin = 0, ymax = 1, + crs = "EPSG:3978") + terra::values(toyLCC) <- c(210L, 30L, 20L) + + flammable <- LandR::defineFlammable(toyLCC, nonFlammClasses = default) + expect_equal(as.vector(terra::values(flammable, mat = FALSE)), c(1, 0, 0)) +})