diff --git a/CHANGELOG.md b/CHANGELOG.md index c850e576f..84bc08b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/data/product_examples/CLI/CLICVG_2007.txt b/data/product_examples/CLI/CLICVG_2007.txt new file mode 100644 index 000000000..581deaa99 --- /dev/null +++ b/data/product_examples/CLI/CLICVG_2007.txt @@ -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. + + + + + $$ diff --git a/src/pyiem/nws/products/cli.py b/src/pyiem/nws/products/cli.py index 8018c28eb..3e0cbd06b 100644 --- a/src/pyiem/nws/products/cli.py +++ b/src/pyiem/nws/products/cli.py @@ -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: @@ -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( diff --git a/tests/nws/products/test_cli.py b/tests/nws/products/test_cli.py index d698a4152..ef0998e10 100644 --- a/tests/nws/products/test_cli.py +++ b/tests/nws/products/test_cli.py @@ -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"))