diff --git a/NEWS.md b/NEWS.md index 82732db..b98922e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # fireSense_dataPrepFit (development version) +- Fixed: `nonflammableLCC`'s default (`c(0, 20, 31, 32, 33)`) missed SCANFI's rock/exposed code + (`30`), so rock entered fits 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.2.0.9017. - New parameter `fuelCovariates` (default `"domSecOther"`): `prepare_SpreadFit()` now builds the spread covariates as `dom_agb_`/`sec_agb_` (the ELF's two fuel classes with the most total treed AGB), `other_agb` and `treedWetland_agb`, chosen once per ELF by the new diff --git a/fireSense_dataPrepFit.R b/fireSense_dataPrepFit.R index fbda1bc..38554d7 100644 --- a/fireSense_dataPrepFit.R +++ b/fireSense_dataPrepFit.R @@ -8,7 +8,7 @@ defineModule(sim, list( person(c("Alex", "M"), "Chubaty", role = "ctb", email = "achubaty@for-cast.ca") ), childModules = character(0), - version = list(fireSense_dataPrepFit = "1.2.0.9016"), + version = list(fireSense_dataPrepFit = "1.2.0.9017"), timeframe = as.POSIXlt(c(NA, NA)), timeunit = "year", citation = list("citation.bib"), @@ -17,7 +17,7 @@ defineModule(sim, list( reqdPkgs = list("data.table", "fastDummies", "Require", "PredictiveEcology/reproducible@development (>= 3.2.1.9042)", # CacheGeo re-reads a changed local file "PredictiveEcology/climateData@development (>= 2.2.3.9006)", - "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9057)", + "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9060)", "FOR-CAST/fireregimetools@main (>= 0.1.0.9008)", "ggplot2", "parallel", "purrr", "raster", "sf", "sp", "PredictiveEcology/LandR@development (>= 1.2.0.9015)", @@ -78,8 +78,10 @@ defineModule(sim, list( "this is not a parameter there.")), defineParameter("minBufferSize", "numeric", 5000, NA, NA, paste("Minimum number of cells in each fire's burned-plus-buffer sample, applied after `areaMultiplier`.")), - defineParameter("nonflammableLCC", "numeric", c(0, 20, 31, 32, 33), NA, NA, - "Non-flammable classes in `rstLCCs`; the default is water, snow/ice, rock and barren land."), + defineParameter("nonflammableLCC", "numeric", fireSenseUtils::fireSenseNonflammableLCC, NA, NA, + paste("Non-flammable classes in `rstLCCs`; the default,", + "`fireSenseUtils::fireSenseNonflammableLCC`, is no data, water, rock,", + "snow/ice and barren land.")), defineParameter("nonForestCanBeYoungAge", "logical", TRUE, NA, NA, paste("if TRUE, burned non-forest will be treated as `youngAge`. Recommended to be TRUE", "as burned forest is often classified as non-forest")), diff --git a/fireSense_dataPrepFit.html b/fireSense_dataPrepFit.html index a3652bf..77686da 100644 --- a/fireSense_dataPrepFit.html +++ b/fireSense_dataPrepFit.html @@ -2994,7 +2994,7 @@

fireSense_dataPrepFit Manual

-

v.1.2.0.9016

+

v.1.2.0.9017

Last updated: 2026-09-28

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

Last updated: 2026-09-28

fireSense_dataPrepFit Module

-

made-with-Markdown

+

made-with-Markdown

Authors:

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

Module Overview

Prepares the data needed to fit fireSense_IgnitionFit, fireSense_EscapeFit and fireSense_SpreadFit.

Module summary

-

The module combines historical fire records, vegetation, land cover and climate into the covariate tables used to fit the three fireSense processes (Marchal, Steve G. Cumming, et al. 2017b; Marchal, Steve G. Cumming, et al. 2017a; Marchal et al. 2019): ignition, escape (an ignition that grows beyond one pixel) and spread.

+

The module combines historical fire records, vegetation, land cover and climate into the covariate tables used to fit the three fireSense processes (Marchal, Cumming, and McIntire 2017b; Marchal, Cumming, and McIntire 2017a; Marchal, Cumming, and McIntire 2019): ignition, escape (an ignition that grows beyond one pixel) and spread.

Vegetation, land cover and stand age are snapshots, one per year in P(sim)$dataYears (default 2000, 2010, 2020). Each year in P(sim)$fireYears uses the snapshot at or before it, so no fire year may precede the first data year, and every data year needs at least one fire year. Climate is annual and is matched to the year of each fire. @@ -3812,7 +3812,7 @@

Module inputs and parameters

NA -Non-flammable classes in rstLCCs; the default is water, snow/ice, rock and barren land. +Non-flammable classes in rstLCCs; the default, fireSenseUtils::fireSenseNonflammableLCC, is no data, water, rock, snow/ice and barren land. @@ -4501,7 +4501,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_dataPrepFit.md b/fireSense_dataPrepFit.md index 761bae5..ac8171c 100644 --- a/fireSense_dataPrepFit.md +++ b/fireSense_dataPrepFit.md @@ -1,6 +1,6 @@ --- title: "fireSense_dataPrepFit Manual" -subtitle: "v.1.2.0.9016" +subtitle: "v.1.2.0.9017" date: "Last updated: 2026-09-28" output: bookdown::html_document2: @@ -408,7 +408,7 @@ Parameters are in Table \@ref(tab:moduleParams-fireSense-dataPrepFit). 0, 20, 3.... NA NA - Non-flammable classes in `rstLCCs`; the default is water, snow/ice, rock and barren land. + Non-flammable classes in `rstLCCs`; the default, `fireSenseUtils::fireSenseNonflammableLCC`, is no data, water, rock, snow/ice and barren land. nonForestCanBeYoungAge diff --git a/tests/testthat/test-domSecOtherFuels.R b/tests/testthat/test-domSecOtherFuels.R index 775183e..6664cbe 100644 --- a/tests/testthat/test-domSecOtherFuels.R +++ b/tests/testthat/test-domSecOtherFuels.R @@ -20,11 +20,11 @@ test_that("fuelCovariates defaults to domSecOther, with species as the only othe expect_identical(def$fuelCovariates, c("domSecOther", "species")) }) -test_that("reqdPkgs floors fireSenseUtils at >= 0.2.3.9057 (chooseDomSecFuelClasses etc.)", { +test_that("reqdPkgs floors fireSenseUtils at >= 0.2.3.9060 (chooseDomSecFuelClasses, fireSenseNonflammableLCC etc.)", { md <- SpaDES.core::moduleMetadata(module = moduleName, path = modulePath) fsu <- grep("fireSenseUtils", md$reqdPkgs, value = TRUE) expect_length(fsu, 1L) - expect_match(fsu, "0\\.2\\.3\\.9057") + expect_match(fsu, "0\\.2\\.3\\.9060") }) test_that("prepare_SpreadFit() picks fuelClassRoles once per ELF via chooseDomSecFuelClasses()", { diff --git a/tests/testthat/test-nonflammableLCC.R b/tests/testthat/test-nonflammableLCC.R new file mode 100644 index 0000000..310b4c5 --- /dev/null +++ b/tests/testthat/test-nonflammableLCC.R @@ -0,0 +1,25 @@ +## Root cause: fireSense_dataPrepFit.R:81 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 +## fits as flammable non-forest (20% of ELF 14.4's "flammable" pixels in the 2026-09 land cover). +## 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)) +})