Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
96 changes: 96 additions & 0 deletions data/product_examples/XTEUS/XTEUS_novalue.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
424
RXUS30 KWNH 220045
XTEUS
<?xml version="1.0"?>
<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">
<head>
<product concise-name="tabular-digital" operational-mode="operational">
<title>US High/Low Temperature Extremes</title>
<field>meteorological</field>
<category>observations</category>
<creation-date refresh-frequency="PT6H">2026-04-22T00:44:34Z</creation-date>
</product>
<source>
<more-information>http://www.nws.noaa.gov/forecasts/xml/</more-information>
<production-center>National Centers For Environmental Prediction
<sub-center>Hydrometeorological Prediction Center</sub-center>
</production-center>
<disclaimer>http://www.nws.noaa.gov/disclaimer.html</disclaimer>
<credit>http://www.weather.gov/</credit>
<credit-logo>http://www.weather.gov/images/xml_logo.gif</credit-logo>
<feedback>http://www.weather.gov/survey/nws-survey.php?code=tpex</feedback>
</source>
</head>
<data>
<location>
<location-key>~KPHX</location-key>
<city state="AZ" summarization="conus"/>
</location>
<location>
<location-key>~CASA3</location-key>
<city state="AZ" summarization="conus">3 miles east southeast of Casa Grande</city>
</location>
<location>
<location-key>~TT482</location-key>
<city state="AZ" summarization="conus">7 miles east southeast of Fountain Hills</city>
</location>
<location>
<location-key>~</location-key>
<city state="~" summarization="conus"/>
</location>
<location>
<location-key>~ESCM1</location-key>
<city state="ME" summarization="conus">4 miles east-southeast of Estcourt Station</city>
</location>
<location>
<location-key>~KMWN</location-key>
<city state="NH" summarization="conus">Mount Washington</city>
</location>
<time-layout time-coordinate="UTC">
<layout-key>k-p10h-n1-1</layout-key>
<start-valid-time>2026-04-21T14:00:00</start-valid-time>
<end-valid-time>2026-04-22T00:00:00</end-valid-time>
</time-layout>
<time-layout time-coordinate="UTC">
<layout-key>k-p13h-n1-1</layout-key>
<start-valid-time>2026-04-21T00:00:00</start-valid-time>
<end-valid-time>2026-04-21T13:00:00</end-valid-time>
</time-layout>
<parameters applicable-location="~KPHX">
<temperature type="maximum" units="Fahrenheit" time-layout="k-p10h-n1-1">
<name>National High Temperature</name>
<value>96</value>
</temperature>
</parameters>
<parameters applicable-location="~CASA3">
<temperature type="maximum" units="Fahrenheit" time-layout="k-p10h-n1-1">
<name>National High Temperature</name>
<value>96</value>
</temperature>
</parameters>
<parameters applicable-location="~TT482">
<temperature type="maximum" units="Fahrenheit" time-layout="k-p10h-n1-1">
<name>National High Temperature</name>
<value>96</value>
</temperature>
</parameters>
<parameters applicable-location="~">
<temperature type="maximum" units="Fahrenheit" time-layout="k-p10h-n1-1">
<name>National High Temperature</name>
<value></value>
</temperature>
</parameters>
<parameters applicable-location="~ESCM1">
<temperature type="minimum" units="Fahrenheit" time-layout="k-p13h-n1-1">
<name>National Low Temperature</name>
<value>3</value>
</temperature>
</parameters>
<parameters applicable-location="~KMWN">
<temperature type="minimum" units="Fahrenheit" time-layout="k-p13h-n1-1">
<name>National Low Temperature</name>
<value>3</value>
</temperature>
</parameters>
</data>
</dwml>
10 changes: 8 additions & 2 deletions src/pyiem/nws/products/xteus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "-"
Expand All @@ -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"],
}
Expand Down
8 changes: 8 additions & 0 deletions tests/nws/products/test_xteus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading