Repository navigation
Build ignition and spread covariates once per year (hindcast reps) - #44
Merged
Merged
Conversation
…same-year step Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
… when it changes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
eliotmcintire
added a commit
that referenced
this pull request
Nov 15, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A hindcast year runs 20 repetitions, and each one rebuilt the same land and climate tables, about 12 seconds each. They are now built once per year and reused while their inputs stay the same.
Affects: hindcast speed (about 4 minutes per hindcast year); the tables are unchanged.
Reuses:
vegetationStamp()(the stamp offuelClassTablesThisYear(), lifted out so both use it),useOwnELFRows(),prepare_IgnitionAndEscapePredict(),prepare_SpreadPredict(),rlang::hash(); new:covariatesBuilt()andinputDigest()(nothing existing tells whether the covariates match their inputs).Technical details
Defect: the
prepIgAndEscPredictDataandprepSpreadPredictDataevents (fireSense_dataPrepPredict.R:327-337) call the builders at everyfireTimeStep, although nothing they read changes inside a year. A second defect, found while testing a land-cover change:ELFfuelSets()keptmod$ELFrstLCCandmod$ELFlandcoverDTsfrom the first call for the whole run, so a changedrstLCC_RTMorflammableRTMwas never seen.Fix:
covariatesBuilt(sim, what)skips the build when a stamp of the inputs and the output are unchanged. The stamp isrlang::hash()digests (not sums, which miss swapped pixels) of the year,cohortData,pixelGroupMap,flammableRTM, the climate layers used, time since disturbance,landcoverDT,rstLCC_RTM(andlightningDaysfor ignition), plus the fitted rows afteruseOwnELFRows():.ELFind, polygon IDs and the column names of eachparams(from which the fuel-class roles are read, and which spreadFit rewrites).ELFfuelSets()now makes the per-ELF land cover again when the digests ofrstLCC_RTMorflammableRTMchange.rlangis added toreqdPkgs. The inputs both events read are hashed once per step (sharedInputStamp(), kept inmodbytime(sim)): hashing five 20M-cell rasters and a 20M-row table twice withdigesttook 6.4 s, once withrlang::hash()2.0 s. Theyearcolumn of the tables carries the first step's time (nothing reads it).Tests (tests/testthat/test-covariatesOncePerYear.R): four steps of one year build once and equal one step (ignition alone, spread alone, and both together as in a hindcast); a cohortData change rebuilds once; two swapped pixels rebuild; a land-cover change rebuilds with several ELFs (fails without the
ELFfuelSets()fix); a change of.ELFindrebuilds; a new year rebuilds. Full suite: branch 339 passed, 0 failed, 0 skipped.🤖 Generated with Claude Code
https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6