diff --git a/NEWS.md b/NEWS.md index 3d8b646..32df969 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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`). `NA` or `NULL` for none. diff --git a/fireSense_spreadPredict.R b/fireSense_spreadPredict.R index 42c3f5b..6f57d02 100644 --- a/fireSense_spreadPredict.R +++ b/fireSense_spreadPredict.R @@ -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", diff --git a/tests/testthat/test-events.R b/tests/testthat/test-events.R index 1bf9d6b..8a960cc 100644 --- a/tests/testthat/test-events.R +++ b/tests/testthat/test-events.R @@ -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 })