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_spreadPredict (development version)

- The yearly spread probability map (`.plots = "png"`) is bigger. Its png is now 10 x 8 inches at 144 dpi (1440 x 1152 pixels), as fireSense_burn's; it was R's `png()` default of 480 x 480, which looked small in `SpaDES.shiny::shine()`.

- A ledger row from a `fireSense_spreadFit` with `spreadClimate = "ceiling"` (a power-law `spreadLink` with `climateRef_spread` and `powerLawPc50_spread`) is predicted with climate moving the ceiling `pc` toward p50 (`fireSenseUtils::spreadLinkInputs()`): new `ledgerPowerLawPc50()`; `spreadProbOneELF()` takes `powerLawPc50`, returns the fuels' linear predictor as `linearPredictor` and the link's parameters as the attribute `linkPars` (one row per pixel here). `fireSense_SpreadPowerLaw` is then a raster with a `pc` per pixel even for one ELF, and several ELFs blend the per-pixel parameters (the vector `powerLawParsOf()` is gone: `spreadLinkInputs()` makes the parameters). Rows without `climateRef_spread` predict exactly as before. `fireSense_burn` already reads a per-cell raster of the link's parameters. Needs fireSenseUtils >= 0.2.3.9181 (PredictiveEcology/fireSenseUtils#250).

- New parameter `.plots` (default `"screen"`): the spread probability map (`fireSense_SpreadPredicted`) is plotted each `run` (`SpreadProbability_yr<year>`). `NA` or `NULL` for none.
Expand Down
3 changes: 2 additions & 1 deletion fireSense_spreadPredict.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ doEvent.fireSense_spreadPredict <- function(sim, eventTime, eventType, debug = F
## the year's spread probability
if (anyPlotting(P(sim)$.plots))
Plots(sim$fireSense_SpreadPredicted, types = P(sim)$.plots,
filename = paste0("SpreadProbability_yr", time(sim)))
filename = paste0("SpreadProbability_yr", time(sim)),
deviceArgs = list(width = 10, height = 8, units = "in", res = 144)) # png() alone is 480 x 480 px

if (!is.na(P(sim)$.runInterval)) {
sim <- scheduleEvent(sim, time(sim) + P(sim)$.runInterval, moduleName, "run",
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-events.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ test_that("`.plots` saves the spread probability map each run (default \"screen\
f <- SpaDES.core::outputs(sim)$file
expect_setequal(basename(f), c("SpreadProbability_yr1.png", "SpreadProbability_yr2.png"))
expect_true(all(file.exists(f)))
pngSize <- function(f) { # width, height in pixels, from the PNG header
con <- file(f, "rb"); on.exit(close(con)); h <- readBin(con, "raw", 24L)
readBin(h[17:24], "integer", 2L, size = 4L, endian = "big")
}
expect_equal(pngSize(f[1]), c(1440L, 1152L)) # not png()'s 480 x 480
expect_length(SpaDES.core::outputs(toyRun())$file, 0L) # toySim() sets NA
})

Loading