Skip to content

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

Description

@imanmaghami

Hi,

I noticed a small issue in create_flood_events() in gauges.py.

For some gauges (e.g., CORM8), certain flood categories are missing. For example, for this gauge the "action" stage is not defined on the NOAA page. However, the API returns a placeholder value like -9999 for missing stages. Since the current logic only checks for None, these values are still plotted:

stage = details.get("stage", None)
if stage is not None:

This adds invalid threshold lines (e.g., at -9999), stretching the y-axis and distorting the plot.

Suggested fix

Filter out placeholder values:

raw_stage = details.get("stage", None)

if raw_stage in [None, "", -9999, -9999.0, "-9999", "-9999.0"]:
    continue

This ensures that only valid flood stages are plotted when available.

Screenshots

Before fix:


After fix:


Happy to open a PR if needed.

Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions