Skip to content

Commit f4618bb

Browse files
committed
🎨 Account for XTEUS without value set
1 parent 58da628 commit f4618bb

4 files changed

Lines changed: 113 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ All notable changes to this library are documented in this file.
1414

1515
- Account for SPC PTS one-off with reversed and closed polygon.
1616
- Add `ip_throttle_secs` to `webutil.iemapp` to deal with IEM pain.
17+
- Gracefully handle `XTEUS` product without a value set.
1718
- Improve `iemapp` to better capture actual HTTP status_code and document
1819
what happens during Exception to status_code mapping.
1920
- Prevent a GIGO on certain autoplot date fields.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
424
2+
RXUS30 KWNH 220045
3+
XTEUS
4+
<?xml version="1.0"?>
5+
<dwml xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:noNamespaceSchemaLocation="http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/DWML.xsd">
6+
<head>
7+
<product concise-name="tabular-digital" operational-mode="operational">
8+
<title>US High/Low Temperature Extremes</title>
9+
<field>meteorological</field>
10+
<category>observations</category>
11+
<creation-date refresh-frequency="PT6H">2026-04-22T00:44:34Z</creation-date>
12+
</product>
13+
<source>
14+
<more-information>http://www.nws.noaa.gov/forecasts/xml/</more-information>
15+
<production-center>National Centers For Environmental Prediction
16+
<sub-center>Hydrometeorological Prediction Center</sub-center>
17+
</production-center>
18+
<disclaimer>http://www.nws.noaa.gov/disclaimer.html</disclaimer>
19+
<credit>http://www.weather.gov/</credit>
20+
<credit-logo>http://www.weather.gov/images/xml_logo.gif</credit-logo>
21+
<feedback>http://www.weather.gov/survey/nws-survey.php?code=tpex</feedback>
22+
</source>
23+
</head>
24+
<data>
25+
<location>
26+
<location-key>~KPHX</location-key>
27+
<city state="AZ" summarization="conus"/>
28+
</location>
29+
<location>
30+
<location-key>~CASA3</location-key>
31+
<city state="AZ" summarization="conus">3 miles east southeast of Casa Grande</city>
32+
</location>
33+
<location>
34+
<location-key>~TT482</location-key>
35+
<city state="AZ" summarization="conus">7 miles east southeast of Fountain Hills</city>
36+
</location>
37+
<location>
38+
<location-key>~</location-key>
39+
<city state="~" summarization="conus"/>
40+
</location>
41+
<location>
42+
<location-key>~ESCM1</location-key>
43+
<city state="ME" summarization="conus">4 miles east-southeast of Estcourt Station</city>
44+
</location>
45+
<location>
46+
<location-key>~KMWN</location-key>
47+
<city state="NH" summarization="conus">Mount Washington</city>
48+
</location>
49+
<time-layout time-coordinate="UTC">
50+
<layout-key>k-p10h-n1-1</layout-key>
51+
<start-valid-time>2026-04-21T14:00:00</start-valid-time>
52+
<end-valid-time>2026-04-22T00:00:00</end-valid-time>
53+
</time-layout>
54+
<time-layout time-coordinate="UTC">
55+
<layout-key>k-p13h-n1-1</layout-key>
56+
<start-valid-time>2026-04-21T00:00:00</start-valid-time>
57+
<end-valid-time>2026-04-21T13:00:00</end-valid-time>
58+
</time-layout>
59+
<parameters applicable-location="~KPHX">
60+
<temperature type="maximum" units="Fahrenheit" time-layout="k-p10h-n1-1">
61+
<name>National High Temperature</name>
62+
<value>96</value>
63+
</temperature>
64+
</parameters>
65+
<parameters applicable-location="~CASA3">
66+
<temperature type="maximum" units="Fahrenheit" time-layout="k-p10h-n1-1">
67+
<name>National High Temperature</name>
68+
<value>96</value>
69+
</temperature>
70+
</parameters>
71+
<parameters applicable-location="~TT482">
72+
<temperature type="maximum" units="Fahrenheit" time-layout="k-p10h-n1-1">
73+
<name>National High Temperature</name>
74+
<value>96</value>
75+
</temperature>
76+
</parameters>
77+
<parameters applicable-location="~">
78+
<temperature type="maximum" units="Fahrenheit" time-layout="k-p10h-n1-1">
79+
<name>National High Temperature</name>
80+
<value></value>
81+
</temperature>
82+
</parameters>
83+
<parameters applicable-location="~ESCM1">
84+
<temperature type="minimum" units="Fahrenheit" time-layout="k-p13h-n1-1">
85+
<name>National Low Temperature</name>
86+
<value>3</value>
87+
</temperature>
88+
</parameters>
89+
<parameters applicable-location="~KMWN">
90+
<temperature type="minimum" units="Fahrenheit" time-layout="k-p13h-n1-1">
91+
<name>National Low Temperature</name>
92+
<value>3</value>
93+
</temperature>
94+
</parameters>
95+
</data>
96+
</dwml>

src/pyiem/nws/products/xteus.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ def _parse_xml(textprod: TextProduct) -> pd.DataFrame:
5050
suffix = "-"
5151
for param in root.findall("data/parameters"):
5252
for child in param:
53+
value_text = child.find("value").text
54+
if value_text is None:
55+
textprod.warnings.append(
56+
"Found a value with no text, skipping."
57+
)
58+
continue
5359
key = param.attrib["applicable-location"]
5460
if key in used:
5561
textprod.warnings.append(
56-
"Found uplicated applicable-location, working around."
62+
"Found duplicated applicable-location, working around."
5763
)
5864
key = f"{key}{suffix}"
5965
suffix += "-"
@@ -66,7 +72,7 @@ def _parse_xml(textprod: TextProduct) -> pd.DataFrame:
6672
"sts": timelayout[tkey]["sts"],
6773
"ets": timelayout[tkey]["ets"],
6874
"type": child.attrib["type"],
69-
"value": float(child.find("value").text),
75+
"value": float(value_text),
7076
"state": xref[key]["state"],
7177
"name": xref[key]["name"],
7278
}

tests/nws/products/test_xteus.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
from pyiem.util import get_test_file, utc
88

99

10+
def test_260424_no_value():
11+
"""Test for a warning emitted for when there is no value."""
12+
data = get_test_file("XTEUS/XTEUS_novalue.txt")
13+
utcnow = utc(2026, 4, 22, 0, 50)
14+
prod = parser(data, utcnow=utcnow)
15+
assert prod.warnings
16+
17+
1018
def test_221228_duplicated_location():
1119
"""Test that we can make assumptions about this duplicated location."""
1220
data = get_test_file("XTEUS/XTEUS_double.txt")

0 commit comments

Comments
 (0)