Skip to content

#226: PARS vignette accessible_km bcfp-equivalence demo (v0.44.1)#229

Merged
NewGraphEnvironment merged 5 commits into
mainfrom
226-vignette-accessible-km
Jul 5, 2026
Merged

#226: PARS vignette accessible_km bcfp-equivalence demo (v0.44.1)#229
NewGraphEnvironment merged 5 commits into
mainfrom
226-vignette-accessible-km

Conversation

@NewGraphEnvironment

Copy link
Copy Markdown
Owner

Summary

Extends vignettes/pars-habitat-connectivity.Rmd to demonstrate accessible_km bcfishpass-equivalence, and regenerates the cached artifacts from the post-#223 state.

New Accessible habitat (km) section: a link-vs-bcfishpass roll-up table (bull-trout accessible / spawning / rearing, from cached pars_accessible.rds) + computed prose — link models 6,822.5 km of accessible bull-trout habitat against bcfishpass's 6,822.9 km, a −0.01% difference (the #223 access-segmentation fix; spawning/rearing agree within the 5% habitat band). It bridges the two parity lenses: the aggregate habitat totals match to hundredths of a percent even where the per-segment mapping_code disagrees, because the disagreements fall on short reaches that don't move the totals.

Full faithful regeneration (the load-bearing bit)

"Regenerate the artifacts from the merged state" was not docs-only. fresh_default (the Arctic-grayling schema) was still on pre-#223 segmentation (48,558 PARS segments vs fresh's 97,538). The gpkg's single streams layer joins fresh geometry + mapping_code_bt to fresh_default mapping_code_gr on id_segment, so a naive regeneration would have attached grayling tokens to mismatched geometry and shipped a corrupted grayling map.

Fix: re-modelled the default config for PARS into fresh_default (data-raw/wsg_run_one.R + a merge = TRUE recompute via wsg_recompute_one.R for cross-WSG ;DAM) so both configs share segmentation. The join is then faithful — exact GR segment count (19,232) and 99.93% aggregate length; the residual per-segment wiggle is local habitat-break redistribution, sub-pixel at basin scale. Added a segmentation-parity guard to data-raw/wsg_vignette_data.R that refuses a mixed-segmentation build so this class of bug can't silently recur.

Also

  • Stale hardcoded grayling map-caption counts (19,233 / 31,932 / 1,764) are now computed inline from the loaded layer (→ 19,232 / 38,622 / 257), so they track the artifact.
  • data-raw/wsg_vignette_data.R gains the accessible roll-up cache (pars_accessible.rds), mirroring data-raw/parity_crosssection.R's validated lnk_rollup_wsg() + fresh.streams_vw_bcfp IN (1,2) computation.
  • mapping_code parity refreshes 99.04% → 98.91% (denser post-BT/ST accessible_km over-credit: access segmentation drops the accessibility frontier #223 segmentation).
  • Verified with a database-free knit — accessible numbers + computed captions render, the only lnk_db_conn() is in an eval = FALSE demo chunk. /code-check guarded a latent diff_pct div-by-zero on the generic-reuse path.
  • v0.44.1 (patch — docs + data-gen; regenerated binary pars.gpkg).

Closes #226. Relates to #221, #223. SRED: NewGraphEnvironment/sred#24.

🤖 Generated with Claude Code

https://claude.ai/code/session_014kSEJoad4Bc553qU8eFiE6

NewGraphEnvironment and others added 5 commits July 4, 2026 08:37
Extend PARS vignette to demonstrate accessible_km bcfp-equivalence. Full faithful regen scope: re-model stale fresh_default (GR) PARS post-#223, regenerate all cached artifacts, add accessible_km subsection. Phases + live-verified findings scaffolded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014kSEJoad4Bc553qU8eFiE6
Phase 2+3. data-raw/wsg_vignette_data.R gains a link (lnk_rollup_wsg) vs bcfp (streams_vw_bcfp, IN (1,2)) accessible/spawning/rearing km rollup -> pars_accessible.rds, mirroring parity_crosssection.R's validated computation. Adds a segmentation-parity guard that refuses to build the gpkg when fresh/fresh_default disagree by >1% (the pre-#223 grayling-corruption class).

Regenerated all cached artifacts from the post-#223 merged state (fresh_default PARS re-modelled + merge=TRUE recompute first): accessible 6822.47|6822.88|-0.01% (exact), spawning +0.93%, rearing -0.53%; mapping_code parity 98.91%; gpkg 11.9 MB, 8 layers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014kSEJoad4Bc553qU8eFiE6
Adds '### Accessible habitat (km)' under the parity section: a link-vs-bcfp km table (accessible/spawning/rearing) from pars_accessible.rds + computed prose (6,822.5 vs 6,822.9 km, -0.01%) bridging to the per-segment mapping_code disagreements. Loads pars_accessible.rds and lists it under Cached inputs.

Fixes the stale hardcoded map captions (19,233/31,932/1,764) by inline-computing n_gr/n_bt/n_gronly from the loaded streams layer so they track the cached artifact. Verified via a DB-free knit (accessible numbers + computed captions render; stale values gone).

code-check: guard diff_pct against a zero bcfp denominator (NA, not Inf/NaN) on the generic-reuse path; PARS artifact unaffected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014kSEJoad4Bc553qU8eFiE6
#226 PARS vignette accessible_km bcfp-equivalence demo + full post-#223 artifact regeneration (re-modelled fresh_default grayling schema, segmentation guard, computed map captions). Docs + data-gen only; patch bump.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014kSEJoad4Bc553qU8eFiE6
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014kSEJoad4Bc553qU8eFiE6
@NewGraphEnvironment NewGraphEnvironment merged commit 3caa71e into main Jul 5, 2026
1 check passed
@NewGraphEnvironment NewGraphEnvironment deleted the 226-vignette-accessible-km branch July 5, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend PARS vignette to demonstrate accessible_km bcfp-equivalence

1 participant