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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# fireSense_dataPrepFit 1.3.0.9011 (development version)

* The "Historical Fire Maps" figure is now listed in `outputs(sim)` on every run. Its outer `Cache()` skipped `Plots()` on a hit, so the figure was missing from the run's saved files; `Plots(useCache = TRUE, .cacheExtra = )` (SpaDES.core, PredictiveEcology/SpaDES.core#535) now skips building the maps on a hit and still records the figure.

* New parameter `spreadInteractions` (default `character(0)`: nothing changes, the formula string is byte-identical). `"climate:fuel"` adds to the spread formula one interaction term for each spread climate variable and each fuel covariate (`fireSenseUtils::spreadFuelCols()`: not `youngAge`, `nfLCC_*` or `treedWetland`), e.g. `CMD:dom_agb_Pice_mar`, after the main effects, so `fireSense_spreadFit` fits fuel x climate interactions with the other terms (`spreadRHS()`, `checkSpreadInteractions()`). Each term is the product of its two covariates after each is rescaled and centred, 0 where `youngAge` cleared the fuel, in the fit and in `fireSense_spreadPredict`; each main effect is then the slope at the mean of the other covariate, so the drought >= 0 and fuel >= 0 bounds apply at typical conditions (`fireSenseUtils::spreadProbFromIntegerCovs()`). It needs `spreadCovariates = "all"`. Needs fireSenseUtils >= 0.2.3.9177 (#242), and `fireSense_spreadFit` and `fireSense_spreadPredict` with their interaction PRs. Adding `spreadFuelCols` to `prepSpreadFitData`'s `.cacheExtra` re-runs that event once.
* New parameter `seedVegInit` (default `1`; `NA` = no seed, the old behaviour). The nested `Biomass_borealDataPrep` runs that rebuild `cohortDatas` and `pixelGroupMaps` draw random numbers (age and biomass models fit to a random subset, replacement land cover), so the same ELF got different vegetation on different machines. `seedVegInit` is passed as the nested module's `.seed` for `init`, so the vegetation is the same everywhere for a given seed and different for another one. The seed is in the cache key of the nested run, which re-runs once under the default. Needs `Biomass_borealDataPrep` with the seed in the keys of its inner `Cache()` calls (`Depends-on` there).

Expand Down
41 changes: 20 additions & 21 deletions fireSense_dataPrepFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -1942,27 +1942,26 @@ runBorealDP_forCohortData <- function(sim) {
if (anyPlotting(Par$.plots)) {
fp <- allFirePolys[!sapply(allFirePolys, is.null)]
yrsDone <- names(fp)
r1 <- {
Map(nam = yrsDone, function(nam) {
r <- sim$rasterToMatch
wh <- r[] > 0
# force the scale on the individual layers to be 1:2; must do the rtm colors larger so that they always plot
r[wh] <- 2
p <- rasterize(allFirePolys[[nam]], sim$rasterToMatch)
r[p[] > 0] <- p[p[] > 0 ]
r
}) |>
terra::rast() |>
Plots(
.plotInitialTime = NULL, # needs to be NULL or else won't do it
maxnl = length(fp),
legend = FALSE,
maxcell = 1e6, zlim = c(1, 2), col = c("red", "grey"),
deviceArgs = list(width = 11, height = 8, units = "in", res = 300),
filename = "Historical Fire Maps") } |>
Cache(.cacheExtra = attr(allFirePolys, "tags"),
omitArgs = "data",
.functionName = "Plots_fireMaps") # uses the cacheId of the firePolysByYear; only plot if changed
Map(nam = yrsDone, function(nam) {
r <- sim$rasterToMatch
wh <- r[] > 0
# force the scale on the individual layers to be 1:2; must do the rtm colors larger so that they always plot
r[wh] <- 2
p <- rasterize(allFirePolys[[nam]], sim$rasterToMatch)
r[p[] > 0] <- p[p[] > 0 ]
r
}) |>
terra::rast() |>
Plots(
.plotInitialTime = NULL, # needs to be NULL or else won't do it
maxnl = length(fp),
legend = FALSE,
maxcell = 1e6, zlim = c(1, 2), col = c("red", "grey"),
deviceArgs = list(width = 11, height = 8, units = "in", res = 300),
filename = "Historical Fire Maps",
## keyed on the fire polygons' cache tags, checked before the maps are built: only
## plot if they changed; a hit still adds the figure to outputs(sim)
useCache = TRUE, .cacheExtra = attr(allFirePolys, "tags"))
}

if (!suppliedElsewhere("firePolys", sim)) {
Expand Down
Loading