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 @@
# fireSimulator_validation (development version)

* Fix: the per-ELF `auc` rows of S7 were NA whenever one scored year had no observed burn (that year's AUC is undefined, and the ELF's median was taken over it). The ELF row is now the median over the years with an AUC, as the pooled row already was.

* New table "Climate slope by channel": which of the three parts of the climate response carries the difference between the simulated and the observed slope. log(annual area) = log(ignitions) + log(escape rate) + log(mean escaped-fire size) (escapes = fires of the escape size or more, area = `area50`), so the slope of log area on the standardised covariate is the sum of three slopes. `scoreSlopeSplit()` gives, per ELF, the observed slope and, per run, the slope of each part over the same years (the scored years with an ignition, an escape and some area; a year with no escape is left out of all three parts, so they add up exactly to the total slope on those years), reported as simulated (median of runs, single-run range), observed and the difference sim - obs with the observed rank; `slopeSplitTable()` adds the median over ELFs with its 2.5-97.5% range over ELFs (`elfRange()`). `runWave1()` returns it as `slopeSplit` and adds its rows to `results` (test `C`, `null` = `slopeIgnitions`, `slopeEscapeRate`, `slopeSize`, measure `difference`); `buildValidationPage()` has a new argument `slopeSplit` and the page a sortable table under the climate table, with a note that the three differences add up to the total slope difference. The covariate, years and slope helpers are the climate table's (`climateInputs()`, `logSlope()`, `withPooled()`).

* New spatial skill tests, scored per ELF-year against historical nulls that leave the scored year out (`R/spatialTests.R`). S6, ignition location: the mean negative log-likelihood per observed ignition point under the model's ignition probability map (each run's map normalised to sum 1, so totals do not count), against N1, the ELF's other years' ignition points smoothed with a Gaussian kernel (25 km) and mixed 90/10 with a uniform density. S7, burn location: the Brier score of the share of runs that burned each burnable core cell, against N1, the cell's burn frequency over the other years; the per-year AUC is also reported. `wave1_results.csv` has tests `S6` and `S7` (null `N1`, measure `skill`, ELF rows with the range of single runs; `S7` also measure `auc`), and the page a "Where fire happens" table. The ELF input has an optional `location`; `readFireSenseHindcast()` builds it from `hindcast_ignitionProb_rep*.tif`, `hindcast_burnID_rep*.tif`, `hindcast_observedPoints.gpkg` and `hindcast_observedPolys.gpkg`, reducing each year as it reads. `observedRecord()` now also keeps each year's natural ignition points, so the cached ELF reads and observed records are rebuilt once.
Expand Down
2 changes: 1 addition & 1 deletion R/runWave1.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ runWave1 <- function(elfs, minHa, nBoot = 999, nNull = 199, nPerm = 9999, seed =
do.call(rbind, lapply(intersect(c("cover50", "cover90", "logScore", "auc"), names(d)), function(m) {
x <- data.frame(ELF = d$ELF, year = d$year, value = as.numeric(d[[m]]))
p <- bootstrapMean(x, nBoot, seed)
perE <- do.call(rbind, lapply(split(x, x$ELF), function(z) data.frame(level = "ELF", ELF = z$ELF[1], value = pooledValue(z$value),
perE <- do.call(rbind, lapply(split(x[is.finite(x$value), ], x$ELF[is.finite(x$value)]), function(z) data.frame(level = "ELF", ELF = z$ELF[1], value = pooledValue(z$value),
lo = NA_real_, hi = NA_real_, nELF = 1L, nUnits = nrow(z))))
rbind(data.frame(level = "pooled", ELF = "all", p), perE) |> transform(test = tst, null = NA_character_, measure = m)
}))
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-spatial.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,13 @@ test_that("the page carries the location table and the pooled ELF-years row of t
cl <- jsonlite::fromJSON(sub(";.*", "", sub(".*const CLIMATE = ", "", h)), simplifyVector = FALSE)
expect_true("all: pooled ELF-years" %in% vapply(cl, `[[`, "", "elf"))
})

test_that("a year with no observed burn (AUC NA) does not make the ELF's AUC row NA", {
skip_if_not_installed("kSamples")
bt <- c(rep(0.3, 100), rep(0.01, 900))
e <- toyElf(name = "a", perfect = TRUE, seed = 1); e$location <- burnToy(bt, bt, seed = 1)$location
e$location$burn$obs[["1991"]] <- integer(0) # nothing burned in 1991: its AUC is NA
r <- runWave1(list(e), toyMinHa, nBoot = 20, nNull = 19, nPerm = 99)$results
a <- r[r$test == "S7" & r$measure == "auc", ]
expect_true(all(is.finite(a$value)))
})
Loading