From f4618bb1f73804d9e685828cbea264c2fc1e1b76 Mon Sep 17 00:00:00 2001 From: akrherz Date: Fri, 24 Apr 2026 10:21:20 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Account=20for=20XTEUS=20without?= =?UTF-8?q?=20value=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + data/product_examples/XTEUS/XTEUS_novalue.txt | 96 +++++++++++++++++++ src/pyiem/nws/products/xteus.py | 10 +- tests/nws/products/test_xteus.py | 8 ++ 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 data/product_examples/XTEUS/XTEUS_novalue.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dda6b901..95abc30e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this library are documented in this file. - Account for SPC PTS one-off with reversed and closed polygon. - Add `ip_throttle_secs` to `webutil.iemapp` to deal with IEM pain. +- Gracefully handle `XTEUS` product without a value set. - Improve `iemapp` to better capture actual HTTP status_code and document what happens during Exception to status_code mapping. - Prevent a GIGO on certain autoplot date fields. diff --git a/data/product_examples/XTEUS/XTEUS_novalue.txt b/data/product_examples/XTEUS/XTEUS_novalue.txt new file mode 100644 index 000000000..ba4caf42d --- /dev/null +++ b/data/product_examples/XTEUS/XTEUS_novalue.txt @@ -0,0 +1,96 @@ +424 +RXUS30 KWNH 220045 +XTEUS + + + + + US High/Low Temperature Extremes + meteorological + observations + 2026-04-22T00:44:34Z + + + http://www.nws.noaa.gov/forecasts/xml/ + National Centers For Environmental Prediction + Hydrometeorological Prediction Center + + http://www.nws.noaa.gov/disclaimer.html + http://www.weather.gov/ + http://www.weather.gov/images/xml_logo.gif + http://www.weather.gov/survey/nws-survey.php?code=tpex + + + + + ~KPHX + + + + ~CASA3 + 3 miles east southeast of Casa Grande + + + ~TT482 + 7 miles east southeast of Fountain Hills + + + ~ + + + + ~ESCM1 + 4 miles east-southeast of Estcourt Station + + + ~KMWN + Mount Washington + + + k-p10h-n1-1 + 2026-04-21T14:00:00 + 2026-04-22T00:00:00 + + + k-p13h-n1-1 + 2026-04-21T00:00:00 + 2026-04-21T13:00:00 + + + + National High Temperature + 96 + + + + + National High Temperature + 96 + + + + + National High Temperature + 96 + + + + + National High Temperature + + + + + + National Low Temperature + 3 + + + + + National Low Temperature + 3 + + + + diff --git a/src/pyiem/nws/products/xteus.py b/src/pyiem/nws/products/xteus.py index 0f5e84adf..7625275b6 100644 --- a/src/pyiem/nws/products/xteus.py +++ b/src/pyiem/nws/products/xteus.py @@ -50,10 +50,16 @@ def _parse_xml(textprod: TextProduct) -> pd.DataFrame: suffix = "-" for param in root.findall("data/parameters"): for child in param: + value_text = child.find("value").text + if value_text is None: + textprod.warnings.append( + "Found a value with no text, skipping." + ) + continue key = param.attrib["applicable-location"] if key in used: textprod.warnings.append( - "Found uplicated applicable-location, working around." + "Found duplicated applicable-location, working around." ) key = f"{key}{suffix}" suffix += "-" @@ -66,7 +72,7 @@ def _parse_xml(textprod: TextProduct) -> pd.DataFrame: "sts": timelayout[tkey]["sts"], "ets": timelayout[tkey]["ets"], "type": child.attrib["type"], - "value": float(child.find("value").text), + "value": float(value_text), "state": xref[key]["state"], "name": xref[key]["name"], } diff --git a/tests/nws/products/test_xteus.py b/tests/nws/products/test_xteus.py index 221345a33..200817a8c 100644 --- a/tests/nws/products/test_xteus.py +++ b/tests/nws/products/test_xteus.py @@ -7,6 +7,14 @@ from pyiem.util import get_test_file, utc +def test_260424_no_value(): + """Test for a warning emitted for when there is no value.""" + data = get_test_file("XTEUS/XTEUS_novalue.txt") + utcnow = utc(2026, 4, 22, 0, 50) + prod = parser(data, utcnow=utcnow) + assert prod.warnings + + def test_221228_duplicated_location(): """Test that we can make assumptions about this duplicated location.""" data = get_test_file("XTEUS/XTEUS_double.txt")