Skip to content

Fit each fire year against vegetation from an earlier year - #73

Merged
eliotmcintire merged 1 commit into
developmentfrom
fix-fire-year-before-data-year
Oct 15, 2026
Merged

eliotmcintire merged 1 commit into
developmentfrom
fix-fire-year-before-data-year

Conversation

@eliotmcintire

Copy link
Copy Markdown
Collaborator

The satellite vegetation of a year already shows part of that year's fires, so the fit learned that fire burns where the vegetation already looks burned. Each fire year now uses vegetation from an earlier year, and the first year of fires, which has no earlier vegetation, can no longer be fitted.

Affects: every spread, ignition and escape fit; fire years now start one year after the first vegetation year (1986), so all ELFs need refitting.

Technical details

Defect: yearGroups() (fireSense_dataPrepFit.R, formerly line 1793), lccShareForYear() (line 988) and fitDecisionYearName() (line 1013) matched a fire year to the data year "at or before" it with fireSenseUtils::dataYearFor() / dataYearElement(). Evidence (6.6.2): pixels burned in 2010 have mean biomass 64 in SCANFI 2005 and 26 in SCANFI 2010, unburned pixels sit near 79 in both; pixels burned in 2011 are still 96 in SCANFI 2010.

Fix: one helper, vegetationYear(fireYears) = fireYears - 1L, is the only statement of the rule; vegetationDataYear() (used by yearGroups()) and the two decision-year lookups go through it. So 1986-1990 use 1985, 1991-2000 use 1990, and so on. yearGroups() stops with a clear error if a fire year is not after the first data year. The fireYears default is now defaultFireYears()[-1L] (1986 on), since fireSenseUtils' default still starts in 1985. fireSenseUtils::dataYearFor()/dataYearElement() are unchanged, so prediction keeps "not after".

Decision year: fitDecisionYear() stays max(fireYears), but the vegetation it reads (treed-wetland share, dom/sec fuel classes) is now that of the data year the last fire year uses, i.e. vegetationYear(max(fireYears)). This keeps the structure decision on the same vegetation the last fire year is fitted with, and a hindcast's run still makes the same decision as the fit. Time since disturbance is unchanged: makeTSD() already uses fires up to year-1 of the data year, which lines up with the new pairing. Roxygen text, parameter descriptions, the Rmd and README were updated.

Tests: new/changed in test-yearGroups.R (1990 pairs with 1985, 1991 with 1990, 2020 with 2010, 2024 with 2020; a fire year equal to the first data year errors), test-lccShareForYear.R, test-joinFireBuffersToVeg.R, test-fireYearsDefault.R. On the old code these fail (14 failures, 3 errors); full module suite via convertToPackage() + test_local(): base 0 failed, 314 passed, 1 skipped; branch 0 failed, 320 passed, 1 skipped (the same skip, the dataPrepBuild equivalence fixture test). Scratch library with fireSenseUtils 0.2.3.9098 and reproducible/SpaDES.core development.

🤖 Generated with Claude Code

A year's satellite vegetation already shows part of that year's fires. yearGroups(), lccShareForYear() and fitDecisionYearName() now look up the data year through one helper, vegetationYear(); fireYears must be after the first dataYear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliotmcintire eliotmcintire added bug Something isn't working breaking change Existing code or results need changes to keep working labels Oct 15, 2026
@eliotmcintire
eliotmcintire merged commit 4ee43e4 into development Oct 15, 2026
9 checks passed
@eliotmcintire
eliotmcintire deleted the fix-fire-year-before-data-year branch October 15, 2026 21:08
eliotmcintire added a commit that referenced this pull request Oct 15, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Existing code or results need changes to keep working bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant