From 1c4d4a7e12fc172e239a3e0afc5c80ee966dc61e Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Thu, 3 Dec 2026 21:46:36 -0700 Subject: [PATCH 1/2] S8/S9 per parameter set; seeded fires as GeoTIFFs; bySet NA = auto elfOfSet() subset only simYears/simSizes, so S8/S9 could not be scored per set. The reader now keeps run ids and fire ids of the burn maps; scoreBySet() adds the S8/S9 ELF rows per set; writeSeededFires() writes the scored observed and per-run fires as GeoTIFFs. Co-Authored-By: Claude Opus 5.5 --- NEWS.md | 2 ++ R/bySet.R | 31 +++++++++++++++++++--- R/escapeTests.R | 41 ++++++++++++++++++++++++++++- R/readFireSenseHindcast.R | 26 ++++++++++++++----- fireSimulator_validation.R | 13 ++++++---- tests/testthat/helper-source.R | 20 +++++++++++++++ tests/testthat/test-byset.R | 43 +++++++++++++++++++++++++++++++ tests/testthat/test-escapes.R | 47 +++++++++++++++++++--------------- 8 files changed, 186 insertions(+), 37 deletions(-) diff --git a/NEWS.md b/NEWS.md index f2be75a..0f91f82 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # fireSimulator_validation (development version) +* S8 and S9 per parameter set, and the seeded fires as maps. `scoreBySet()` now also scores S8 (size given escape) and S9 (shape given escape) of each set of an in-sample ELF: columns `S8_rho`, `S8_log2ratio`, `S9_aucDiff`, `S9_auc`, `S9_aucDist`, `S9_shareInside`, `S8_nFires`, `S9_nFires`, with `_runLo`/`_runHi` (the ELF rows of `escapeResultRows()`). `elfOfSet()` now keeps only the set's runs in `location$seeded$sizes` and `location$burn` too; before, it subset only `simYears` and `simSizes`. To split the burns by set, `readHindcastLocation()` records the run of each burn map (`burn$runIds`, from `hindcast_reps.csv`, new `burnRunIds()`) and keeps each burned cell's fire (`fire`, its burn ID), and `readHindcastSeeded()` keeps `fire` in `sizes`; the grid also carries its `crs`. New `writeSeededFires()`: `writeOutputs` writes, for each in-sample ELF, `/seededFires//_/observed.tif` and `predicted.tif` (one layer per run, `set_rep`), holding exactly the cells S8 and S9 score (1 burned, 0 burnable and not burned, NA not scored, so lakes are NA), with `fires.csv`; a predicted layer holds only the fire grown from that start. `bySet` defaults to `NA`: score by set when some ELF's runs are of more than one set. The cached ELF reads are rebuilt once. + * In-sample hindcasts (they spread the observed escapes from their real starts and years, `FS_HC_IGNITIONS=observedEscapes`): S7 is no longer scored, because its whole-ELF AUC (about 0.9) only shows that the fires start where the observed ones did. New tests S8 and S9 score what a fire does once it has escaped (`R/escapeTests.R`). S8, size given escape: for each seeded observed escape, the median over runs of the final size of the fire that grew from it against the fire's observed size; per ELF the Spearman correlation `rho` (single-run range), the median `log2ratio` of simulated over observed size and `nFires`. S9, shape given escape: for each seeded fire with N observed cells, the circle around its start that holds 2N burnable core cells; the AUC of the share of runs that burned each cell for the cells the fire burned against the others (`aucOf()`), reported as the median over fires with a single-run range, beside a distance-only baseline `aucDist` (each cell of the circle scored by its closeness to the start) and the headline `aucDiff` (model AUC minus baseline AUC), `shareInside` (the share of the fire's cells inside the circle, since cells outside are not counted) and `nFires`. Both are pooled over ELFs with `bootstrapPooled()` and are rows of `wave1_results.csv` (tests `S8`, `S9`); the page has a "Given an escape" table, shown only when there are such rows. A run is in-sample when every run of every year with a fire started the same fires from the same cells (`hindcastInSample()`, read from `fireSense_burnSummary.csv`: the hindcast files record no setting, only the folder name does); `readFireSenseHindcast()` has a new argument `inSample` (default `NA`: detect) and puts `inSample` and `location$seeded` in the ELF input. A fire is tied to its observed escape by its start cell (`igLoc` of `fireSense_burnSummary.csv`, in the order of `hindcast_sizes.csv`), and the start to the observed polygon that holds it. S8 and S9 are not scored for normal runs: their fires do not start where the observed ones did. * 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. diff --git a/R/bySet.R b/R/bySet.R index b5ebccd..b77786f 100644 --- a/R/bySet.R +++ b/R/bySet.R @@ -2,11 +2,20 @@ #' One ELF's input restricted to one parameter set #' -#' @param elf An ELF input list ([runWave1()]) whose `simYears` and `simSizes` have a `paramSet` column ([readHindcastSim()]). +#' @param elf An ELF input list ([runWave1()]) whose `simYears` and `simSizes` have a `paramSet` column ([readHindcastSim()]). Its `location`, when there is one, keeps the set's runs too: +#' `seeded$sizes` by `run`, and `burn$sim` by `burn$runIds` (the run of each burn run), renumbered 1..n; without `burn$runIds` the burns cannot be split by set, and `burn` is dropped. #' @param set The `paramSet` to keep. @return The same list with only that set's runs. elfOfSet <- function(elf, set) { elf$simYears <- elf$simYears[elf$simYears$paramSet == set, , drop = FALSE] elf$simSizes <- elf$simSizes[elf$simSizes$paramSet == set, , drop = FALSE] + runs <- unique(elf$simYears$run); loc <- elf$location + if (!is.null(loc$seeded)) loc$seeded$sizes <- loc$seeded$sizes[loc$seeded$sizes$run %in% runs, , drop = FALSE] + if (!is.null(loc$burn)) loc$burn <- if (!is.null(loc$burn$runIds)) { + keep <- which(loc$burn$runIds %in% runs) + loc$burn$sim <- lapply(loc$burn$sim, function(x) { x <- x[x$run %in% keep, , drop = FALSE]; x$run <- match(x$run, keep); x }) + loc$burn$runIds <- loc$burn$runIds[keep]; loc$burn$nRuns <- length(keep); loc$burn + } + elf$location <- loc elf } @@ -14,11 +23,13 @@ elfOfSet <- function(elf, set) { #' #' For every `paramSet` of `elf$simYears`: the gates ([runGates()]) and the annual-area skill ([scoreS3()], [skillScore()]), on that set's runs only. #' The ratios are those of [summariseGates()]: the median run over the observation (area, median of the 10 largest fires, ignitions, escape rate, -#' area per escape), each with the 2.5% and 97.5% of single runs (`_runLo`, `_runHi`). +#' area per escape), each with the 2.5% and 97.5% of single runs (`_runLo`, `_runHi`). An in-sample ELF also has the ELF values of S8 and S9 +#' ([scoreS8()], [scoreS9()]) on the set's runs, as the `results` rows of [escapeResultRows()]. #' #' @param elf An ELF input list with a `paramSet` column in `simYears` and `simSizes`. @param nBoot,seed As [runGates()]. #' @return `data.frame`, one row per set: `ELF`, `paramSet`, `nRuns`, the ratio columns of [summariseGates()], `annualArea_skillN1`, -#' `annualArea_skillN2` (skill of the set's annual area against the null N1 and N2), and `G2`, `G4`, `G6` (pass). +#' `annualArea_skillN2` (skill of the set's annual area against the null N1 and N2), and `G2`, `G4`, `G6` (pass); in-sample, also +#' `_` with `_runLo`, `_runHi` for each ELF measure of S8 and S9 (e.g. `S8_rho`, `S9_aucDiff`, `S8_nFires`; NA where it has no range). scoreBySet <- function(elf, nBoot = 1000, seed = 1) { do.call(rbind, lapply(sort(unique(elf$simYears$paramSet)), function(s) { e <- elfOfSet(elf, s) @@ -27,6 +38,18 @@ scoreBySet <- function(elf, nBoot = 1000, seed = 1) { skill <- function(nl) { x <- sk[sk$null == nl, ]; skillScore(x$lossModel, x$lossNull) } pass <- stats::setNames(lapply(c("G2", "G4", "G6"), function(id) g$pass[g$gate == id]), c("G2", "G4", "G6")) cbind(summariseGates(g), paramSet = s, nRuns = length(unique(e$simYears$run)), - annualArea_skillN1 = skill("N1"), annualArea_skillN2 = skill("N2"), as.data.frame(pass)) + annualArea_skillN1 = skill("N1"), annualArea_skillN2 = skill("N2"), as.data.frame(pass), escapeBySetColumns(e, nBoot, seed)) })) } + +## The ELF rows of S8 and S9 ([escapeResultRows()]) of one set as one row of columns `_`, `_runLo`, `_runHi`; a 0-column data.frame for an ELF that is not in-sample +escapeBySetColumns <- function(e, nBoot, seed) { + if (!isTRUE(e$inSample)) return(data.frame(row.names = 1L)) + tag <- function(x) if (!is.null(x)) cbind(ELF = e$elf, x) + s8 <- scoreS8(e); s9 <- scoreS9(e) + r <- escapeResultRows(list(S8 = tag(s8$scores), S9 = tag(s9$scores)), list(S8 = tag(s8$runs), S9 = tag(s9$runs)), nBoot, seed) + r <- r[r$level == "ELF", , drop = FALSE] + if (is.null(r) || !nrow(r)) return(data.frame(row.names = 1L)) + nm <- paste(r$test, r$measure, sep = "_") + as.data.frame(as.list(stats::setNames(c(r$value, r$lo, r$hi), c(nm, paste0(nm, "_runLo"), paste0(nm, "_runHi"))))) +} diff --git a/R/escapeTests.R b/R/escapeTests.R index 211f3ef..3c2d235 100644 --- a/R/escapeTests.R +++ b/R/escapeTests.R @@ -3,7 +3,7 @@ ## S8 asks how big each seeded fire gets, S9 what shape it takes. Nothing here knows a simulator: the adapter (readFireSenseHindcast.R) builds the plain tables below. ## An ELF input carries `inSample = TRUE` and, in `location`, `burn$grid` and `burn$gridCell` (the grid and the grid cell of each scored cell 1..nCells; see the top of spatialTests.R) and ## seeded: `fires` (`data.frame(year, start, obsHa)`: one row per observed escape that the run seeded, `start` its start as a grid cell, `obsHa` the observed size of the whole fire), -## `sizes` (`data.frame(year, run, start, ha)`: the final size of the fire that grew from each seeded start, in every run), +## `sizes` (`data.frame(year, run, start, ha)`: the final size of the fire that grew from each seeded start, in every run; the fireSense reader adds `fire`, the fire's burn ID in its run), ## `obsCells` (`data.frame(year, start, cell)`: the scored cells the observed fire burned). ## Squared distance of each cell of `xy` (list x, y) to `centre` (c(x, y)) @@ -105,3 +105,42 @@ escapePageRows <- function(results) { list(elf = label, rho = resultCell(z, "S8", "rho"), size = resultCell(z, "S8", "log2ratio"), n8 = n(z, "S8"), diff = resultCell(z, "S9", "aucDiff"), auc = resultCell(z, "S9", "auc"), dist = resultCell(z, "S9", "aucDist"), inside = resultCell(z, "S9", "shareInside"), n9 = n(z, "S9"))) } + +#' The seeded fires as maps: each observed fire and the runs' fires grown from its start +#' +#' For other scores of the same fires (e.g. a fractions skill score): per seeded observed escape, the cells S8 and S9 score, as GeoTIFFs on the hindcast grid, cropped to the observed and +#' simulated fire plus `margin` cells. A cell is 1 where the fire burned it, 0 where it is a scored cell (the ELF's burnable core) that did not burn, and NA where it is not scored (not burnable, +#' or outside the core), as in S9. `observed.tif` has one layer; `predicted.tif` one per run, named `set_rep`, holding only the fire that grew from this start in that run +#' (its burn ID), not the other fires of the year. Files go to `//_/`, with `//fires.csv` (`fireId`, `year`, `start`: the start cell of the grid, `obsHa`: +#' the observed size of the whole fire on burnable cells, as S8, `obsCells`: its scored cells, as in `observed.tif`). +#' @param elf ELF input list with `location$seeded` (with `fire` in `sizes`) and `location$burn` (with `runIds`, `fire` in `sim` and `crs` in `grid`), as [readFireSenseHindcast()] builds it. +#' @param dir Folder. @param margin Cells around the fires. @return The `fires.csv` table, invisibly; `NULL` for an ELF without them. +writeSeededFires <- function(elf, dir, margin = 10L) { + sd <- elf$location$seeded; b <- elf$location$burn + if (is.null(sd) || is.null(b$runIds) || !"fire" %in% names(sd$sizes)) return(invisible(NULL)) + g <- b$grid; resX <- (g$xmax - g$xmin) / g$ncol; resY <- (g$ymax - g$ymin) / g$nrow + scored <- rep(NA_integer_, g$nrow * g$ncol); scored[b$gridCell] <- 0L + bands <- paste0("set", b$runIds %/% 1000L, "_rep", b$runIds %% 1000L) + out <- file.path(dir, elf$elf); dir.create(out, recursive = TRUE, showWarnings = FALSE) + rows <- lapply(seq_len(nrow(sd$fires)), function(i) { + y <- sd$fires$year[i]; st <- sd$fires$start[i]; s <- b$sim[[as.character(y)]] + obs <- b$gridCell[sd$obsCells$cell[sd$obsCells$year == y & sd$obsCells$start == st]] + if (!length(obs) || is.null(s)) return(NULL) + z <- sd$sizes[sd$sizes$year == y & sd$sizes$start == st, , drop = FALSE] + sim <- lapply(seq_len(b$nRuns), function(r) b$gridCell[s$cell[s$run == r & s$fire %in% z$fire[z$run == b$runIds[r]]]]) + all <- c(obs, unlist(sim)); rr <- (all - 1L) %/% g$ncol + 1L; cc <- (all - 1L) %% g$ncol + 1L + r0 <- max(1L, min(rr) - margin); r1 <- min(g$nrow, max(rr) + margin); c0 <- max(1L, min(cc) - margin); c1 <- min(g$ncol, max(cc) + margin) + win <- as.vector(t(outer((r0:r1 - 1L) * g$ncol, c0:c1, `+`))) # the window's cells, row by row, as terra orders them + layer <- function(cells) { v <- scored[win]; v[match(cells, win)] <- 1L; v } + r <- terra::rast(nrows = r1 - r0 + 1L, ncols = c1 - c0 + 1L, nlyrs = 1L, crs = g$crs, + extent = terra::ext(g$xmin + (c0 - 1L) * resX, g$xmin + c1 * resX, g$ymax - r1 * resY, g$ymax - (r0 - 1L) * resY)) + id <- paste0(y, "_", st); d <- file.path(out, id); dir.create(d, showWarnings = FALSE) + wr <- function(x, nm, f) { names(x) <- nm; terra::writeRaster(x, file.path(d, f), datatype = "INT1U", gdal = "COMPRESS=DEFLATE", overwrite = TRUE) } + wr(terra::setValues(r, layer(obs)), "observed", "observed.tif") + wr(terra::rast(lapply(sim, function(cl) terra::setValues(r, layer(cl)))), bands, "predicted.tif") + data.frame(fireId = id, year = y, start = st, obsHa = sd$fires$obsHa[i], obsCells = length(obs)) + }) + fires <- do.call(rbind, rows) + utils::write.csv(fires, file.path(out, "fires.csv"), row.names = FALSE) + invisible(fires) +} diff --git a/R/readFireSenseHindcast.R b/R/readFireSenseHindcast.R index c2b73f1..35be29b 100644 --- a/R/readFireSenseHindcast.R +++ b/R/readFireSenseHindcast.R @@ -139,7 +139,7 @@ readHindcastObserved <- function(rec, hindcastDir, elf, scored, minHa) { } ## A raster's grid as the `grid` of the ELF input (see the top of R/spatialTests.R) -gridOf <- function(r) list(nrow = terra::nrow(r), ncol = terra::ncol(r), xmin = terra::xmin(r), xmax = terra::xmax(r), ymin = terra::ymin(r), ymax = terra::ymax(r)) +gridOf <- function(r) list(nrow = terra::nrow(r), ncol = terra::ncol(r), xmin = terra::xmin(r), xmax = terra::xmax(r), ymin = terra::ymin(r), ymax = terra::ymax(r), crs = terra::crs(r)) ## For each cell of a grid of `n` cells, its number among the scored cells `scoredCells` (0 where it is not scored) toScoredIndex <- function(scoredCells, n) { i <- integer(n); i[scoredCells] <- seq_along(scoredCells); i } @@ -149,7 +149,8 @@ toScoredIndex <- function(scoredCells, n) { i <- integer(n); i[scoredCells] <- s #' `hindcast_observedPoints.gpkg` and `hindcast_observedPolys.gpkg`; the other years' observed points and polygons come from the record `rec` (as [readHindcastObserved()]). Each year is reduced as #' it is read ([ignitionYear()], the burned cells of each run), so no stack of maps is held. Burns are on the cells of `core` (the burnable core, as the other tests count them). #' @param rec [observedRecord()]. @param hindcastDir,elf,scored,sets As [readHindcastSim()]. @param core [hindcastCore()]. -#' @return `list(ign, burn)`, see the top of `R/spatialTests.R` (`burn` also has `grid` and `gridCell`, the grid and the grid cell of each scored cell); `NULL` when the hindcast has no ignition maps. +#' @return `list(ign, burn)`, see the top of `R/spatialTests.R` (`burn` also has `grid` and `gridCell`, the grid and the grid cell of each scored cell, `runIds`, the run of [readHindcastSim()] of each burn run, +#' and in `sim` a `fire` column, the fire's number in its run: its burn ID); `NULL` when the hindcast has no ignition maps. readHindcastLocation <- function(rec, hindcastDir, elf, scored, sets, core) { dirs <- function(y) file.path(hindcastDir, elf, y, sets) maps <- function(y, what) unlist(lapply(dirs(y), function(d) Sys.glob(file.path(d, paste0("hindcast_", what, "_rep*.tif"))))) @@ -169,13 +170,24 @@ readHindcastLocation <- function(rec, hindcastDir, elf, scored, sets, core) { perYear <- lapply(stats::setNames(scored, scored), function(y) { ign <- ignitionYear(terra::rast(maps(y, "ignitionProb")), { f <- own(y, "hindcast_observedPoints.gpkg"); if (!is.null(f)) terra::vect(f) }) ids <- maps(y, "burnID") - burn <- do.call(rbind, lapply(seq_along(ids), function(r) { i <- toScored[which(!is.na(terra::values(terra::rast(ids[r]))[, 1]))]; i <- i[i > 0]; data.frame(cell = i, run = rep(r, length(i))) })) - list(ign = ign, burn = burn, nRuns = length(ids)) + burn <- do.call(rbind, lapply(seq_along(ids), function(r) { + v <- terra::values(terra::rast(ids[r]))[, 1]; g <- which(!is.na(v)); i <- toScored[g] + data.frame(cell = i[i > 0], run = rep(r, sum(i > 0)), fire = as.integer(v[g][i > 0])) })) + list(ign = ign, burn = burn, nRuns = length(ids), runIds = burnRunIds(ids)) }) + runIds <- perYear[[1]]$runIds + if (!all(vapply(perYear, function(x) identical(x$runIds, runIds), TRUE))) stop(elf, ": the burn maps of the scored years are not of the same runs") list(ign = list(grid = grid, points = pointsOf, sim = lapply(perYear, `[[`, "ign")), - burn = list(nCells = length(scoredCells), nRuns = perYear[[1]]$nRuns, obs = obsBurn, sim = lapply(perYear, `[[`, "burn"), grid = grid, gridCell = scoredCells)) + burn = list(nCells = length(scoredCells), nRuns = perYear[[1]]$nRuns, runIds = runIds, obs = obsBurn, sim = lapply(perYear, `[[`, "burn"), grid = grid, gridCell = scoredCells)) } +## The run (as `run` of [readHindcastSim()]) of each `hindcast_burnID_rep.tif` of `files`: rep NN of the `hindcast_reps.csv` beside it +burnRunIds <- function(files) vapply(files, function(f) { + r <- readHindcastSetFiles(dirname(f))$reps; i <- match(as.integer(sub("^hindcast_burnID_rep(\\d+)\\.tif$", "\\1", basename(f))), r$rep) + if (is.na(i)) stop(f, " has no rep in hindcast_reps.csv") + hindcastRun(r[i, , drop = FALSE], as.integer(basename(dirname(f)))) +}, 0, USE.NAMES = FALSE) + #' Where each simulated fire started #' #' `fireSense_burnSummary.csv` of every set has one row per fire: its start cell `igLoc` (a cell of the hindcast grid), its time `year` (year + 0.001 x the rep's index, the `time` of `hindcast_reps.csv`) and its size. @@ -234,7 +246,7 @@ readHindcastSeeded <- function(starts, hindcastDir, elf, scored, sets, flammable if (sum(vapply(one, `[[`, 0, "dropped"))) message(elf, ": ", sum(vapply(one, `[[`, 0, "dropped")), " seeded escapes start in no observed polygon and are not scored in S8 and S9") fires <- do.call(rbind, lapply(one, `[[`, "fires")) list(fires = fires, obsCells = do.call(rbind, lapply(one, `[[`, "obsCells")), - sizes = merge(starts[starts$year %in% scored, c("year", "run", "start", "ha")], fires[c("year", "start")], by = c("year", "start"))[c("year", "run", "start", "ha")]) + sizes = merge(starts[starts$year %in% scored, c("year", "run", "start", "ha", "fire")], fires[c("year", "start")], by = c("year", "start"))[c("year", "run", "start", "ha", "fire")]) } #' ELF median of the fit's climate covariate (CMD) for every year of the record @@ -327,7 +339,7 @@ hindcastReadFiles <- function(elf, hindcastDir, inputsDir, covariateDir, ledgerF ## the inner functions readFireSenseHindcast() calls: Cache() sees the body of the function it is given, not of these readerCallees <- c("hindcastFinishedYears", "readHindcastSim", "hindcastBurnMap", "hindcastCore", "hindcastFlammable", "observedRecord", "buildObservedRecord", "readHindcastObserved", "readLedgerRow", "burnRate", "readHindcastCovariate", "fread0", - "readHindcastLocation", "ignitionYear", "hindcastSet", "hindcastRun", "gridOf", "toScoredIndex", "readHindcastSetFiles", "rasterizedValues", "readHindcastStarts", "hindcastInSample", "readHindcastSeeded") + "readHindcastLocation", "ignitionYear", "hindcastSet", "hindcastRun", "gridOf", "toScoredIndex", "readHindcastSetFiles", "rasterizedValues", "readHindcastStarts", "hindcastInSample", "readHindcastSeeded", "burnRunIds") #' Read every finished ELF's hindcast, each read cached #' diff --git a/fireSimulator_validation.R b/fireSimulator_validation.R index c059cb1..18d587e 100644 --- a/fireSimulator_validation.R +++ b/fireSimulator_validation.R @@ -48,9 +48,10 @@ defineModule(sim, list( cacheKey = FALSE), # as hindcastPath defineParameter("hindcastYears", "integer", 1986:2024, NA, NA, "Scored years; an ELF is scored only when every one is finished."), defineParameter("hindcastSets", "integer", 1L, NA, NA, "Hindcast parameter sets ( folders) read."), - defineParameter("bySet", "logical", FALSE, NA, NA, + defineParameter("bySet", "logical", NA, NA, NA, paste("Also score each parameter set of each ELF on its own (the `paramSet` column of hindcast_reps.csv and hindcast_sizes.csv, else the set folder):", - "gate ratios with single-run 2.5-97.5% ranges, annual-area skill and gate results, one row per set, written to wave1_bySet.csv.")), + "gate ratios with single-run 2.5-97.5% ranges, annual-area skill, gate results and, in-sample, S8 and S9, one row per set, written to wave1_bySet.csv.", + "NA: when some ELF's runs are of more than one set.")), defineParameter("mode", "character", "score", NA, NA, paste("'score': score the hindcast (the default). 'weights': tune objective weights from `weightsTerms`, `weightsBySet` and `weightsGrid` (`tuneWeights()`):", "no hindcast is read; the tables `weights_report.csv` (the held-out ELFs' rows: the result), `weights_tuning.csv` (tune ELFs, labelled) and `weights_losses.csv` go to outputPath.", @@ -110,7 +111,7 @@ defineModule(sim, list( createsOutput("anovaResults", "list", "Mode 'anova': `terms` (per metric and term: df, pctSS, dropOnePctSS, F, p, note), `cells` and `long`, from computeAnova(); the first two are also written to /anova_terms.csv and anova_cells.csv."), createsOutput("weightsResults", "list", "Mode 'weights': `report`, `tuning` and `losses`, from tuneWeights(); also written to /weights_report.csv, weights_tuning.csv and weights_losses.csv."), createsOutput("bySetResults", "data.frame", "Mode 'score' with bySet: scoreBySet() of every ELF, written to /wave1_bySet.csv. NULL otherwise."), - createsOutput("validationResults", "list", "runWave1() result: results, gates, bias, climate, slopeSplit, perELF, flagged. Also saved to /wave1.rds, its results table to wave1_results.csv, and the page to validation.html.") + createsOutput("validationResults", "list", "runWave1() result: results, gates, bias, climate, slopeSplit, perELF, flagged. Also saved to /wave1.rds, its results table to wave1_results.csv, and the page to validation.html; in-sample ELFs also get their seeded fires as maps in /seededFires (writeSeededFires()).") ) )) @@ -161,7 +162,8 @@ doEvent.fireSimulator_validation <- function(sim, eventTime, eventType) { reportELFs = orNULL(p$weightsReportELFs), leaveOneOut = p$weightsLeaveOneOut, loss = p$weightsLoss) } else { sim$validationResults <- runWave1(sim$validationELFs, minHa = scoredMinHa(p), nBoot = p$nBoot, nNull = p$nNull, nPerm = p$nPerm, seed = p$seed) - sim$bySetResults <- if (p$bySet) do.call(rbind, lapply(sim$validationELFs, scoreBySet, nBoot = p$nBoot, seed = p$seed)) + bySet <- if (is.na(p$bySet)) any(vapply(sim$validationELFs, function(e) length(unique(e$simYears$paramSet)) > 1L, TRUE)) else p$bySet + sim$bySetResults <- if (bySet) do.call(rbind, lapply(sim$validationELFs, scoreBySet, nBoot = p$nBoot, seed = p$seed)) } params(sim)$fireSimulator_validation$.neverCache <- union(p$.neverCache, "writeOutputs") # a user's `.neverCache` replaces the default; writeOutputs is never cached sim <- scheduleEvent(sim, start(sim), "fireSimulator_validation", "writeOutputs", eventPriority = 6) @@ -187,7 +189,8 @@ doEvent.fireSimulator_validation <- function(sim, eventTime, eventType) { out <- outputPath(sim); dir.create(out, recursive = TRUE, showWarnings = FALSE) saveRDS(sim$validationResults, file.path(out, "wave1.rds")) utils::write.csv(sim$validationResults$results, file.path(out, "wave1_results.csv"), row.names = FALSE) - if (P(sim)$bySet) utils::write.csv(sim$bySetResults, file.path(out, "wave1_bySet.csv"), row.names = FALSE) + if (!is.null(sim$bySetResults)) utils::write.csv(sim$bySetResults, file.path(out, "wave1_bySet.csv"), row.names = FALSE) + for (e in sim$validationELFs) writeSeededFires(e, file.path(out, "seededFires")) # in-sample ELFs only: the fires S8 and S9 score, as maps buildValidationPage(sim$validationELFs, sim$validationResults$gates, file.path(out, "validation.html"), template = file.path(modulePath(sim), currentModule(sim), "pageTemplate.html"), title = P(sim)$pageTitle, subtitle = P(sim)$pageSubtitle, label = P(sim)$simLabel, diff --git a/tests/testthat/helper-source.R b/tests/testthat/helper-source.R index bed3532..ff78df7 100644 --- a/tests/testthat/helper-source.R +++ b/tests/testthat/helper-source.R @@ -53,3 +53,23 @@ runModule <- function(root, params, inputPath = root, .env = parent.frame()) { } ## the cache entries (one per cached event run) in /cache nCached <- function(root) length(unique(reproducible::showCache(file.path(root, "cache"), verbose = -1)$cacheId)) + +## A 40 x 40 grid of 1 km cells, every cell scored. `nFires` observed escapes (one per year), each a blob of `n` cells around its start; the model's runs are +## `perfect` (the observed blob), `shuffled` (the observed blob's cells moved to random places, sizes kept) or `random` (every cell burns with probability 0.3 in every run). +seedToy <- function(model = c("perfect", "shuffled", "random"), nFires = 39L, nRuns = 20L, seed = 1, inSample = TRUE) { + model <- match.arg(model); set.seed(seed) + grid <- list(nrow = 40L, ncol = 40L, xmin = 0, xmax = 40000, ymin = 0, ymax = 40000); n <- 1600L + xy <- gridXY(grid, seq_len(n)); years <- 1986L:2024L + fires <- data.frame(year = years[seq_len(nFires)], start = sample.int(n, nFires, TRUE), nObs = sample(10:40, nFires, TRUE)) + blob <- Map(function(s, k) circleCells(xy, c(xy$x[s], xy$y[s]), k), fires$start, fires$nObs) + fires$obsHa <- fires$nObs * 100 + sizeOf <- if (model == "shuffled") sample(fires$obsHa) else fires$obsHa # a model that sizes fires at random + sizes <- do.call(rbind, lapply(seq_len(nRuns), function(r) data.frame(year = fires$year, run = r, start = fires$start, ha = sizeOf))) + sim <- lapply(stats::setNames(fires$year, fires$year), function(y) { i <- match(y, fires$year); do.call(rbind, lapply(seq_len(nRuns), function(r) { + k <- switch(model, perfect = blob[[i]], shuffled = sample.int(n, fires$nObs[i]), random = which(stats::runif(n) < 0.3)); data.frame(cell = k, run = rep(r, length(k))) })) }) + obs <- lapply(stats::setNames(fires$year, fires$year), function(y) blob[[match(y, fires$year)]]) + list(elf = paste0("seed-", model), inSample = inSample, simYears = data.frame(year = rep(fires$year, each = nRuns), run = rep(seq_len(nRuns), nFires)), + location = list(burn = list(nCells = n, nRuns = nRuns, obs = obs, sim = sim, grid = grid, gridCell = seq_len(n)), + seeded = list(fires = fires[, c("year", "start", "obsHa")], sizes = sizes, + obsCells = do.call(rbind, Map(function(y, s, b) data.frame(year = y, start = s, cell = b), fires$year, fires$start, blob))))) +} diff --git a/tests/testthat/test-byset.R b/tests/testthat/test-byset.R index 9cb909d..e4ac0a0 100644 --- a/tests/testthat/test-byset.R +++ b/tests/testthat/test-byset.R @@ -57,3 +57,46 @@ test_that("scoreBySet: one row per paramSet x ELF, medians with single-run range expect_equal(out$area_ratio[1], gateG2(e$simYears[e$simYears$paramSet == 1, ], e$obsYears, nBoot = 20)$value) # the module's own gate, on that set's runs expect_equal(out$nRuns, c(3L, 3L)) }) + +## An in-sample ELF with two sets of 2 runs: set 1 sizes and shapes the fires as observed, set 2 is seedToy's "random" model (test-escapes.R) +twoSetSeeded <- function() { + e <- toyElf(nRuns = 4L, perfect = TRUE) + setOf <- function(run) ifelse(run <= 2L, 1L, 2L); idOf <- function(run) setOf(run) * 1000L + (run - 1L) %% 2L + 1L + e$simYears$paramSet <- setOf(e$simYears$run); e$simYears$run <- idOf(e$simYears$run) + e$simSizes$paramSet <- setOf(e$simSizes$run); e$simSizes$run <- idOf(e$simSizes$run) + p <- seedToy("perfect", nRuns = 2L, seed = 2); r <- seedToy("random", nRuns = 2L, seed = 2) # same seed: the same observed fires + r$location$seeded$sizes$ha <- r$location$seeded$sizes$ha * stats::runif(nrow(r$location$seeded$sizes), 0.1, 10) + loc <- p$location + loc$seeded$sizes <- rbind(transform(p$location$seeded$sizes, run = 1000L + run), transform(r$location$seeded$sizes, run = 2000L + run)) + loc$burn$sim <- Map(function(a, b) rbind(a, transform(b, run = run + 2L)), p$location$burn$sim, r$location$burn$sim) + loc$burn$nRuns <- 4L; loc$burn$runIds <- c(1001L, 1002L, 2001L, 2002L) + e$location <- loc; e$inSample <- TRUE + e +} + +test_that("elfOfSet keeps the set's seeded sizes and burns, and numbers the burn runs 1..n", { + e <- twoSetSeeded(); s2 <- elfOfSet(e, 2L) + expect_equal(sort(unique(s2$location$seeded$sizes$run)), c(2001L, 2002L)) + expect_equal(s2$location$burn$nRuns, 2L); expect_equal(s2$location$burn$runIds, c(2001L, 2002L)) + expect_equal(sort(unique(unlist(lapply(s2$location$burn$sim, `[[`, "run")))), 1:2) + expect_equal(nrow(s2$location$burn$sim[[1]]), sum(e$location$burn$sim[[1]]$run > 2L)) + e$location$burn$runIds <- NULL + expect_null(elfOfSet(e, 1L)$location$burn) # burns that cannot be split by set are dropped, not scored as the set's +}) + +test_that("scoreBySet scores S8 and S9 per set for an in-sample ELF: the set that sizes and shapes fires as observed ranks first", { + out <- scoreBySet(twoSetSeeded(), nBoot = 20) + expect_true(all(c("S8_rho", "S8_rho_runLo", "S8_rho_runHi", "S8_log2ratio", "S8_nFires", "S9_aucDiff", "S9_auc", "S9_aucDiff_runLo") %in% names(out))) + expect_equal(out$S8_rho[1], 1); expect_equal(out$S8_log2ratio[1], 0) + expect_lt(out$S8_rho[2], 0.9) + expect_gt(out$S9_aucDiff[1], out$S9_aucDiff[2]) + expect_equal(out$S9_auc[1], escapeStats$S9$auc(scoreS9(elfOfSet(twoSetSeeded(), 1L))$scores)) # the module's own S9, on that set's runs + expect_false("S8_rho" %in% names(scoreBySet({ e <- twoSetSeeded(); e$inSample <- FALSE; e }, nBoot = 20))) # not in-sample: no S8, S9 +}) + +test_that("burnRunIds: each burn map's run is paramSet x 1000 + rep of the hindcast_reps.csv beside it", { + d <- file.path(withr::local_tempdir(), "1"); dir.create(d) + write.csv(data.frame(rep = 1:4, paramSet = c(1L, 2L, 1L, 2L), time = 1986 + (0:3) / 1000), file.path(d, "hindcast_reps.csv"), row.names = FALSE) + expect_equal(burnRunIds(file.path(d, sprintf("hindcast_burnID_rep%02d.tif", c(1, 2, 4)))), c(1001, 2002, 2004)) + expect_error(burnRunIds(file.path(d, "hindcast_burnID_rep09.tif")), "no rep") +}) diff --git a/tests/testthat/test-escapes.R b/tests/testthat/test-escapes.R index 35e61fc..d7647bf 100644 --- a/tests/testthat/test-escapes.R +++ b/tests/testthat/test-escapes.R @@ -1,25 +1,5 @@ ## S8 (size given escape), S9 (shape given escape) and the S7 switch-off for in-sample runs. Synthetic ELFs with a known truth. -## A 40 x 40 grid of 1 km cells, every cell scored. `nFires` observed escapes (one per year), each a blob of `n` cells around its start; the model's runs are -## `perfect` (the observed blob), `shuffled` (the observed blob's cells moved to random places, sizes kept) or `random` (every cell burns with probability 0.3 in every run). -seedToy <- function(model = c("perfect", "shuffled", "random"), nFires = 39L, nRuns = 20L, seed = 1, inSample = TRUE) { - model <- match.arg(model); set.seed(seed) - grid <- list(nrow = 40L, ncol = 40L, xmin = 0, xmax = 40000, ymin = 0, ymax = 40000); n <- 1600L - xy <- gridXY(grid, seq_len(n)); years <- 1986L:2024L - fires <- data.frame(year = years[seq_len(nFires)], start = sample.int(n, nFires, TRUE), nObs = sample(10:40, nFires, TRUE)) - blob <- Map(function(s, k) circleCells(xy, c(xy$x[s], xy$y[s]), k), fires$start, fires$nObs) - fires$obsHa <- fires$nObs * 100 - sizeOf <- if (model == "shuffled") sample(fires$obsHa) else fires$obsHa # a model that sizes fires at random - sizes <- do.call(rbind, lapply(seq_len(nRuns), function(r) data.frame(year = fires$year, run = r, start = fires$start, ha = sizeOf))) - sim <- lapply(stats::setNames(fires$year, fires$year), function(y) { i <- match(y, fires$year); do.call(rbind, lapply(seq_len(nRuns), function(r) { - k <- switch(model, perfect = blob[[i]], shuffled = sample.int(n, fires$nObs[i]), random = which(stats::runif(n) < 0.3)); data.frame(cell = k, run = rep(r, length(k))) })) }) - obs <- lapply(stats::setNames(fires$year, fires$year), function(y) blob[[match(y, fires$year)]]) - list(elf = paste0("seed-", model), inSample = inSample, simYears = data.frame(year = rep(fires$year, each = nRuns), run = rep(seq_len(nRuns), nFires)), - location = list(burn = list(nCells = n, nRuns = nRuns, obs = obs, sim = sim, grid = grid, gridCell = seq_len(n)), - seeded = list(fires = fires[, c("year", "start", "obsHa")], sizes = sizes, - obsCells = do.call(rbind, Map(function(y, s, b) data.frame(year = y, start = s, cell = b), fires$year, fires$start, blob))))) -} - test_that("S8: a perfect size model has rho 1 and log ratio 0; a model that sizes fires at random has rho near 0", { p <- scoreS8(seedToy("perfect", seed = 2)) expect_equal(rankCor(p$scores$obsHa, p$scores$simMedian), 1); expect_equal(stats::median(p$scores$log2ratio), 0) @@ -148,3 +128,30 @@ test_that("the page has the `Given an escape` table only when S8 and S9 rows exi expect_match(page(r$results), 'const ESCAPE = [{"elf":"all: pooled"', fixed = TRUE) expect_match(page(r$results[!r$results$test %in% c("S8", "S9"), ]), "const ESCAPE = [];", fixed = TRUE) }) + +test_that("writeSeededFires: one observed and one predicted GeoTIFF per seeded fire; only the fire grown from the start, NA off the scored cells", { + grid <- list(nrow = 20L, ncol = 20L, xmin = 0, xmax = 2000, ymin = 0, ymax = 2000, crs = terra::crs("EPSG:3978")) + gridCell <- setdiff(seq_len(400L), c(42L, 43L)) # two cells not scored (a lake) + sc <- function(cells) match(cells, gridCell) # grid cell -> scored cell + obsGrid <- c(41L, 44L, 61L, 62L); st <- 61L + e <- list(elf = "9.9", inSample = TRUE, location = list( + burn = list(nCells = length(gridCell), nRuns = 2L, runIds = c(1003L, 2004L), grid = grid, gridCell = gridCell, + sim = list(`1986` = data.frame(cell = sc(c(61L, 81L, 300L, 61L, 62L)), run = c(1L, 1L, 1L, 2L, 2L), fire = c(1L, 1L, 2L, 2L, 2L)))), + seeded = list(fires = data.frame(year = 1986L, start = st, obsHa = 7), + sizes = data.frame(year = 1986L, run = c(1003L, 2004L), start = st, ha = c(2, 2), fire = c(1L, 2L)), # in run 2 the fire from this start is fire 2 + obsCells = data.frame(year = 1986L, start = st, cell = sc(obsGrid))))) + dir <- withr::local_tempdir() + f <- writeSeededFires(e, dir, margin = 1L) + expect_equal(f, data.frame(fireId = "1986_61", year = 1986L, start = 61L, obsHa = 7, obsCells = 4L)) + expect_equal(read.csv(file.path(dir, "9.9", "fires.csv"))$fireId, "1986_61") + o <- terra::rast(file.path(dir, "9.9", "1986_61", "observed.tif")); p <- terra::rast(file.path(dir, "9.9", "1986_61", "predicted.tif")) + expect_equal(names(p), c("set1_rep3", "set2_rep4")); expect_true(terra::compareGeom(o, p)); expect_equal(terra::crs(o), grid$crs) + ## in grid coordinates: cell 41 is row 3, col 1; the window is rows 2-6 (cell 300, row 15, is the other fire of run 1, left out), cols 1-5 + at <- function(r, cells) terra::extract(r, cbind((((cells - 1L) %% 20L) + 0.5) * 100, 2000 - ((cells - 1L) %/% 20L + 0.5) * 100)) + expect_equal(at(o, c(41L, 44L, 61L, 62L, 63L))[, 1], c(1, 1, 1, 1, 0)) + expect_true(all(is.na(at(o, c(42L, 43L))[, 1]))) # not scored: NA, not 0 + expect_equal(at(p, c(61L, 81L, 62L))$set1_rep3, c(1, 1, 0)); expect_equal(at(p, c(61L, 81L, 62L))$set2_rep4, c(1, 0, 1)) + expect_equal(terra::nrow(o), 5L); expect_equal(terra::ncol(o), 5L) # rows 2-6, cols 1-5: the fires plus one cell + e$location$burn$runIds <- NULL + expect_null(writeSeededFires(e, dir)) # no run ids: the fires cannot be tied to their runs +}) From 52cf97ed57fa9bc10117c91b79e7485e2fde24a5 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Thu, 3 Dec 2026 21:58:14 -0700 Subject: [PATCH 2/2] Review: grid cells via terra, hindcastRunParts(), reps.csv read once per folder Co-Authored-By: Claude Opus 5.5 --- R/escapeTests.R | 15 +++++++-------- R/readFireSenseHindcast.R | 14 ++++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/R/escapeTests.R b/R/escapeTests.R index 3c2d235..f536a85 100644 --- a/R/escapeTests.R +++ b/R/escapeTests.R @@ -118,9 +118,9 @@ escapePageRows <- function(results) { writeSeededFires <- function(elf, dir, margin = 10L) { sd <- elf$location$seeded; b <- elf$location$burn if (is.null(sd) || is.null(b$runIds) || !"fire" %in% names(sd$sizes)) return(invisible(NULL)) - g <- b$grid; resX <- (g$xmax - g$xmin) / g$ncol; resY <- (g$ymax - g$ymin) / g$nrow - scored <- rep(NA_integer_, g$nrow * g$ncol); scored[b$gridCell] <- 0L - bands <- paste0("set", b$runIds %/% 1000L, "_rep", b$runIds %% 1000L) + g <- b$grid; tmpl <- terra::rast(nrows = g$nrow, ncols = g$ncol, extent = terra::ext(g$xmin, g$xmax, g$ymin, g$ymax), crs = g$crs) + scored <- rep(NA_integer_, terra::ncell(tmpl)); scored[b$gridCell] <- 0L + bands <- with(hindcastRunParts(b$runIds), paste0("set", paramSet, "_rep", rep)) out <- file.path(dir, elf$elf); dir.create(out, recursive = TRUE, showWarnings = FALSE) rows <- lapply(seq_len(nrow(sd$fires)), function(i) { y <- sd$fires$year[i]; st <- sd$fires$start[i]; s <- b$sim[[as.character(y)]] @@ -128,12 +128,11 @@ writeSeededFires <- function(elf, dir, margin = 10L) { if (!length(obs) || is.null(s)) return(NULL) z <- sd$sizes[sd$sizes$year == y & sd$sizes$start == st, , drop = FALSE] sim <- lapply(seq_len(b$nRuns), function(r) b$gridCell[s$cell[s$run == r & s$fire %in% z$fire[z$run == b$runIds[r]]]]) - all <- c(obs, unlist(sim)); rr <- (all - 1L) %/% g$ncol + 1L; cc <- (all - 1L) %% g$ncol + 1L - r0 <- max(1L, min(rr) - margin); r1 <- min(g$nrow, max(rr) + margin); c0 <- max(1L, min(cc) - margin); c1 <- min(g$ncol, max(cc) + margin) - win <- as.vector(t(outer((r0:r1 - 1L) * g$ncol, c0:c1, `+`))) # the window's cells, row by row, as terra orders them + all <- c(obs, unlist(sim)); rr <- range(terra::rowFromCell(tmpl, all)); cc <- range(terra::colFromCell(tmpl, all)) + r <- terra::crop(tmpl, terra::ext(tmpl, cells = terra::cellFromRowColCombine(tmpl, c(max(1L, rr[1] - margin), min(g$nrow, rr[2] + margin)), + c(max(1L, cc[1] - margin), min(g$ncol, cc[2] + margin))))) + win <- terra::cells(tmpl, terra::ext(r)) # the window's cells of the grid, in the order of r's values layer <- function(cells) { v <- scored[win]; v[match(cells, win)] <- 1L; v } - r <- terra::rast(nrows = r1 - r0 + 1L, ncols = c1 - c0 + 1L, nlyrs = 1L, crs = g$crs, - extent = terra::ext(g$xmin + (c0 - 1L) * resX, g$xmin + c1 * resX, g$ymax - r1 * resY, g$ymax - (r0 - 1L) * resY)) id <- paste0(y, "_", st); d <- file.path(out, id); dir.create(d, showWarnings = FALSE) wr <- function(x, nm, f) { names(x) <- nm; terra::writeRaster(x, file.path(d, f), datatype = "INT1U", gdal = "COMPRESS=DEFLATE", overwrite = TRUE) } wr(terra::setValues(r, layer(obs)), "observed", "observed.tif") diff --git a/R/readFireSenseHindcast.R b/R/readFireSenseHindcast.R index 35be29b..1e12162 100644 --- a/R/readFireSenseHindcast.R +++ b/R/readFireSenseHindcast.R @@ -17,6 +17,8 @@ hindcastFinishedYears <- function(hindcastDir, elf, years = seq(1986L, 2021L, 5L ## The parameter set of the rows of a hindcast file (its `paramSet` column when it has one, else the set folder `s`) and the run (`set * 1000 + rep`) hindcastSet <- function(x, s) if ("paramSet" %in% names(x)) as.integer(x$paramSet) else rep(as.integer(s), NROW(x)) hindcastRun <- function(x, s) hindcastSet(x, s) * 1000L + x$rep +## The set and rep of runs numbered by hindcastRun() +hindcastRunParts <- function(run) data.frame(paramSet = run %/% 1000L, rep = run %% 1000L) ## The reps and the fire sizes of one set folder `d` readHindcastSetFiles <- function(d) list(reps = fread0(file.path(d, "hindcast_reps.csv")), sizes = fread0(file.path(d, "hindcast_sizes.csv"))) @@ -182,11 +184,11 @@ readHindcastLocation <- function(rec, hindcastDir, elf, scored, sets, core) { } ## The run (as `run` of [readHindcastSim()]) of each `hindcast_burnID_rep.tif` of `files`: rep NN of the `hindcast_reps.csv` beside it -burnRunIds <- function(files) vapply(files, function(f) { - r <- readHindcastSetFiles(dirname(f))$reps; i <- match(as.integer(sub("^hindcast_burnID_rep(\\d+)\\.tif$", "\\1", basename(f))), r$rep) - if (is.na(i)) stop(f, " has no rep in hindcast_reps.csv") - hindcastRun(r[i, , drop = FALSE], as.integer(basename(dirname(f)))) -}, 0, USE.NAMES = FALSE) +burnRunIds <- function(files) unsplit(lapply(split(files, dirname(files)), function(f) { + r <- readHindcastSetFiles(dirname(f[1]))$reps; i <- match(as.integer(sub("^hindcast_burnID_rep(\\d+)\\.tif$", "\\1", basename(f))), r$rep) + if (anyNA(i)) stop(paste(f[is.na(i)], collapse = ", "), " has no rep in hindcast_reps.csv") + hindcastRun(r[i, , drop = FALSE], as.integer(basename(dirname(f[1])))) +}), dirname(files)) #' Where each simulated fire started #' @@ -339,7 +341,7 @@ hindcastReadFiles <- function(elf, hindcastDir, inputsDir, covariateDir, ledgerF ## the inner functions readFireSenseHindcast() calls: Cache() sees the body of the function it is given, not of these readerCallees <- c("hindcastFinishedYears", "readHindcastSim", "hindcastBurnMap", "hindcastCore", "hindcastFlammable", "observedRecord", "buildObservedRecord", "readHindcastObserved", "readLedgerRow", "burnRate", "readHindcastCovariate", "fread0", - "readHindcastLocation", "ignitionYear", "hindcastSet", "hindcastRun", "gridOf", "toScoredIndex", "readHindcastSetFiles", "rasterizedValues", "readHindcastStarts", "hindcastInSample", "readHindcastSeeded", "burnRunIds") + "readHindcastLocation", "ignitionYear", "hindcastSet", "hindcastRun", "gridOf", "toScoredIndex", "readHindcastSetFiles", "rasterizedValues", "readHindcastStarts", "hindcastInSample", "readHindcastSeeded", "burnRunIds", "hindcastRunParts") #' Read every finished ELF's hindcast, each read cached #'