Skip to content

Commit

Permalink
🐛 Support a CLI circa 2007
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Oct 20, 2024
1 parent 9a931fc commit e15e3c1
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ generating plots of HRRR ptype.
- Accomodate ancient LSRs using `TRACE` as the magnitude field.
- Ensure geometries going into masking helper are CCW, to mask outside of.
- Properly check USDM service response prior to parsing it.
- Support parsing `CLI` products circa 2007 with a bad space.

## **1.21.0** (6 Sep 2024)

Expand Down
101 changes: 101 additions & 0 deletions data/product_examples/CLI/CLICVG_2007.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
000
CDUS41 KILN 010557
CLICVG


CLIMATE REPORT
NATIONAL WEATHER SERVICE WILMINGTON OH
155 AM EDT SUN JUL 1 2007


...................................

...THE CINCINNATI CLIMATE SUMMARY FOR JUNE 30 2007...

CLIMATE NORMAL PERIOD 1971 TO 2000
CLIMATE RECORD PERIOD 1869 TO 2007


WEATHER ITEM OBSERVED TIME RECORD YEAR NORMAL DEPARTURE LAST
VALUE (LST) VALUE VALUE FROM YEAR
NORMAL
..................................................................
TEMPERATURE (F)
YESTERDAY
MAXIMUM 82 403 PM 98 1953 85 -3 82
MINIMUM 67 727 AM 47 1923 65 2 55
AVERAGE 75 75 0 69

PRECIPITATION (IN)
YESTERDAY 0.00 1.36 1933 0.13 -0.13 T
MONTH TO DATE 1.74 4.42 -2.68 3.67
SINCE JUN 1 1.74 4.42 -2.68 3.67
SINCE JAN 1 16.22 22.54 -6.32 24.33

SNOWFALL (IN)
YESTERDAY 0.0 0.0 0.0 0.0
MONTH TO DATE 0.0 0.0 0.0 0.0
SINCE JUN 1 0.0 0.0 0.0 0.0
SINCE JUL 1 17.1 23.6 -6.5 17.5
SNOW DEPTH 0

DEGREE DAYS
HEATING
YESTERDAY 0 0 0 0
MONTH TO DATE 0 19 -19 9
SINCE JUN 1 0 19 -19 9
SINCE JUL 1 4785 5148 -363 4624

COOLING
YESTERDAY 10 10 0 4
MONTH TO DATE 286 215 71 167
SINCE JUN 1 286 215 71 167
SINCE JAN 1 474 304 170 263
..................................................................


WIND (MPH)
RESULTANT WIND SPEED 5 RESULTANT WIND DIRECTION NE (50)
HIGHEST WIND SPEED 15 HIGHEST WIND DIRECTION NE (30)
HIGHEST GUST SPEED 18 HIGHEST GUST DIRECTION NE (30)
AVERAGE WIND SPEED 6.0


SKY COVER
POSSIBLE SUNSHINE MM
AVERAGE SKY COVER 0.8


WEATHER CONDITIONS
THE FOLLOWING WEATHER WAS RECORDED YESTERDAY.
NO SIGNIFICANT WEATHER WAS OBSERVED.


RELATIVE HUMIDITY (PERCENT)
HIGHEST 78 100 AM
LOWEST 30 100 PM
AVERAGE 54

..........................................................


THE CINCINNATI CLIMATE NORMALS FOR TODAY
NORMAL RECORD YEAR
MAXIMUM TEMPERATURE (F) 85 98 1970
MINIMUM TEMPERATURE (F) 65 49 1988


SUNRISE AND SUNSET
JULY 1 2007..........SUNRISE 616 AM EDT SUNSET 908 PM EDT
JULY 2 2007..........SUNRISE 617 AM EDT SUNSET 908 PM EDT


- INDICATES NEGATIVE NUMBERS.
R INDICATES RECORD WAS SET OR TIED.
MM INDICATES DATA IS MISSING.
T INDICATES TRACE AMOUNT.




$$
4 changes: 2 additions & 2 deletions src/pyiem/nws/products/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def find_sections(self):
for section in text.split("&&"):
if not HEADLINE_RE.findall(section.replace("\n", " ")):
continue
tokens = re.findall("^WEATHER ITEM.*$", section, re.M)
tokens = re.findall(r"^\s?WEATHER ITEM.*$", section, re.M)
if not tokens:
raise CLIException("Could not find 'WEATHER ITEM' within text")
if len(tokens) == 1:
Expand All @@ -554,7 +554,7 @@ def find_sections(self):

def compute_diction(self, text):
"""Try to determine what we have for a format"""
tokens = re.findall("^WEATHER ITEM.*$", text, re.M)
tokens = re.findall(r"^\s?WEATHER ITEM.*$", text, re.M)
diction = tokens[0].strip()
if diction not in REGIMES:
raise CLIException(
Expand Down
6 changes: 6 additions & 0 deletions tests/nws/products/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def factory(fn):
return cliparser(get_test_file(fn), nwsli_provider=NWSLI_PROVIDER)


def test_241020_2007cli():
"""Test a CLI with stray spaces from 2007."""
prod = cliparser(get_test_file("CLI/CLICVG_2007.txt"))
assert abs(prod.data[0]["data"]["snow_jul1"] - 17.1) < 0.01


def test_231025_tabs():
"""Test that a line with tabs gets ignored (best we can do)."""
prod = cliparser(get_test_file("CLI/CLICVG_tab.txt"))
Expand Down

0 comments on commit e15e3c1

Please sign in to comment.