From 80be565fc418de600b47be943a0eb594c402f6dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 23:38:44 +0000 Subject: [PATCH 1/8] Initial plan From fab74bae8fb2ceb8dd83aee412dc8da3ae96e052 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 23:41:28 +0000 Subject: [PATCH 2/8] fix: skip placeholder flood stage values in flood event annotations Agent-Logs-Url: https://github.com/FIRO-Tethys/ciroh_plugins/sessions/0f553e01-181b-4fb4-8454-e2472d9d0e0e Co-authored-by: romer8 <43544549+romer8@users.noreply.github.com> --- ciroh_plugins/nwmps/gauges.py | 75 +++++++++++++++++++++-------------- tests/test_gauges.py | 34 ++++++++++++++++ 2 files changed, 79 insertions(+), 30 deletions(-) create mode 100644 tests/test_gauges.py diff --git a/ciroh_plugins/nwmps/gauges.py b/ciroh_plugins/nwmps/gauges.py index 7ab46e2..37b845f 100644 --- a/ciroh_plugins/nwmps/gauges.py +++ b/ciroh_plugins/nwmps/gauges.py @@ -131,37 +131,52 @@ def create_flood_events(flood_data): for category, details in categories.items(): stage = details.get("stage", None) - if stage is not None: - shapes.append( - { - "type": "line", - "x0": 0, - "x1": 1, - "xref": "paper", - "y0": stage, - "y1": stage, - "yref": "y1", - "line": { - "color": category_colors.get(category.lower(), "black"), - "width": 2, - "dash": "dash", - }, - } - ) + if stage is None: + continue - annotations.append( - { - "x": 0, - "y": stage, - "xref": "paper", - "yref": "y1", - "text": f"{stage} {flood_data.get('stageUnits', '')} - {category}".strip(), - "showarrow": False, - "xanchor": "left", - "yanchor": "bottom", - "font": {"color": "black", "size": 12}, - } - ) + if isinstance(stage, str): + stage = stage.strip() + if not stage: + continue + + try: + stage_value = float(stage) + except (TypeError, ValueError): + continue + + if stage_value == -9999.0: + continue + + shapes.append( + { + "type": "line", + "x0": 0, + "x1": 1, + "xref": "paper", + "y0": stage, + "y1": stage, + "yref": "y1", + "line": { + "color": category_colors.get(category.lower(), "black"), + "width": 2, + "dash": "dash", + }, + } + ) + + annotations.append( + { + "x": 0, + "y": stage, + "xref": "paper", + "yref": "y1", + "text": f"{stage} {flood_data.get('stageUnits', '')} - {category}".strip(), + "showarrow": False, + "xanchor": "left", + "yanchor": "bottom", + "font": {"color": "black", "size": 12}, + } + ) return shapes, annotations diff --git a/tests/test_gauges.py b/tests/test_gauges.py new file mode 100644 index 0000000..b06d3ba --- /dev/null +++ b/tests/test_gauges.py @@ -0,0 +1,34 @@ +from ciroh_plugins.nwmps.gauges import NWMPSGaugesSeries + + +def test_create_flood_events_skips_placeholder_stage_values(): + flood_data = { + "stageUnits": "ft", + "categories": { + "action": {"stage": -9999}, + "minor": {"stage": 12}, + }, + } + + shapes, annotations = NWMPSGaugesSeries.create_flood_events(flood_data) + + assert len(shapes) == 1 + assert len(annotations) == 1 + assert shapes[0]["y0"] == 12 + assert annotations[0]["text"] == "12 ft - minor" + + +def test_create_flood_events_skips_invalid_string_stage_values(): + flood_data = { + "stageUnits": "ft", + "categories": { + "action": {"stage": " -9999.0 "}, + "minor": {"stage": ""}, + "moderate": {"stage": None}, + }, + } + + shapes, annotations = NWMPSGaugesSeries.create_flood_events(flood_data) + + assert shapes == [] + assert annotations == [] From c05a4ba6d982650db6228f234c970420209664d5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 23:42:27 +0000 Subject: [PATCH 3/8] refactor: use validated flood stage values for plotting Agent-Logs-Url: https://github.com/FIRO-Tethys/ciroh_plugins/sessions/0f553e01-181b-4fb4-8454-e2472d9d0e0e Co-authored-by: romer8 <43544549+romer8@users.noreply.github.com> --- ciroh_plugins/nwmps/gauges.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ciroh_plugins/nwmps/gauges.py b/ciroh_plugins/nwmps/gauges.py index 37b845f..fbb990f 100644 --- a/ciroh_plugins/nwmps/gauges.py +++ b/ciroh_plugins/nwmps/gauges.py @@ -7,6 +7,7 @@ # Set up logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +FLOOD_STAGE_PLACEHOLDER = -9999.0 # This will be used for the TimeSeries of the NWM data @@ -144,7 +145,7 @@ def create_flood_events(flood_data): except (TypeError, ValueError): continue - if stage_value == -9999.0: + if stage_value == FLOOD_STAGE_PLACEHOLDER: continue shapes.append( @@ -153,8 +154,8 @@ def create_flood_events(flood_data): "x0": 0, "x1": 1, "xref": "paper", - "y0": stage, - "y1": stage, + "y0": stage_value, + "y1": stage_value, "yref": "y1", "line": { "color": category_colors.get(category.lower(), "black"), @@ -167,7 +168,7 @@ def create_flood_events(flood_data): annotations.append( { "x": 0, - "y": stage, + "y": stage_value, "xref": "paper", "yref": "y1", "text": f"{stage} {flood_data.get('stageUnits', '')} - {category}".strip(), From eeb12459339193695f3177730991c03c11cb0300 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 23:43:08 +0000 Subject: [PATCH 4/8] fix: use cleaned validated stage value in annotations Agent-Logs-Url: https://github.com/FIRO-Tethys/ciroh_plugins/sessions/0f553e01-181b-4fb4-8454-e2472d9d0e0e Co-authored-by: romer8 <43544549+romer8@users.noreply.github.com> --- ciroh_plugins/nwmps/gauges.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ciroh_plugins/nwmps/gauges.py b/ciroh_plugins/nwmps/gauges.py index fbb990f..b1a1206 100644 --- a/ciroh_plugins/nwmps/gauges.py +++ b/ciroh_plugins/nwmps/gauges.py @@ -147,6 +147,7 @@ def create_flood_events(flood_data): if stage_value == FLOOD_STAGE_PLACEHOLDER: continue + cleaned_stage = int(stage_value) if stage_value.is_integer() else stage_value shapes.append( { @@ -154,8 +155,8 @@ def create_flood_events(flood_data): "x0": 0, "x1": 1, "xref": "paper", - "y0": stage_value, - "y1": stage_value, + "y0": cleaned_stage, + "y1": cleaned_stage, "yref": "y1", "line": { "color": category_colors.get(category.lower(), "black"), @@ -168,10 +169,10 @@ def create_flood_events(flood_data): annotations.append( { "x": 0, - "y": stage_value, + "y": cleaned_stage, "xref": "paper", "yref": "y1", - "text": f"{stage} {flood_data.get('stageUnits', '')} - {category}".strip(), + "text": f"{cleaned_stage} {flood_data.get('stageUnits', '')} - {category}".strip(), "showarrow": False, "xanchor": "left", "yanchor": "bottom", From 0632146e6b92bd192cb407bdc9a2c0c255cf4d33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 23:43:47 +0000 Subject: [PATCH 5/8] test: clarify invalid stage test name Agent-Logs-Url: https://github.com/FIRO-Tethys/ciroh_plugins/sessions/0f553e01-181b-4fb4-8454-e2472d9d0e0e Co-authored-by: romer8 <43544549+romer8@users.noreply.github.com> --- tests/test_gauges.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_gauges.py b/tests/test_gauges.py index b06d3ba..458380f 100644 --- a/tests/test_gauges.py +++ b/tests/test_gauges.py @@ -18,7 +18,7 @@ def test_create_flood_events_skips_placeholder_stage_values(): assert annotations[0]["text"] == "12 ft - minor" -def test_create_flood_events_skips_invalid_string_stage_values(): +def test_create_flood_events_skips_all_invalid_stage_values(): flood_data = { "stageUnits": "ft", "categories": { From 062c35e2bf689c6eb7b99a78a307b43cf07ebe90 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 23:44:31 +0000 Subject: [PATCH 6/8] fix: simplify stage normalization using validated float values Agent-Logs-Url: https://github.com/FIRO-Tethys/ciroh_plugins/sessions/0f553e01-181b-4fb4-8454-e2472d9d0e0e Co-authored-by: romer8 <43544549+romer8@users.noreply.github.com> --- ciroh_plugins/nwmps/gauges.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ciroh_plugins/nwmps/gauges.py b/ciroh_plugins/nwmps/gauges.py index b1a1206..65f54fa 100644 --- a/ciroh_plugins/nwmps/gauges.py +++ b/ciroh_plugins/nwmps/gauges.py @@ -147,7 +147,6 @@ def create_flood_events(flood_data): if stage_value == FLOOD_STAGE_PLACEHOLDER: continue - cleaned_stage = int(stage_value) if stage_value.is_integer() else stage_value shapes.append( { @@ -155,8 +154,8 @@ def create_flood_events(flood_data): "x0": 0, "x1": 1, "xref": "paper", - "y0": cleaned_stage, - "y1": cleaned_stage, + "y0": stage_value, + "y1": stage_value, "yref": "y1", "line": { "color": category_colors.get(category.lower(), "black"), @@ -169,10 +168,10 @@ def create_flood_events(flood_data): annotations.append( { "x": 0, - "y": cleaned_stage, + "y": stage_value, "xref": "paper", "yref": "y1", - "text": f"{cleaned_stage} {flood_data.get('stageUnits', '')} - {category}".strip(), + "text": f"{stage_value:g} {flood_data.get('stageUnits', '')} - {category}".strip(), "showarrow": False, "xanchor": "left", "yanchor": "bottom", From bd1060119f4a85544d8be1bc2d0689fa96246ceb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 23:51:37 +0000 Subject: [PATCH 7/8] chore: remove unneeded gauge test file per review Agent-Logs-Url: https://github.com/FIRO-Tethys/ciroh_plugins/sessions/eecc3881-d38f-4193-9a54-b6ee23e3b9c7 Co-authored-by: romer8 <43544549+romer8@users.noreply.github.com> --- tests/test_gauges.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 tests/test_gauges.py diff --git a/tests/test_gauges.py b/tests/test_gauges.py deleted file mode 100644 index 458380f..0000000 --- a/tests/test_gauges.py +++ /dev/null @@ -1,34 +0,0 @@ -from ciroh_plugins.nwmps.gauges import NWMPSGaugesSeries - - -def test_create_flood_events_skips_placeholder_stage_values(): - flood_data = { - "stageUnits": "ft", - "categories": { - "action": {"stage": -9999}, - "minor": {"stage": 12}, - }, - } - - shapes, annotations = NWMPSGaugesSeries.create_flood_events(flood_data) - - assert len(shapes) == 1 - assert len(annotations) == 1 - assert shapes[0]["y0"] == 12 - assert annotations[0]["text"] == "12 ft - minor" - - -def test_create_flood_events_skips_all_invalid_stage_values(): - flood_data = { - "stageUnits": "ft", - "categories": { - "action": {"stage": " -9999.0 "}, - "minor": {"stage": ""}, - "moderate": {"stage": None}, - }, - } - - shapes, annotations = NWMPSGaugesSeries.create_flood_events(flood_data) - - assert shapes == [] - assert annotations == [] From f93e8639f5661d7f0c9aeedbb3f23224a7496b31 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 May 2026 00:07:35 +0000 Subject: [PATCH 8/8] fix: skip all negative flood stage values Agent-Logs-Url: https://github.com/FIRO-Tethys/ciroh_plugins/sessions/69b04710-7ffc-41db-a425-79c88d4edd26 Co-authored-by: romer8 <43544549+romer8@users.noreply.github.com> --- ciroh_plugins/nwmps/gauges.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ciroh_plugins/nwmps/gauges.py b/ciroh_plugins/nwmps/gauges.py index 65f54fa..027c64b 100644 --- a/ciroh_plugins/nwmps/gauges.py +++ b/ciroh_plugins/nwmps/gauges.py @@ -7,7 +7,6 @@ # Set up logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) -FLOOD_STAGE_PLACEHOLDER = -9999.0 # This will be used for the TimeSeries of the NWM data @@ -145,7 +144,7 @@ def create_flood_events(flood_data): except (TypeError, ValueError): continue - if stage_value == FLOOD_STAGE_PLACEHOLDER: + if stage_value < 0: continue shapes.append(