Repository navigation
Fit each fire year against vegetation from an earlier year - #73
Merged
Merged
Conversation
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
added a commit
that referenced
this pull request
Oct 15, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
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) andfitDecisionYearName()(line 1013) matched a fire year to the data year "at or before" it withfireSenseUtils::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 byyearGroups()) 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. ThefireYearsdefault is nowdefaultFireYears()[-1L](1986 on), since fireSenseUtils' default still starts in 1985.fireSenseUtils::dataYearFor()/dataYearElement()are unchanged, so prediction keeps "not after".Decision year:
fitDecisionYear()staysmax(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