Skip to content

Option for fits to use the same fire-and-harvest ages as the simulation, including youngAge - #121

Merged
eliotmcintire merged 4 commits into
developmentfrom
feat/disturbance-age-sources
Nov 30, 2026
Merged

eliotmcintire merged 4 commits into
developmentfrom
feat/disturbance-age-sources

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

The vegetation that fire models are fitted on, and their "young stand" covariate, now come from the same fire and harvest history as the simulation's stand ages. Harvested stands count as young, and fire perimeters that didn't burn a pixel no longer make it young. This is opt in for now (ageDisturbanceSources = "all", set in .globals for this module and Biomass_borealDataPrep); fits made with it differ from existing fits.

Affects: fit inputs (each data year's stand ages, youngAge and non-forest time since disturbance) only with ageDisturbanceSources = "all"; nothing changes with the default "NFDB".

Depends-on: PredictiveEcology/LandR#299
Depends-on: PredictiveEcology/Biomass_borealDataPrep#159

Technical details
  • New parameter ageDisturbanceSources (default "NFDB"), the same as Biomass_borealDataPrep's. .inputObjects reads it with SpaDES.core::paramCheckOtherMods(ifSetButDifferent = "error"), so the two must match when both are loaded. It is this module's own parameter because hindcasts run without Biomass_borealDataPrep, and simInit() drops the parameters of a module that isn't loaded (checked: params(sim)$Biomass_borealDataPrep is NULL then).

  • .inputObjects: each data year's standAgeMaps element passes firePerimeters = LandR::prepInputsDisturbanceYear(latestYear = dy) to prepInputsStandAgeMap(). That changes the nested Biomass_borealDataPrep cohortDatas.

  • New input disturbancePixelsByYear: prepInputsDisturbanceYear(byYear = TRUE) on rasterToMatch up to max(fireYears).

  • allFirePixelsByYear() returns disturbancePixelsByYear when present. Otherwise it uses historicalFireRaster, then firePolysForAge, as before. This covers youngAge in spread and ignition covariates.

  • dataPrepBuild: makeTSD() gets the last disturbance year at each data year (disturbanceYearRaster()).

  • LandR::lastDisturbanceYear and LandR::disturbancesByYear are in the cache keys.

  • With "NFDB", or without Biomass_borealDataPrep, nothing changes.

Tests: new test-disturbanceAgeSources.R (8 pass). test-metadata.R (15), test-annualYoungAge.R (21) and test-dataPrepBuild.R (12) pass.

Separate from #120 (start-year ages).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lx3DXfVqAugcusGHygZGJ3

…borealDataPrep

With Biomass_borealDataPrep ageDisturbanceSources = "NFDB+NBAC+CanLaD", the
per-year standAgeMaps reset age with LandR::prepInputsDisturbanceYear(), and a
new disturbancePixelsByYear (fire and harvest by year) replaces firePolysForAge
and historicalFireRaster for time since disturbance (youngAge).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXfVqAugcusGHygZGJ3
@eliotmcintire eliotmcintire added enhancement New feature or request major change Changes behaviour or results in a way users will notice labels Nov 30, 2026
eliotmcintire and others added 2 commits November 30, 2026 16:21
…default "NFDB")

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXfVqAugcusGHygZGJ3
…l" uses now

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXfVqAugcusGHygZGJ3
@eliotmcintire eliotmcintire changed the title Fits use the same fire-and-harvest ages as the simulation, including youngAge Option for fits to use the same fire-and-harvest ages as the simulation, including youngAge Nov 30, 2026
@eliotmcintire eliotmcintire added backwards compatible Existing code and results keep working unchanged and removed major change Changes behaviour or results in a way users will notice labels Nov 30, 2026
… Biomass_borealDataPrep's

A hindcast runs without Biomass_borealDataPrep, and simInit drops the
parameters of a module that is not loaded, so reading
params(sim)$Biomass_borealDataPrep gave a hindcast the default and a youngAge
unlike the fit's. paramCheckOtherMods() stops when both modules are loaded
and differ; set it in .globals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXfVqAugcusGHygZGJ3
@eliotmcintire
eliotmcintire merged commit 1331554 into development Nov 30, 2026
9 checks passed
@eliotmcintire
eliotmcintire deleted the feat/disturbance-age-sources branch November 30, 2026 23:54
eliotmcintire added a commit that referenced this pull request Nov 30, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
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