Skip to content

prepInputsFireYear(latestYear): stand age in reburned perimeters for earlier data years - #275

Merged
eliotmcintire merged 1 commit into
developmentfrom
fix/fire-year-latestYear
Oct 15, 2026
Merged

eliotmcintire merged 1 commit into
developmentfrom
fix/fire-year-latestYear

Conversation

@eliotmcintire

Copy link
Copy Markdown
Contributor

Stand ages inside old burns were wrong where a pixel burned twice: the later fire hid the earlier one, so for an earlier vegetation year the pixel kept its satellite age. The fire map used for a vegetation year now ignores fires after that year.

Affects: stand age (and biomass re-estimated from it) inside reburned fire perimeters, for vegetation years earlier than the latest fire.

Technical details

Defect: prepInputsFireYear() (R/prepInputObjects.R, the terra::rasterize(..., fun = max) call) keeps only the most recent fire of any year per pixel, and replaceAgeInFires() only changes pixels with fire year <= startTime. A pixel burned in 1980 and 2015 holds 2015, so for startTime 1990 it was skipped.

Fix: new argument latestYear (default Inf, so other callers are unchanged) drops fires after that year before rasterizing; prepInputsStandAgeMap() passes dataYear when it builds the raster itself (a firePerimeters supplied by the caller is used as given).

Tests (offline, file:// sources): prepInputsFireYear(latestYear = 1990) gives 1980 for a 1980/2015 pixel and 2015 with no limit; replaceAgeInFires(startTime = 1990) then gives age 10; no fires before the limit gives an empty raster; prepInputsStandAgeMap(dataYear = 2011) gives 31 at that pixel. These fail on development (4 and 1 failures) and pass on the branch. Full testthat run: development 0 failures, 1380 passed, 21 skipped; branch 0 failures, 1387 passed, 21 skipped. R CMD check --no-manual (scratch library phase4/lib, _R_CHECK_FORCE_SUGGESTS_=false because BioSIM is not installed): 0 errors, 0 warnings, 1 note (existing undefined-global notes in .adjustNewCohortsERG and dropUnsupportedSpecies).

🤖 Generated with Claude Code

…at or before the data year

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliotmcintire eliotmcintire added bug Something isn't working backwards compatible Existing code and results keep working unchanged labels Oct 15, 2026
@eliotmcintire
eliotmcintire merged commit 6343951 into development Oct 15, 2026
14 checks passed
@eliotmcintire
eliotmcintire deleted the fix/fire-year-latestYear branch October 15, 2026 23:48
eliotmcintire added a commit that referenced this pull request Oct 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

backwards compatible Existing code and results keep working unchanged bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant