Repository navigation
Predict a fit with split climate terms from the year's climate - #44
Open
eliotmcintire wants to merge 2 commits into
Open
eliotmcintire wants to merge 2 commits into
eliotmcintire wants to merge 2 commits into
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
This branch has not been deployed
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.Merge order with the interaction PRs (PredictiveEcology/fireSenseUtils#242, PredictiveEcology/fireSense_dataPrepFit#107, PredictiveEcology/fireSense_spreadFit#131, #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:
fireSenseUtils::splitSpreadClimate(),climateSplitBase(),isClimateSplitCol(),climateSplitRefPixels()andelfCellLabels()(the label code ofELFblendWeights(), moved to fireSenseUtils); new: nothing in this module.Tests (new
test-climateSplit.R, 5 tests; the new one: a non-flammable row with an extreme value in the covariate table does not move the median): a split row predicts the logistic of the hand-computed linear predictor (median over the burnable pixels, deviation per pixel); 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. Full suite on the branch: 0 failures, 0 errors, 0 skips, 358 passed. On base (origin/development with the new file copied in): 0 failures, 4 errors (the new tests), 0 skips, 352 passed. Ran against the fireSenseUtils branch loaded withpkgload::load_all(), in aSpaDES.core::convertToPackage()copy.No version bump. The
reqdPkgsfloor on fireSenseUtils is set after #244 merges and its version is bumped.🤖 Generated with Claude Code
https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6