Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# fireSense_dataPrepPredict (development version)

- `forestedLCC`, `cutoffForYoungAge`, `nonForestCanBeYoungAge`, `flammabilityThreshold`,
`fuelClassCol` and `igAggFactor` now default to `fireSenseUtils`'s shared constants
(`fireSenseForestedLCC`, `fireSenseYoungAgeCutoff`, `fireSenseNonForestCanBeYoungAge`,
`fireSenseFlammabilityThreshold`, `fireSenseFuelClassCol`, `fireSenseIgAggFactor`), as
`nonflammableLCC` already did, so a fit and its predictions cannot silently use different
values. Values are unchanged. New parameter `scanfiVersion` (default
`fireSenseUtils::fireSenseSCANFIVersion`), the SCANFI land-cover version used when this module
builds its own land cover, passed to `makeFireSenseLCC()`. `fireSenseCovariatesCreate()` is now
called with `::`, not `:::` (it is exported). Needs `fireSenseUtils@development (>= 0.2.3.9062)`.
Version 1.0.4.9006.
- 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()`
Expand Down
24 changes: 15 additions & 9 deletions fireSense_dataPrepPredict.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.9005"),
version = list(fireSense_dataPrepPredict = "1.0.4.9006"),
timeframe = as.POSIXlt(c(NA, NA)),
timeunit = "year",
citation = list("citation.bib"),
Expand All @@ -19,11 +19,11 @@ defineModule(sim, list(
"fireSense_IgnitionFit", "fireSense_SpreadFit")),
reqdPkgs = list(
"data.table",
"PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9060)",
"PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9062)",
"terra"
),
parameters = rbind(
defineParameter("cutoffForYoungAge", "numeric", 15, NA, NA,
defineParameter("cutoffForYoungAge", "numeric", fireSenseUtils::fireSenseYoungAgeCutoff, NA, NA,
desc = paste(
"Age at and below which pixels are considered 'young'",
"(i.e., `age <= cutoffForYoungAge`)."
Expand All @@ -33,14 +33,14 @@ defineModule(sim, list(
paste("Year of the default landcover and stand age maps, and last year of the fires",
"used to initialise `nonForest_timeSinceDisturbance`.")),
defineParameter("fireTimeStep", "numeric", 1, NA, NA, desc = "Interval between events of this module, in years."),
defineParameter("forestedLCC", "numeric", c(81, 210, 220, 230, 240), NA, NA,
defineParameter("forestedLCC", "numeric", fireSenseUtils::fireSenseForestedLCC, NA, NA,
"Forested landcover classes in `rstLCC_RTM`. Only used if `landcoverDT` is not supplied."),
defineParameter("flammabilityThreshold", "numeric", 0.1, 0, 1,
defineParameter("flammabilityThreshold", "numeric", fireSenseUtils::fireSenseFlammabilityThreshold, 0, 1,
paste("Minimum proportion of flammable pixels for an upscaled pixel to be flammable,",
"when building the default landcover.")),
defineParameter("fuelClassCol", "character", "FuelClass", NA, NA,
defineParameter("fuelClassCol", "character", fireSenseUtils::fireSenseFuelClassCol, NA, NA,
"Column of `sppEquiv` that defines the fuel classes, for both ignition and spread."),
defineParameter("igAggFactor", "numeric", 4, 1, NA,
defineParameter("igAggFactor", "numeric", fireSenseUtils::fireSenseIgAggFactor, 1, NA,
paste("Aggregation factor for the ignition and escape covariates.",
"Overwritten in `init` by the value set in other modules.")),
defineParameter("nonflammableLCC", "numeric", fireSenseUtils::fireSenseNonflammableLCC, NA, NA,
Expand All @@ -50,8 +50,13 @@ defineModule(sim, list(
"water, rock, snow/ice and barren land."
)
),
defineParameter("nonForestCanBeYoungAge", "logical", TRUE, NA, NA,
defineParameter("nonForestCanBeYoungAge", "logical", fireSenseUtils::fireSenseNonForestCanBeYoungAge, NA, NA,
desc = "Should burned non-forest pixels be `youngAge` until `cutoffForYoungAge`?"),
defineParameter("scanfiVersion", "character", fireSenseUtils::fireSenseSCANFIVersion, NA, NA,
desc = paste(
"SCANFI land-cover version for non-forest land cover, when this module builds its own",
"landcover (only used if `rstLCC_RTM`/`rstLCCs` is not supplied)."
)),
defineParameter("sppEquivCol", "character", "LandR", NA, NA,
desc = "Column of `sppEquiv` with the species names used in `cohortData`."),
defineParameter("whichModulesToPrepare", "character",
Expand Down Expand Up @@ -471,7 +476,7 @@ prepare_SpreadPredict <- function(sim) {
## its fit used even where a different class dominates here. domClass = NA (a fit made with
## fuelCovariates = "species", or with no fitted parameters yet) predicts with the previous
## per-fuel-class columns.
covs <- fireSenseUtils:::fireSenseCovariatesCreate(
covs <- fireSenseUtils::fireSenseCovariatesCreate(
cohortData = sim$cohortData,
pixelGroupMap = sim$pixelGroupMap,
flammableRTM = sim$flammableRTM,
Expand Down Expand Up @@ -676,6 +681,7 @@ unionLCCGroups <- function(fuelSets) {
overwrite= TRUE,
nonflammableLCC = P(sim)$nonflammableLCC,
flammabilityThreshold = P(sim)$flammabilityThreshold,
scanfiVersion = P(sim)$scanfiVersion,
userTags = c("makeFireSenseLCC", "predict")
)
sim$rstLCC_RTM <- rstLCC$lcc
Expand Down
22 changes: 21 additions & 1 deletion fireSense_dataPrepPredict.html
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,7 @@


<h1 class="title toc-ignore">fireSense_dataPrepPredict Manual</h1>
<h3 class="subtitle">v.1.0.4.9005</h3>
<h3 class="subtitle">v.1.0.4.9006</h3>
<h4 class="date">Last updated: 2026-09-28</h4>

</div>
Expand Down Expand Up @@ -3571,6 +3571,26 @@ <h3>Module inputs and parameters</h3>
</tr>
<tr>
<td style="text-align:left;">
scanfiVersion
</td>
<td style="text-align:left;">
character
</td>
<td style="text-align:left;">
V3
</td>
<td style="text-align:left;">
NA
</td>
<td style="text-align:left;">
NA
</td>
<td style="text-align:left;">
SCANFI land-cover version for non-forest land cover, when this module builds its own landcover (only used if <code>rstLCC_RTM</code>/<code>rstLCCs</code> is not supplied).
</td>
</tr>
<tr>
<td style="text-align:left;">
sppEquivCol
</td>
<td style="text-align:left;">
Expand Down
10 changes: 9 additions & 1 deletion fireSense_dataPrepPredict.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "fireSense_dataPrepPredict Manual"
subtitle: "v.1.0.4.9005"
subtitle: "v.1.0.4.9006"
date: "Last updated: 2026-09-28"
output:
bookdown::html_document2:
Expand Down Expand Up @@ -288,6 +288,14 @@ Summary of user-visible parameters (Table \@ref(tab:moduleParams-fireSense-dataP
<td style="text-align:left;"> NA </td>
<td style="text-align:left;"> Should burned non-forest pixels be `youngAge` until `cutoffForYoungAge`? </td>
</tr>
<tr>
<td style="text-align:left;"> scanfiVersion </td>
<td style="text-align:left;"> character </td>
<td style="text-align:left;"> V3 </td>
<td style="text-align:left;"> NA </td>
<td style="text-align:left;"> NA </td>
<td style="text-align:left;"> SCANFI land-cover version for non-forest land cover, when this module builds its own landcover (only used if `rstLCC_RTM`/`rstLCCs` is not supplied). </td>
</tr>
<tr>
<td style="text-align:left;"> sppEquivCol </td>
<td style="text-align:left;"> character </td>
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test_that("parameters are the expected names", {
sort(md$parameters$paramName),
sort(c(".runInitialTime", ".studyAreaName", ".useCache", "cutoffForYoungAge", "dataYear",
"fireTimeStep", "flammabilityThreshold", "forestedLCC", "fuelClassCol",
"igAggFactor", "nonflammableLCC", "nonForestCanBeYoungAge", "sppEquivCol",
"whichModulesToPrepare"))
"igAggFactor", "nonflammableLCC", "nonForestCanBeYoungAge", "scanfiVersion",
"sppEquivCol", "whichModulesToPrepare"))
)
})
19 changes: 19 additions & 0 deletions tests/testthat/test-sharedDefaults.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Root cause: fireSense_dataPrepPredict.R hard-coded its own copies of `forestedLCC`,
## `cutoffForYoungAge`, `nonForestCanBeYoungAge`, `flammabilityThreshold`, `fuelClassCol` and
## `igAggFactor`, the same defaults fireSense_dataPrepFit hard-codes separately. A fit and its
## predictions are only consistent if both modules use the same values, so each now takes its
## default from `fireSenseUtils`'s shared constants (`?fireSenseUtils::fireSenseSharedDefaults`),
## as `nonflammableLCC` already did.

test_that("parameter defaults come from fireSenseUtils's shared constants", {
md <- SpaDES.core::moduleMetadata(module = moduleName, path = modulePath)
default <- function(name) md$parameters$default[md$parameters$paramName == name][[1]]

expect_identical(default("forestedLCC"), fireSenseUtils::fireSenseForestedLCC)
expect_identical(default("cutoffForYoungAge"), fireSenseUtils::fireSenseYoungAgeCutoff)
expect_identical(default("nonForestCanBeYoungAge"), fireSenseUtils::fireSenseNonForestCanBeYoungAge)
expect_identical(default("flammabilityThreshold"), fireSenseUtils::fireSenseFlammabilityThreshold)
expect_identical(default("fuelClassCol"), fireSenseUtils::fireSenseFuelClassCol)
expect_identical(default("igAggFactor"), fireSenseUtils::fireSenseIgAggFactor)
expect_identical(default("scanfiVersion"), fireSenseUtils::fireSenseSCANFIVersion)
})
Loading