Skip to content

Filter invalid negative NOAA flood stages in gauge flood-event overlays - #11

Draft
romer8 with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-invalid-flood-stage-values
Draft

Filter invalid negative NOAA flood stages in gauge flood-event overlays#11
romer8 with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-invalid-flood-stage-values

Conversation

Copilot AI commented May 18, 2026

Copy link
Copy Markdown

create_flood_events() was plotting invalid NOAA flood-stage values as real flood stages when categories are undefined, which injected bogus threshold lines and distorted the stage axis. This change ensures only valid non-negative numeric flood stages are rendered.

  • Flood stage validation in create_flood_events()

    • Rejects missing/invalid stage values before plotting:
      • None
      • empty/whitespace strings
      • non-numeric values
      • any negative stage value (including NOAA placeholder-style values such as -9999 after parsing)
  • Consistent rendering values

    • Uses the validated numeric stage_value for shape coordinates (y0, y1) and annotation positioning/text, avoiding raw/unparsed stage values in overlays.
stage = details.get("stage", None)
if stage is None:
    continue

if isinstance(stage, str):
    stage = stage.strip()
    if not stage:
        continue

try:
    stage_value = float(stage)
except (TypeError, ValueError):
    continue

if stage_value < 0:
    continue

Copilot AI changed the title [WIP] Fix invalid flood stage values causing distorted y-axis Filter invalid NOAA flood stage sentinels in gauge flood-event overlays May 18, 2026
Copilot finished work on behalf of romer8 May 18, 2026 23:46
Copilot AI requested a review from romer8 May 18, 2026 23:46
Comment thread tests/test_gauges.py Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this test file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot work on this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed tests/test_gauges.py as requested in commit bd10601.

Comment thread ciroh_plugins/nwmps/gauges.py Outdated
except (TypeError, ValueError):
continue

if stage_value == FLOOD_STAGE_PLACEHOLDER:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we instead make that if ``

Suggested change
if stage_value == FLOOD_STAGE_PLACEHOLDER:
if stage_value < 0:
continue

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in commit f93e863: the flood-stage filter now skips any negative stage_value (if stage_value < 0: continue).

Comment thread ciroh_plugins/nwmps/gauges.py Outdated
# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
FLOOD_STAGE_PLACEHOLDER = -9999.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look my suggestion below

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via the suggested update in commit f93e863.

@romer8

romer8 commented May 19, 2026

Copy link
Copy Markdown
Collaborator

@copilot please address the reviewer's response

Copilot AI changed the title Filter invalid NOAA flood stage sentinels in gauge flood-event overlays Filter invalid negative NOAA flood stages in gauge flood-event overlays May 19, 2026
Copilot finished work on behalf of romer8 May 19, 2026 00:08
Copilot AI requested a review from romer8 May 19, 2026 00:08

Copilot AI commented May 19, 2026

Copy link
Copy Markdown
Author

@copilot please address the reviewer's response

Addressed in f93e863 (updated flood-stage filter to stage_value < 0). I also checked current review threads and don’t see any additional unresolved reviewer response to implement; share the specific thread if you want a further change.

Copilot finished work on behalf of romer8 May 19, 2026 00:10
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.

Invalid flood stage values (-9999) plotted in create_flood_events() causing distorted y-axis

2 participants