Skip to content

replaySave and replayFrom: save and replay the spread-prediction inputs of a hindcast - #45

Merged
eliotmcintire merged 7 commits into
developmentfrom
fastHc-replay
Nov 15, 2026
Merged

eliotmcintire merged 7 commits into
developmentfrom
fastHc-replay

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

A reference hindcast can now keep the land and climate tables it built, and a later job can load them instead of building them. This lets the same year be re-run with other fitted parameters without redoing the vegetation and climate work.

Affects: nothing unless the new settings replaySave or replayFrom are used; hindcast jobs that replay need no climate, vegetation, fit or ELF module.

Depends-on: #44

Reuses: SpaDES.core's outputs()/saveFiles() (its save event) and inputs()/loadFiles() with terra::writeRaster()/rast(), terra::writeVector()/vect(), qs2::qs_save()/qs_read(); new: only the table of which function handles which object (replayObjects, replayHow), the stacking of firePolys (stackFirePolys()/unstackFirePolys(): a list of vectors has no single outputs() function) and the row builders replayOutputs()/replayInputs().

Technical details

No defect; this is the replay path of the fast-hindcast design. With replaySave = TRUE the module's save event (scheduled at .runInitialTime, priority 7, after the first build) adds one row per object it holds to outputs(sim) and schedules SpaDES.core's own save event, which writes replay_<name>_year<time>.<ext> to outputPath(sim). With replayFrom set, .inputObjects adds rows to inputs(sim) and calls loadFiles(), then returns; init returns before Init() and schedules no event. A save first deletes the replay_* files of an earlier save in that folder, so an object missing from the newer save is not replayed from the older one. A folder with two saves of one object is refused.

Bundle (object: who normally makes it; saved when present): fireSense_SpreadCovariates: this module (qs2); flammableRTM: fireSense_dataPrepFit per-year list via this module's Init (tif); rasterToMatch, rasterToMatchELF, rasterToMatchLargeELF: fireSense_ELFs (tif, categories kept); studyAreaWithSpreadParams: fireSense_dataPrepFit, or this module from the ledger (qs2, so its list columns params, sppEquiv, covMinMax_spread survive; a GeoPackage turned params into text); nonEscapedFireSizesHa: fireSense_dataPrepFit (qs2); ignitionFirePoints: fireSense_dataPrepFit (gpkg); firePolys: supplied by the user, no module makes it (stacked into one gpkg with the element names year<YYYY> in a column; a NULL element is dropped; an unnamed list stops). A terra object where a table is expected stops, never reaching qs2. Nothing uses saveRDS.

The module declares the objects other modules make as expectsInput only. A createsOutput for them would make suppliedElsewhere() report them supplied in every run, so fireSense_dataPrepFit would not build firePolys and fireSense_burn would not make nonEscapedFireSizesHa in a predict-only run. A test checks that none is declared.

Tests (tests/testthat/test-replay.R): no createsOutput of other modules' objects; nothing written without replaySave; save then replay gives identical objects of every class, with a ledger-shaped studyAreaWithSpreadParams (list columns), the levels of rasterToMatchLargeELF and the names of firePolys; a second smaller save to the same folder leaves no stale polygon, and an object dropped from a later save is not replayed (fails without the delete); a terra object in a table slot and an unnamed firePolys stop; a replay job builds no fuel classes and runs no build event. Full suite: branch 378 passed, 0 failed, 0 skipped; #44's code with these tests: 340 passed, 7 failed, 4 errors (all in the new tests).

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

eliotmcintire and others added 2 commits November 14, 2026 23:52
…same-year step

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
…dcast job and load them in a replay job

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Nov 15, 2026
eliotmcintire and others added 5 commits November 15, 2026 00:17
… when it changes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
…her modules' objects; sf and tables via qs2

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire
eliotmcintire merged commit 0d94bcf into development Nov 15, 2026
9 checks passed
@eliotmcintire
eliotmcintire deleted the fastHc-replay branch November 15, 2026 07:58
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant