mostlyright.weather.catalog.iem
mostlyright.weather.catalog.iem
Section titled “mostlyright.weather.catalog.iem”IEM catalog adapter (CATALOG-01).
Wraps mostlyright.weather._iem.iem_to_observation() (and parse_iem_file)
into a class that satisfies the WeatherAdapter Protocol and emits a
canonical schema.observation.v1 DataFrame with overlay columns + correct
SI units (m/s, metres, mm — see _obs_projection.PROJECTION_SPEC).
Source IDs handled:
"iem.archive"— historical CSV pulls (the v0.14.1 parity baseline)"iem.live"— same parser, current-month staging cache (no semantic
difference at the parser level; the source ID drives Validator dispatch)
MOS forecast leg deferred to Phase 3 per the Phase 2 PLAN Open Q1 resolution.
fetch_forecasts() raises NotImplementedError.
Pitfall 8 (codex cross-ref): IEM’s missing-data sentinel M is converted
to None by the underlying parser. The projection in
mostlyright.weather.catalog._obs_projection preserves None through
unit conversion.
Module Attributes
Section titled “Module Attributes”IEM_METAR_LAG | Knowledge-time lag for METAR/SPECI reports. |
|---|
Classes
Section titled “Classes”IEMAdapter() | IEM ASOS observation adapter. |
|---|
class mostlyright.weather.catalog.iem.IEMAdapter
Section titled “class mostlyright.weather.catalog.iem.IEMAdapter”Bases: object
IEM ASOS observation adapter.
SUPPORTED_SOURCES : ClassVar[list[str]] = [‘iem.archive’, ‘iem.live’]
Section titled “SUPPORTED_SOURCES : ClassVar[list[str]] = [‘iem.archive’, ‘iem.live’]”fetch_forecasts(source, station, from_date, to_date)
Section titled “fetch_forecasts(source, station, from_date, to_date)”Fetch IEM MOS forecasts via fetch_iem_mos() (Phase 17 PLAN-08).
Replaces the Phase-2 NotImplementedError stub. The default
model is nbe (preferred for US stations); other supported
models (gfs / lav / met / ecm) are reachable via direct
fetch_iem_mos() calls.
- Parameters:
- Return type:
DataFrame - Returns:
DataFrame matching
schema.forecast.iem_mos.v1. - Raises:
- ValueError – unknown
source. - NotImplementedError –
source="iem.live".
- ValueError – unknown
fetch_observations(source, station, from_date, to_date)
Section titled “fetch_observations(source, station, from_date, to_date)”Fetch observations from IEM ASOS.
v0.1.0: NOT YET WIRED. research() and snapshot continue to
call _fetchers/iem_asos.py directly. The adapter contract is in
place for Phase 3 Mode-2 dispatch.
static from_rows(rows, , source=‘iem.archive’, retrieved_at=None)
Section titled “static from_rows(rows, , source=‘iem.archive’, retrieved_at=None)”Project parser-output rows to a canonical observation DataFrame.
Applies the shared canonical-units projection
(mostlyright.weather.catalog._obs_projection): knots → m/s,
miles → metres, feet → metres, inches → mm. None (IEM M
sentinel) passes through unchanged.
- Return type:
DataFrame - Parameters:
mostlyright.weather.catalog.iem.iem_to_observation(row, observation_type_override=None)
Section titled “mostlyright.weather.catalog.iem.iem_to_observation(row, observation_type_override=None)”Convert a single IEM CSV row to an observation schema dict.
Takes a dict from csv.DictReader (comma-delimited). If observation_type_override is set, uses that instead of detecting from raw METAR text. IEM strips the SPECI keyword from raw METAR, so callers that request report_type=3 or report_type=4 separately should pass the override. Returns observation dict with exactly 30 fields, or None if row should be skipped (invalid station, bad timestamp, or all key vars missing).