Skip to content

Add coreFraction to the predict covariates, as the fit has it - #51

Merged
eliotmcintire merged 3 commits into
developmentfrom
coreFractionShared
Nov 20, 2026
Merged

eliotmcintire merged 3 commits into
developmentfrom
coreFractionShared

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

The prediction step now records, for each coarse pixel, how much of it lies in the study core, in the same way the fit does. Without it, the year-level dryness average in the prediction included the surrounding buffer while the fit's did not, which shifted every year's predicted ignitions by the same factor.

Affects: fireSense_igAndEscapePred_Covariates gains a coreFraction column (not a covariate); predicted ignitions of fits with a year climate term now use the core pixels only.

Depends-on: PredictiveEcology/fireSenseUtils#254

Technical details

Defect: prepIgAndEscPredictData (fireSense_dataPrepPredict.R, the mergePreparedCovs() call, about line 694) built the covariates with no coreFraction; only fireSense_dataPrepFit adds it. fireSenseUtils::yearClimateMeans() therefore averaged buffer pixels in predict and core pixels in the fit.

Fix: after the merge, fireSenseUtils::addCoreFraction() with list(<year label>), sim$flammableRTM (the raster the coarse covariates are built from), sim$rasterToMatchLargeELF and P(sim)$igAggFactor. That factor is forced to the fit module's value by paramCheckOtherMods(sim, "igAggFactor") (line 472), so it equals the fit's igAggFactor. The result does not depend on the year, so it is kept in mod (like mod$fuelCovsStatic), keyed by fireSenseUtils::coreFractionKey() (flammable cells, core raster and grid, igAggFactor), and remade whenever the key changes; each year only relabels it. onMissing = "zero": a pixel with no flammable cell gets 0, with one warning that gives the count. A multi-ELF categorical raster or none gives 1. Floor fireSenseUtils >= 0.2.3.9183.

Reuses: fireSenseUtils::addCoreFraction() (moved from fireSense_dataPrepFit in fireSenseUtils#254); new: nothing.

fireSense_ignitionPredict: scaleAsFit() only touches columns the fit scaled (coreFraction is stored unscaled), and xgbFeatureNames() excludes it; a test there runs real boosters on covariates with the extra column.

Tests (fireSenseUtils 0.2.3.9183 in a scratch library): full suite branch 419 pass, 0 fail; base 406 pass, 0 fail. New: made once over three years, remade when flammableRTM or rasterToMatchLargeELF changes; coreFraction with no raster (all 1), and with a core/buffer raster (1, 0, 1, 0 on the toy grid), and the fit-style table (addCoreFraction() on the same covariates without the column) gives the same yearly mean as the predict table.

Cache keys: this module's code changed, which is part of each cached event's key, so its cached events re-run once. The covariate merge here runs with useCache = FALSE. I did not run a cache comparison.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh

eliotmcintire and others added 2 commits November 19, 2026 23:26
…reFraction, level helper, warnings

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
@eliotmcintire
eliotmcintire merged commit 6586387 into development Nov 20, 2026
7 checks passed
@eliotmcintire
eliotmcintire deleted the coreFractionShared branch November 20, 2026 13:39
eliotmcintire added a commit that referenced this pull request Nov 20, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant