Skip to content

Hindcast youngAge built as the spread fit builds it (youngAgeAtYear) - #46

Merged
eliotmcintire merged 3 commits into
developmentfrom
hindcast-youngage-at-year
Nov 16, 2026
Merged

eliotmcintire merged 3 commits into
developmentfrom
hindcast-youngage-at-year

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

A hindcast of a fire year counted "recently burned" land differently from the spread model's fit, so it saw too many young pixels, in both the spread and the ignition covariates. It now counts them the same way as the fit.

Affects: hindcast spread and ignition covariates (and their cache keys) change for every hindcast year; forecasts are unchanged.

Depends-on: PredictiveEcology/fireSenseUtils#239

Technical details

Defect: for a hindcast of year Y, youngAge came from cohort ages (fireSenseCovariatesCreate()) and the data year's non-forest time since disturbance, which the ageNonForest event never advances inside one year (yearsElapsed 0). Fires between the data year and Y were ignored. The ignition path had the same defect: prepare_IgnitionAndEscapePredict() called prepare_FuelCovsCoarse() with the un-aged time since disturbance, where the fit uses prepare_FuelCovsCoarseByYear() (fireSense_dataPrepFit.R, ignition fit). The spread fit uses fireSenseUtils::youngAgeAtYear() (addAnnualYoungAge, fireSense_dataPrepFit.R:1121-1123). On ELF 6.6.2, 2010: youngAge was 2.8% of burned pixels in the hindcast, 1.5% in the fit.

Fix: new hindcastYoungAgeInputs() gives the data year's nonForest_timeSinceDisturbances element (dataYearElement(before = TRUE), the rule takeLatestVegetation() uses), Y = floor(time(sim)) and the fires (firePixelsByYear() from historicalFireRaster, else firePolysForAge: the fit's choice; a hindcast with neither stops). Spread: fireSenseCovariatesCreate(youngAge = FALSE) as the fit does (its fuel table is made with cutoff -1), then youngAge from youngAgeAtYear(); fuel, non-forest land cover and treed wetland are then cleared on young pixels in the table with fireSenseUtils::clearYoungAge() (the rule the ignition fit uses). fireSense_spreadPredict alone is not enough: it clears fuel only for a linear-fuel fit (fireSense_spreadPredict.R:512-516), so a log-scale fit would have kept fuel on young pixels. Ignition: prepare_FuelCovsCoarseByYear(). nonForestCanBeYoungAge = FALSE stops in a hindcast with fireSenseUtils::stopIfNonForestCannotBeYoung(), as the fit does. Forecasts (a module simulates cohortData) are unchanged: their cohorts are simulated. New inputs firePolysForAge, historicalFireRaster (from fireSense_dataPrepFit); The inputs are worked out once per year and kept in mod, not at every covariate event. Floor: set after fireSenseUtils#239 merges.

Reuses: fireSenseUtils::youngAgeAtYear(), prepare_FuelCovsCoarseByYear(), firePixelsByYear(), stopIfNonForestCannotBeYoung(), tsdTable(), clearYoungAge(), dataYearElement(), simulatedObjects(); new: hindcastYoungAgeInputs() (gathers the predict module's inputs for those functions; nothing existing does that) and isHindcast() (the test takeLatestVegetation() had inline, now shared).

Tests (test-latestVegetation.R): a 2004 fire after data year 2003 makes pixels young in a 2005 hindcast and the spread youngAge equals youngAgeAtYear()'s; fires from firePolysForAge; ageing without fires; fuel of cohort-young pixels is kept; fuel and land cover cleared on young pixels in the table (a log-scale fit then needs nothing from fireSense_spreadPredict); a hindcast with no fire data stops; inputs kept once per year; ignition youngAge equals the share of young pixels per coarse cell; nonForestCanBeYoungAge = FALSE stops in a hindcast, not in a forecast; a forecast keeps cohort youngAge. Ten failures on base with these tests, none on the branch. Expectations on youngAge cells 5, 6, 9 changed (time since disturbance, not cohort age, decides) and one fuel comparison moved from cell 1 to cell 2 (cell 1 is now young, so cleared); the test helper gives hindcasts firePolysForAge = list(). Full suite (convertToPackage() + test_local(), one thread, scratch library with the fireSenseUtils branch): branch 395 pass, 0 fail, 0 skip; base 378 pass, 0 fail, 0 skip.

Hindcast covariates, and so cache keys, change.

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

…() with the data year's time since disturbance and the fires after it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
…anBeYoungAge = FALSE stops in a hindcast; fire-source selection through firePixelsByYear

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
…:clearYoungAge), uses the fit's fire source, resolves its inputs once per year

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire
eliotmcintire merged commit 6fa7573 into development Nov 16, 2026
9 checks passed
@eliotmcintire
eliotmcintire deleted the hindcast-youngage-at-year branch November 16, 2026 22:29
eliotmcintire added a commit that referenced this pull request Nov 16, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant