tephpy.io.wyoming#
University of Wyoming sounding archive reader (spec §3.4).
fetch() requests one ascent from the archive’s post-2024 wsgi
interface in its machine-readable TEXT:CSV form — bare, self-describing
CSV (verified 2026-07-27) — over stdlib urllib behind a function-local
import, and hands the body to a pure, transport-free parser. Network
failures, HTTP errors, and the archive’s “no data” replies raise
TephpyIOError summarising the upstream
response; the parsed sounding passes the ordinary ingest validation
(spec §6).
Notes#
Added in version 0.1.0.
Functions#
Module Contents#
- tephpy.io.wyoming.fetch(station: str, time: datetime.datetime | str, *, timeout: float | None = None) tephpy.sounding.Sounding[source]#
Fetch one sounding from the University of Wyoming archive.
- Parameters:
- station
str The WMO station identifier, e.g.
"72357".- time
datetime.datetimeorstr The nominal launch time; a string is read with
datetime.datetime.fromisoformat(), and a naive value is read as UTC (theSoundingconvention).- timeout
float, optional The request timeout in seconds (default
WYOMING_TIMEOUT).
- station
- Returns:
- Raises:
TephpyIOErrorFor network failures, HTTP errors (including the archive’s “no data at that time” and “unknown station” replies), or a response the parser does not recognise.
TypeErrorIf time is neither a datetime nor a string.
ValueErrorIf a time string is not ISO 8601.
Notes
Added in version 0.1.0.
- tephpy.io.wyoming.parse(text: str, *, station: str | None = None, time: datetime.datetime | str | None = None) tephpy.sounding.Sounding[source]#
Read one
TEXT:CSVarchive body into a sounding.The route
fetch()cannot serve: a body the caller already has. A response cached against a rate limit, one pulled through a proxy that this package’surlopencall cannot reach, or a bulk archive dump someone else downloaded – each is the same text over the same format, with only the retrieval differing, andfetch()is retrieval. The two share this parser rather than agreeing by inspection, so a body read here and a body fetched become the sameSounding.station and time are metadata rather than parsing input: the archive body carries neither the identifier that was asked for nor the nominal hour it was asked for, so a caller who knows them says so and gets the legend label derived (spec §3.4). A caller who does not gets a sounding without one, which is a sounding all the same.
Blank cells read as NaN (NaN gaps are data, spec §3.4); rows whose pressure does not strictly decrease on the running minimum are dropped keeping the first occurrence, so the dense BUFR-era ascents satisfy
Sounding’s strict monotonicity; an optional field that is entirely NaN is treated as absent — and the wind pair as a unit, so a one-sided wind column passes as absent rather than trippingSounding’s pairing rule — keeping the missing-data errors meaningful downstream (spec §6).The archive’s CSV is rectangular, so a row with fewer cells than the header is a truncated reply rather than a gap: it is rejected naming the row (the header is row 1). Trailing cells beyond the header are ignored — every carried column is located by its header index.
- Parameters:
- text
str The response body.
- station
str, optional The WMO station identifier, carried as metadata; omitted, no legend label derives.
- time
datetime.datetimeorstr, optional The nominal launch time, carried as metadata; a string is read the way
fetch()reads one, so the two do not diverge. Omitted, no legend label derives.
- text
- Returns:
SoundingThe validated sounding.
- Raises:
TephpyIOErrorIf the body is not readable as CSV at all, expected columns are missing, a row is shorter than the header, the header carries no data rows, or a cell is not numeric.
TypeErrorIf time is neither a datetime nor a string.
ValueErrorIf a time string is not ISO 8601.
Notes
Added in version 0.1.0.