Skip to content

In-sample hindcasts: no S7; new S8 (size given escape) and S9 (shape given escape) - #33

Merged
eliotmcintire merged 2 commits into
developmentfrom
insample-tests
Dec 2, 2026
Merged

eliotmcintire merged 2 commits into
developmentfrom
insample-tests

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Some hindcasts spread the fires that were actually observed, from their real start points. For those runs the old "where fire happens" score for burned cells looked good (AUC about 0.9) only because the fires start in the right place. This PR stops scoring that for those runs and adds two scores of what a fire does once it has escaped: how big it gets, and what shape it takes.

Affects: scores of in-sample (observed-escape) hindcasts only: S7 rows disappear for them, and S8 and S9 rows and a "Given an escape" table appear. Normal runs are unchanged.

Technical details

Defect. R/spatialTests.R scoreS7 scored every ELF with location$burn, including runs that seed the observed escapes (FS_HC_IGNITIONS=observedEscapes), where the whole-ELF AUC only shows that fires start where the observed ones did.

In-sample detection. The hindcast files record no setting; only the folder name (_obsEsc) and the run name carry it. So it is read from the data (hindcastInSample()): in every year with a fire, every run starts the same fires from the same cells (igLoc of fireSense_burnSummary.csv), with at least two runs. readFireSenseHindcast() has a new argument inSample (default NA: detect; TRUE/FALSE override) and puts inSample and location$seeded in the ELF input. scoreS7 returns NULL when elf$inSample is true.

Linking fires to escapes. fireSense_burnSummary.csv has one row per fire, in the order of fire_id in hindcast_sizes.csv and of the values of that rep's hindcast_burnID_rep*.tif; the rep comes from time in hindcast_reps.csv. The sizes of the two files are compared, and the read stops if they differ. The start cell is igLoc. The start is tied to the observed polygon of hindcast_observedPolys.gpkg that holds it (starts in no polygon are dropped with a message; none were on the real data). Observed size is the polygon rasterized on the burnable cells (core and buffer), which reproduces hindcast_observedSizes.csv on 11.3 / 2000.

S8 (R/escapeTests.R): per seeded fire, median over runs of the final size against the observed size. Per ELF rho (Spearman), log2ratio (median log2 of simulated over observed, as in bias.R) and nFires; the range is the 2.5-97.5% of single runs. Pooled with bootstrapPooled() (median over ELFs, bootstrap over ELFs and fires).

S9: per fire with N observed scored cells, the circle around its start holding the 2N nearest scored cells (circleCells()); positives are the fire's cells in it, negatives the rest; each cell scored by the share of runs that burned it; aucOf(). Baseline: each cell of the circle scored by minus its distance to the start, same AUC (aucDist); the headline is aucDiff, the model's AUC minus it. Per ELF the median over fires (range: median over fires of each single run's 0/1 map), shareInside (share of the fire's cells inside the circle) and nFires. Not scored for normal runs: their fires start elsewhere than the observed ones, so the circle is not defined.

Page. New sortable "Given an escape" table, hidden when there are no S8/S9 rows. wave1_results.csv gets tests S8 and S9.

Reuses: aucOf, longRows (new nUnits argument; callers unchanged), bootstrapPooled, quantRange, ratioCell, gridXY, scoredYears, hindcastFlammable, readHindcastLocation (now also returns grid and gridCell), the ELF tagging idiom in runWave1. Lifted out of existing code and used by old and new callers: pageRowsOf/resultCell (from locationPageRows; the location and escape tables use them), hindcastSet/hindcastRun, readHindcastSetFiles (sim and starts readers), rasterizedValues (location and seeded readers), gridOf, toScoredIndex, rankCor (from bootstrapRankDiff). Not changed: scoreRanking still calls cor itself, because rankCor returns NA for fewer than 3 pairs and drops NA pairs, so the behaviour would differ. New: scoreS8, scoreS9, circleCells/sqDist (nothing picks the k nearest cells to a point), escapeResultRows, escapePageRows, readHindcastStarts, hindcastInSample, readHindcastSeeded (nothing read the burn summary's start cells).

Tests. New tests/testthat/test-escapes.R (12 tests): perfect size model gives rho 1 and log ratio 0, shuffled gives rho near 0; the circle holds exactly 2N cells; perfect shape gives AUC 1, random about 0.5; elongated fire reports its share inside; S7 absent for in-sample and present for normal; pooled rows; page rows; reader detection and link. On development: all new tests error (functions missing); full suite 142 tests, 0 failures. On this branch: full suite 154 tests, 0 failures, 0 skipped (OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1, testthat::test_dir).

Real data (GPSC, read-only; score_ClimBaseline_20261125_obsEsc and _obsEsc_yeDraw, ELFs 6.6.2, 11.3, 11.4, 14.3, 39 years, 20 runs, all detected in-sample): pooled S8 rho 0.24 / 0.23, pooled S9 AUC 0.94, distance-only AUC 0.66, difference 0.25-0.26; per ELF numbers are in the PR comment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh

…given escape)

S7's whole-ELF AUC is about 0.9 in a hindcast that spreads the observed escapes, only because
the fires start where the observed ones did. It is no longer scored for such runs. S8 and S9
score what a fire does once it has escaped: its final size and its shape around its start.
A run is detected as in-sample from fireSense_burnSummary.csv (every run starts the same fires).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Does not break existing behaviour labels Dec 2, 2026
@eliotmcintire

Copy link
Copy Markdown
Contributor Author

Real-data check (GPSC, read-only; 39 years, 20 runs; all four ELFs detected as in-sample; every seeded start fell in an observed polygon). Range is the 2.5-97.5% of single runs; pooled range is the bootstrap.

_obsEsc / _obsEsc_yeDraw

ELF fires S8 rho S8 log2(sim/obs) S9 AUC S9 share of fire in circle
6.6.2 90 0.20 [0.05, 0.26] / 0.22 [0.00, 0.32] 0.02 [-0.49, 0.34] / 0.26 [-0.21, 0.43] 0.95 [0.68, 0.74] / 0.95 [0.67, 0.74] 0.34 / 0.34
11.3 225 0.41 [0.19, 0.33] / 0.39 [0.14, 0.29] 0.04 [-0.36, 0.43] / 0.01 [-0.34, 0.53] 0.94 [0.66, 0.70] / 0.94 [0.67, 0.70] 0.44 / 0.44
11.4 195 0.29 [0.03, 0.25] / 0.23 [0.02, 0.22] 0.22 [-0.45, 0.29] / 0.35 [-0.55, 0.40] 0.89 [0.62, 0.64] / 0.89 [0.62, 0.65] 0.57 / 0.57
14.3 141 (S9: 140) 0.05 [-0.10, 0.16] / 0.06 [-0.04, 0.19] 0.17 [-0.35, 0.25] / 0.21 [-0.61, 0.27] 0.94 [0.66, 0.70] / 0.94 [0.66, 0.70] 0.43 / 0.43
pooled 651 0.24 [0.04, 0.41] / 0.23 [0.06, 0.39] 0.11 [-0.09, 0.39] / 0.24 [-0.07, 0.51] 0.94 [0.90, 0.95] / 0.94 [0.90, 0.95] 0.43 / 0.43

The S9 ELF value ranks cells by the share of 20 runs, so it sits above the single-run range (one run is a 0/1 map). The S8 ELF rho uses the median over runs of each fire's size, so it is also above the single-run range. Files: fast/scratch/insampleTests/S89_results_*.csv on the GPSC.

…, distance-only baseline for S9

pageRowsOf/resultCell serve the location and escape tables; longRows takes nUnits; readHindcastSetFiles
and rasterizedValues are used by the sim, starts, location and seeded readers. S9 reports the AUC of a
distance-only score (closer to the start is likelier burned) and the model's AUC minus it as the headline.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
@eliotmcintire

Copy link
Copy Markdown
Contributor Author

Update after review: S9 now has a distance-only baseline (each cell of the circle scored by minus its distance to the start, same AUC). Headline aucDiff = model AUC minus baseline AUC. _obsEsc / _obsEsc_yeDraw, range = single runs (pooled: bootstrap):

ELF fires model AUC distance-only AUC difference
6.6.2 90 0.949 / 0.949 0.656 0.250 [-0.008, 0.034] / 0.260 [-0.010, 0.033]
11.3 225 0.937 / 0.935 0.631 0.283 [0.012, 0.043] / 0.279 [0.015, 0.044]
11.4 195 0.893 / 0.894 0.682 0.216 [-0.058, -0.026] / 0.215 [-0.058, -0.022]
14.3 140 0.940 / 0.938 0.660 0.258 [-0.011, 0.021] / 0.255 [-0.025, 0.021]
pooled 650 0.938 / 0.937 0.658 0.254 [0.218, 0.283] / 0.257 [0.217, 0.280]

Read with care: the 0.94 uses the share of 20 runs per cell. A single run's own map scores 0.62-0.74, which is about the distance-only 0.63-0.68, so the single-run difference is near 0 (11.4 slightly below). Most of the model's 0.25 gain over distance comes from averaging the runs, not from any one run's shape.

@eliotmcintire
eliotmcintire merged commit 5e05d9d into development Dec 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Does not break existing behaviour enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant