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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# fireSense_ignitionPredict (development version)

* The yearly ignition and escape 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()`.
* The yearly map shows the escape probability beside the ignition probability (`IgnitionEscapeProbability_yr<year>`, was `IgnitionProbability_yr<year>`), both layers of `fireSense_IgAndEscapeProbRas`, and their product, the expected number of escaped fires starting in each pixel that year (`expectedEscapes`).
* New parameter `.plots` (default `"screen"`): the ignition probability map is plotted each `run` with `Plots(types = .plots)`; `NA` or `NULL` for none. The plot was gated on `.saveInterval` instead, so `.plots` (e.g. `"png"` from `.globals`) drew and saved nothing. `.saveInterval`, used for nothing else, is removed.
* Before predicting, every stored ignition and escape fit (each ELF's, with several) is checked against the covariates to predict (`fireSenseUtils::storedFitProblem()`): a fit that is not Poisson or uses features the covariates lack stops the run, naming the ELF, process and features, and saying to refit or to choose another ledger (`fitFileSuffix`). Needs fireSenseUtils (>= 0.2.3.9177).
Expand Down
3 changes: 2 additions & 1 deletion fireSense_ignitionPredict.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ IgnitionPredictRun <- function(sim) {
expectedEscapes <- probs[["ignitionProb"]] * probs[["escapeProb"]]
names(expectedEscapes) <- "expectedEscapes"
Plots(c(probs, expectedEscapes), types = Par$.plots,
filename = paste0("IgnitionEscapeProbability_yr", time(sim)))
filename = paste0("IgnitionEscapeProbability_yr", time(sim)),
deviceArgs = list(width = 10, height = 8, units = "in", res = 144)) # png() alone is 480 x 480 px
}

return(invisible(sim))
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 @@ -64,6 +64,11 @@ test_that("`.plots` saves the ignition and escape probability maps each run, and
pngs <- SpaDES.core::outputs(withPng)$file
expect_true(any(grepl("IgnitionEscapeProbability_yr2001", pngs)))
expect_true(all(file.exists(pngs[grepl("IgnitionEscapeProbability", pngs)])))
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(pngs[grepl("IgnitionEscapeProbability", pngs)][1]), c(1440L, 1152L)) # not png()'s 480 x 480
without <- toyIgRun(ins, params = list(.plots = NA), times = list(start = 2001, end = 2002))
expect_false(any(grepl("IgnitionEscapeProbability", SpaDES.core::outputs(without)$file)))
})