Skip to content

Commit

Permalink
Merge pull request #964 from akrherz/lsr_troubles
Browse files Browse the repository at this point in the history
✅ Workaround LSRs with just TRACE
  • Loading branch information
akrherz authored Sep 27, 2024
2 parents b6d226d + b5e29ec commit e3823a3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ generating plots of HRRR ptype.

### Bug Fixes

- Accomodate ancient LSRs using `TRACE` as the magnitude field.
- Ensure geometries going into masking helper are CCW, to mask outside of.

## **1.21.0** (6 Sep 2024)
Expand Down
23 changes: 23 additions & 0 deletions data/product_examples/LSR/LSRSEW.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
357
NWUS56 KSEW 141924 CCA
LSRSEW

PRELIMINARY LOCAL STORM REPORT
NATIONAL WEATHER SERVICE SEATTLE WA
1124 AM PST SAT JAN 14 2012

..TIME... ...EVENT... ...CITY LOCATION... ...LAT.LON...
..DATE... ....MAG.... ..COUNTY LOCATION..ST.. ...SOURCE....
..REMARKS..

1050 AM SNOW 4 SW EVERETT 47.92N 122.25W
01/14/2012 TRACE INCH SNOHOMISH WA TRAINED SPOTTER

SLUSH ON ROADWAYS.


&&

$$

GRUB
4 changes: 4 additions & 0 deletions src/pyiem/nws/lsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def get_lon(self):

def consume_magnitude(self, text):
"""Convert LSR magnitude text into something atomic"""
# Brute force this special case, which trips up the regex
if text.upper().strip().startswith("TRACE"):
self.magnitude_f = TRACE_VALUE
return
self.magnitude_str = text
tokens = MAG_UNITS.findall(text)
if not tokens:
Expand Down
7 changes: 7 additions & 0 deletions tests/nws/products/test_lsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
from pyiem.util import get_test_file


def test_240927_bad_qualifier():
"""Test a product that generates an invalid qualifier."""
prod = parser(get_test_file("LSR/LSRSEW.txt"))
assert prod.lsrs[0].magnitude_qualifier is None
assert abs(TRACE_VALUE - prod.lsrs[0].magnitude_f) < TRACE_VALUE


def test_240926_nolsrs():
"""Test that this processes a LSR!"""
prod = parser(get_test_file("LSR/LSRFWD.txt"))
Expand Down

0 comments on commit e3823a3

Please sign in to comment.