Repository navigation
Split the spread climate covariate into a between-year and a within-year term - #244
Open
eliotmcintire wants to merge 2 commits into
Open
eliotmcintire wants to merge 2 commits into
eliotmcintire wants to merge 2 commits into
Conversation
…ear term: splitSpreadClimate(), climateSplitRanges() and helpers; spreadFitLedgerInputs() finds a split fit's climate variable Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## development #244 +/- ##
===============================================
+ Coverage 93.52% 93.54% +0.02%
===============================================
Files 67 68 +1
Lines 5265 5285 +20
===============================================
+ Hits 4924 4944 +20
Misses 341 341 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 17, 2026
…r fit and prediction) and elfCellLabels() (one cell-label lookup) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
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 fire spread model uses one climate coefficient for both the year-to-year swings and the differences between places within a year. This adds the shared tools to give each its own coefficient, so a run can test it as a separate arm.
Affects: nothing changes unless a run turns on the new split-climate option in
fireSense_dataPrepFit; then the spread model has two climate terms instead of one.Technical details
Part of one change with PredictiveEcology/fireSense_dataPrepFit, fireSense_spreadFit and fireSense_spreadPredict (the other three PRs
Depends-onthis one). In ELF 6.6.2 thel_pow05fit gives climate 2% of the between-year variance of the spread linear predictor, although annual climate correlates 0.47-0.60 with annual fire size. One coefficient serves the spatial gradient (confounded with fuel) and the year-to-year swings.Fix: new
R/spreadClimateSplit.R.splitSpreadClimate(dt, vars, ref, by)replaces climateCbyC_yr(the year's median ofCover the ELF's burnable pixels,stats::median(na.rm = TRUE)at full precision, same value for every pixel of a year) andC_dev(C - C_yr). The fit calls it per year (by = "year"), the prediction once for the year's layer. This is the one place the median is computed.climateSplitCols(),climateSplitBase(),isClimateSplitCol()and the suffixesclimateSplitYrSuffix,climateSplitDevSuffixare the one definition of the names.climateSplitRanges(ranges)adds fixed rescaling ranges:_yrhas the variable's range,_devthe same width centred on 0 (c(-w/2, w/2)), so one unit of each is the same amount of climate. A range already given for a split name is kept.climateSplitRefPixels(pixelID, flammableRTM, elfPixels)is the one choice of the pixels the median is over: the ELF's flammable pixels. The fit passes its burnable pixels; the prediction passes its table's rows withflammableRTMand the ELF's own cells.elfCellLabels(r)is the one lookup of the ELF of each cell ofrasterToMatchLargeELF(category labels, else values), used byfireSense_spreadPredictandfireSense_dataPrepPredict.spreadFitLedgerInputs()took the climate variable of a fit from its parameter names, which would not findCMDinCMD_yr/CMD_dev. It now strips the suffixes (climateSplitBase()).Sign rule (applied by name in
fireSense_spreadFit, no change there): names withCMDorMDCare bounded below by 0, soCMD_yr,CMD_dev,cumMDC_yrare >= 0.Tmaxsmterms are not constrained today, soTmaxsm_yr/Tmaxsm_devare not either. Bounds are not narrowed otherwise.Consumers checked and unchanged because they read the design columns generically:
spreadDesignCols(), covariate rescaling and centring,objFunSpread.R,spreadProbGates,spreadClimateCols()(both terms count as climate for theclimateOutsidelink).Overlap with the
spreadInteractionswork: that one also touches the formula and design columns. This diff adds one new file and a one-line change inspreadFitLedgerInputs().Merge order with the interaction PRs (#242, PredictiveEcology/fireSense_dataPrepFit#107, PredictiveEcology/fireSense_spreadFit#131, PredictiveEcology/fireSense_spreadPredict#43), whichever merges first: interaction terms must use
fireSenseUtils::climateSplitCols(spreadVars), soCMD_yr:fuelandCMD_dev:fuel; and in fireSense_spreadPredict the interaction PR'sneeded <- spreadSourceCols(fitted)must come after the split block ofspreadProbOneELF(), which makesCMD_yrandCMD_devfromCMD.Reuses:
stats::median,data.tableupdate join,climateCovRanges,spreadFitLedgerInputs(), the label lookup ofELFblendWeights()(moved here aselfCellLabels(), andfireSense_dataPrepPredict's second copy now calls it); new:splitSpreadClimate,climateSplitCols,climateSplitBase,isClimateSplitCol,climateSplitRanges,climateSplitRefPixels(nothing existing builds or names the two terms, derives their ranges, or picks the reference pixels),elfCellLabels(the moved lookup, one copy).Tests (new
test-spreadClimateSplit.R, 20 expectations): names; the between term is constant within a year and equals the median over the reference pixels (not the fitted buffer's);C_dev = C - C_yr; a fit-style call (by year, buffer pixels) and a prediction-style call (one year, whole ELF) give the same values; NA is ignored; ranges; a split fit's variable is found inspreadFitLedgerInputs(). Also: reference pixels drop non-flammable and blend-zone cells; a fit-style table and a prediction table with an extra non-flammable row give the sameC_yr;elfCellLabels(). Full suite: base 0 failures, 0 errors, 16 skips, 3138 passed; branch 0 failures, 0 errors, 16 skips, 3167 passed. On base the new file errors (the functions do not exist).rcmdcheck(--no-manual --no-tests,_R_CHECK_FORCE_SUGGESTS_=false, scratch librarylibClimSplit+lib9175): 0 errors, 0 warnings, 2 notes, neither from this change (the worktree's.git;objFunInner, which this diff does not touch).No version bump. The module
reqdPkgsfloors are raised after this merges.🤖 Generated with Claude Code
https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6