Skip to content

fix: PNS max EF rating truncated at first tornado's && delimiter#620

Merged
full-bars merged 1 commit into
mainfrom
fix/pns-max-ef-ampamp-delimiter
Jul 24, 2026
Merged

fix: PNS max EF rating truncated at first tornado's && delimiter#620
full-bars merged 1 commit into
mainfrom
fix/pns-max-ef-ampamp-delimiter

Conversation

@full-bars

@full-bars full-bars commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • _handle_pns truncated its EF-rating search text at the first && marker, intending to strip the trailing "EF Scale" legend boilerplate. But NWS damage survey PNS products also use && to separate every individual tornado entry within the product, so on any survey with more than one tornado only the first tornado's rating was ever considered.
  • Confirmed live: KPBZ's July 21, 2026 tornado event Update fix: persist CSU-MLP posted state across reboots using cache JSON #3 (202607232205-KPBZ-NOUS41-PNSPBZ) reported "Max: EF0" despite containing a later EF1 tornado (Zanesville 1, Muskingum County, OH).
  • Fix: only stop the search at EF SCALE: / THE ENHANCED FUJITA SCALE, which unambiguously mark the trailing legend — leave every &&-delimited tornado entry intact for rating extraction.

Test plan

  • Added regression test reproducing the real product's &&-delimited, multi-tornado structure; verified it fails against the pre-fix code (asserts Max: EF0 was wrongly produced) and passes with the fix (Max: EF1)
  • venv/bin/python3 -m pytest tests/test_reports.py tests/test_surveys.py -q — 20 passed
  • Full pre-push suite (ruff, mypy, cargo fmt/clippy, pytest) — 570 passed

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Multi-Tornado Damage Survey processing so all tornado entries are retained.
    • Maximum Enhanced Fujita (EF) ratings are now calculated correctly when entries contain multiple separators.
  • Tests
    • Added regression coverage for surveys containing multiple tornado entries and EF ratings.

_handle_pns stopped searching for EF ratings at the first "&&" marker,
meant to strip the trailing EF Scale legend. But "&&" also separates
every individual tornado entry in multi-tornado damage survey PNS
products, so only the first tornado's rating was ever considered.
Confirmed live against KPBZ's July 21 2026 event, which reported
"Max: EF0" despite containing an EF1 tornado later in the same product.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f25e731-f73a-48fc-acd8-6eee344c963b

📥 Commits

Reviewing files that changed from the base of the PR and between bda5316 and 8750b1d.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • cogs/reports.py
  • tests/test_reports.py

📝 Walkthrough

Walkthrough

The PNS handler no longer treats && as a truncation boundary, preserving multiple tornado entries for EF rating extraction. A regression test covers the maximum rating across entries, and the changelog documents the fix.

Changes

PNS EF rating parsing

Layer / File(s) Summary
Preserve tornado entries during EF extraction
cogs/reports.py, tests/test_reports.py, CHANGELOG.md
_handle_pns now truncates only at EF scale legend headers; a regression test verifies the maximum EF rating across &&-delimited tornado entries, and the fix is documented.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main fix: EF rating extraction no longer truncates at the first tornado && delimiter.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pns-max-ef-ampamp-delimiter

Comment @coderabbitai help to get the list of available commands.

@full-bars
full-bars merged commit 6a9bf6a into main Jul 24, 2026
10 checks passed
@full-bars
full-bars deleted the fix/pns-max-ef-ampamp-delimiter branch July 24, 2026 10:09
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.

1 participant