Repository navigation
Predict a fit with split climate terms from the year's climate - #44
Merged
Merged
Conversation
… over the ELF's own burnable pixels Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
…me from fireSenseUtils::climateSplitRefPixels(); cell labels from elfCellLabels() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
eliotmcintire
force-pushed
the
climateSplit
branch
from
November 20, 2026 23:40
87761f8 to
f8b5a88
Compare
… an interaction is split too; tests: split with climate in the ceiling, split in an interaction Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
…itSpreadClimate() can add its columns; test of a CMD_yr:fuel interaction Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
eliotmcintire
added a commit
that referenced
this pull request
Nov 21, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
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.
A spread model fitted with the climate split into a between-year and a within-year term needs those two terms rebuilt when it predicts. This makes the predictions do that, from the year's climate, the same way the fit did.
Affects: nothing changes for existing fits. A prediction from a fit with the two climate terms now works and uses the year's regional median of climate, computed over the region's own burnable pixels.
Depends-on: PredictiveEcology/fireSenseUtils#244
Technical details
Part of one change with PredictiveEcology/fireSenseUtils#244, fireSense_dataPrepFit and fireSense_spreadFit. Without this,
spreadProbOneELF()(fireSense_spreadPredict.R) stops for a row withCMD_yr/CMD_devparameters: the prediction covariates haveCMD, not those two, so "the fitted coefficients ... have no covariate".Fix:
spreadProbOneELF()finds the split terms among the fitted names (isClimateSplitCol(),climateSplitBase()) and callsfireSenseUtils::splitSpreadClimate()on its copy of the covariates, as the fit does. The median is over the ELF's flammable pixels, chosen withfireSenseUtils::climateSplitRefPixels(covs$pixelID, flammableRTM, elfPixels), the function the fit uses. The new argumentelfPixels: every row ofcovswith one fitted ELF; with several, the cells ofrasterToMatchLargeELFlabelled with that ELF (not the blend zone, which would shift the median), found withELFcellLabels(), the label step ofELFblendWeights()moved into a function so both use it. One fitted ELF: the table is that ELF'slandcoverDTrows (fuelClassPrep.R:786in fireSenseUtils joins tolandcoverDT;makeLandcoverDT.R:34-41keeps flammable cells with land cover not 0;useOwnELFRows()drops other ELFs), so it already is the fit's burnable pixel set, andflammableRTMis a guard. Several ELFs: the merged table holds every ELF's rows, soelfPixelsselects the ELF's own cells. A row without split terms takes none of these paths.fireSense_dataPrepPredictneeds no change: its covariate table has the base climate variable, and the ledger row's names carry the rest (fireSenseUtils::spreadFitLedgerInputs()now findsCMDfromCMD_yr/CMD_dev, so the climate layer is still requested).Overlap with the
spreadInteractionswork: that one also builds columns inspreadProbOneELF(). This diff adds one block before the "every fitted coefficient needs a covariate" check and one argument.The interaction work (fuel x climate terms) is now on development.
fireSense_dataPrepFitstops whenspreadInteractionsandspreadClimateSplit = TRUEare combined;fireSense_spreadPredictbuilds the split terms for a coefficient such asCMD_yr:fueltoo, so a ledger row with one predicts.Climate in the ceiling and activation (
spreadClimate, now on development): the climate columns ofclimateRefare every annual covariate that is not a 0/1 indicator (fireSenseUtils::spreadClimateCols()), soC_yrandC_devare both climate columns, each with its own reference, and both move the ceiling (or are the linear predictor in activation). Nothing to change here; a new test checks it.Interaction with a split term (2026-11-20): a split fit whose fuel is in the linear range (every real fit) did not predict at all.
spreadProbOneELF()turned the logged fuel to linear withcovs[[cn]] <-(fireSense_spreadPredict.R:572), which copies the table, sosplitSpreadClimate()could no longer addCMD_yr/CMD_devby reference and the prediction stopped with "have no covariate". The earlier split tests had no linear fuel, so they passed. It now usesdata.table::set(). New test: a row with an intercept, centres,youngAgeandCMD_yr:fuelAgives the logistic of the hand-computed linear predictor (product of the centred terms, 0 whereyoungAgecleared the fuel). On the base this test errors; full suite branch 0 failures, 0 errors, 0 skips, 426 passed (base 425). Combined with fireSense_dataPrepFit'sspreadInteractions, which now buildsCMD_yr:fuel.Reuses:
fireSenseUtils::splitSpreadClimate(),climateSplitBase(),isClimateSplitCol(),climateSplitRefPixels()andelfCellLabels()(the label code ofELFblendWeights(), moved to fireSenseUtils); new: nothing in this module.Tests (new
test-climateSplit.R, 7 tests): a split row predicts the logistic of the hand-computed linear predictor (median over the burnable pixels, deviation per pixel); a non-flammable row with an extreme value does not move the median; with only the between term, every pixel gets the same value; with two ELFs each uses the median of its own pixels; a row without split terms is unchanged; a split fit with climate in the ceiling (spreadClimate = "ceiling"row) movespcwith both terms andxholds the fuels only; a coefficientCMD_yr:fuelis built from the split term. Full suite (convertToPackage()copy, fireSenseUtils with the branch installed in a scratch library): base (development 1.2.0.9017) 0 failures, 0 errors, 0 skips, 414 passed; branch 0 failures, 0 errors, 0 skips, 425 passed. On base the new file errors (the functions do not exist).No version bump. The
reqdPkgsfloor on fireSenseUtils is0.2.3.9186, the version fireSenseUtils#244 will have once it merges (development is at 9184; if another fireSenseUtils PR merges first, the floor is raised to match). Until then CI installs 9184, so theDepends-online is what holds this PR back.🤖 Generated with Claude Code
https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6