Apply bridge gradient along downstream path in frs_cluster#157
Merged
NewGraphEnvironment merged 4 commits intomainfrom Apr 14, 2026
Merged
Apply bridge gradient along downstream path in frs_cluster#157NewGraphEnvironment merged 4 commits intomainfrom
NewGraphEnvironment merged 4 commits intomainfrom
Conversation
Relates to #153 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upstream cluster check now traces segment-by-segment via FWA_Upstream
join against the streams table, mirroring the downstream pattern:
cluster_maximums → upstream segments ordered ASC → distance cap →
nearest_connect vs nearest_barrier → keep if spawning before barrier.
Previously used FWA_Upstream as a boolean ("does spawning exist anywhere
upstream?") with no gradient or distance constraint. This caused excess
rearing: clusters passed the upstream check even when a >5% gradient
barrier existed between rearing and spawning.
Both .frs_cluster_upstream() and .frs_cluster_both() updated.
Relates to #153
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
FWA_Upstream returns all upstream segments including tributaries. row_number() on a branching network interleaves tributary segments with mainstem — a steep tributary gets a lower rn than nearby mainstem spawning, incorrectly disconnecting rearing 123m from spawning with zero gradient. Upstream check reverted to boolean FWA_Upstream (spawning exists anywhere upstream). Downstream path gradient kept — fwa_downstreamtrace is linear, row_number works. direction="both" now correctly combines upstream boolean + downstream path gradient. Relates to #153 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
bridge_gradientandbridge_distancealong the downstream trace path infrs_cluster— segment-by-segment gradient stop and distance cap viafwa_downstreamtraceFWA_Upstream— spawning exists anywhere upstream). Path gradient is unreliable upstream becauseFWA_Upstreamreturns all tributaries;row_number()interleaves tributary segments with mainstem, incorrectly disconnecting rearing near mainstem spawningdirection="both": upstream boolean + downstream path gradientTest plan
Fixes #153
Relates to NewGraphEnvironment/sred-2025-2026#16
🤖 Generated with Claude Code