Weather Observation Fetching
Overview
Retrieve measured surface and upper-air weather reports without losing station
identity, observation time, units, raw values, or provider quality flags. Pick
the source by observation type and retention need, then validate the returned
records before normalization.
This skill covers METARs, historical surface observations, radiosondes, and
station metadata. It excludes model output, radar volumes, and satellite
imagery.
When to Use This Skill
- A task needs recent METAR observations for named stations or a small region.
- Historical hourly or synoptic surface data is needed from NOAA NCEI.
- A sounding workflow needs observed radiosonde profiles rather than model
profiles.
- Station identifiers, relocations, instruments, or metadata must be resolved.
- A fetch returned duplicate, stale, unit-ambiguous, or quality-flagged values.
Do not use forecast products as observations, and do not substitute a nearby
model grid point for a missing station report without explicit approval.
Choose the Source
| Need |
Preferred source |
Notes |
| Recent aviation surface reports |
NOAA Aviation Weather Center Data API |
Query a small station/time set; use published cache files for bulk current data. |
| Historical global surface reports |
NOAA NCEI Integrated Surface Database (ISD) |
Preserve USAF/WBAN identity, units, and QC fields. |
| Historical or recent radiosondes |
NOAA NCEI IGRA |
Use the station inventory and retain level and QC metadata. |
| Station history and identifier changes |
NOAA NCEI station history/HOMR |
Resolve moves, renames, and observing-platform changes. |
Prefer an existing project adapter when it already handles the provider's
schema, retries, and cache. Record the exact endpoint or archive object used.
Define the Observation Request
Resolve these values before fetching:
- observation type and variables;
- station identifier system, not just the identifier string;
- start and end instants in UTC, including interval inclusivity;
- maximum acceptable observation age;
- raw, decoded, or both output forms;
- required quality flags and policy for rejected values;
- output units and missing-value representation;
- cache location and retention.
For spatial queries, also define the search geometry, distance limit, and how a
station is selected. Return the selected station and distance rather than
silently using the nearest report.
Fetch Recent METARs
The Aviation Weather Center exposes machine-readable METAR data under
/api/data/metar. Send a descriptive user agent, keep the query narrow, and
handle a valid 204 No Content separately from an error.
import json
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import Request, urlopen
def fetch_metars(stations, hours=2):
station_ids = sorted({station.strip().upper() for station in stations})
if not station_ids or any(len(station) != 4 for station in station_ids):
raise ValueError("use one or more four-character ICAO station IDs")
if not 1 <= hours <= 24:
raise ValueError("hours must be between 1 and 24 for this narrow query")
query = urlencode({
"ids": ",".join(station_ids),
"format": "json",
"hours": hours,
})
request = Request(
f"https://aviationweather.gov/api/data/metar?{query}",
headers={"User-Agent": "weather-observation-fetching/1.0 contact@example.org"},
)
try:
with urlopen(request, timeout=30) as response:
if response.status == 204:
return []
records = json.load(response)
except HTTPError as exc:
if exc.code == 429:
raise RuntimeError("AWC rate limit reached; honor Retry-After") from exc
raise
if not isinstance(records, list):
raise RuntimeError("unexpected METAR response shape")
return records
Replace the example contact address with an appropriate project contact. For a
large current snapshot, download the provider's compressed cache file once
instead of issuing many station queries.
Fetch Historical Surface Data
For ISD:
- Resolve the station using the current station inventory and its USAF/WBAN
identifiers.
- Confirm that the station's coverage overlaps the requested time range.
- Use bulk HTTPS files for a large historical request; avoid one network call
per observation.
- Preserve the original report and source/QC codes before converting units.
- Treat trace values, missing sentinels, and calm or variable winds according
to the data format documentation.
- Join station metadata by both identifier and effective date when station
history matters.
Do not assume one station identifier always represents an unchanged location or
instrument throughout its archive.
Fetch Radiosonde Profiles
For IGRA:
- Search the station inventory by identifier or location and verify the
station's record period.
- Fetch the station file covering the requested dates rather than scraping an
interactive page.
- Select by the report's UTC time and retain nominal, launch, and release times
when the source supplies them.
- Preserve pressure, height, temperature, moisture, wind, level type, and QC
fields. Standard and significant levels are both scientifically relevant.
- Sort the profile only after parsing; do not invent levels or interpolate
across large gaps during acquisition.
- Report an absent launch or incomplete profile explicitly.
Many upper-air stations usually report near 00 and 12 UTC, but the archive is
the authority. Do not manufacture a schedule or select a different day solely
because a nominal time is missing.
Normalize Without Erasing Provenance
Each normalized record should retain:
- provider and dataset;
- station identifier plus identifier scheme;
- station latitude, longitude, elevation, and metadata effective date;
- observation time in UTC and, when available, receipt or ingestion time;
- raw report or raw archive row;
- decoded values with explicit units;
- provider quality flags and local QC decisions;
- retrieval time, source URL/object, and response identity.
Store original and converted values side by side when a conversion could affect
rounding. Never use the HTTP Last-Modified timestamp as the observation time.
Quality Control and Deduplication
- Treat provider flags as data, not decoration. Define which flags are accepted,
rejected, or retained with warnings.
- Deduplicate on provider identity, station, observation time, and report type.
When corrected reports exist, preserve the correction lineage.
- Check physical ranges only after handling missing and trace encodings.
- Verify wind direction conventions, temperature scales, pressure units, and
precipitation accumulation periods before combining sources.
- Keep station time, observation time, and ingestion time distinct.
- Flag stale reports against the request's maximum age rather than returning
them as current conditions.
Reliability and Caching
- Honor provider request limits,
Retry-After, and published bulk-download
guidance.
- Retry timeouts,
408, 429, and transient 5xx failures with bounded
backoff and jitter.
- Cache immutable archive files by URL/object identity and current API responses
for no longer than their update cadence permits.
- Write downloads to a temporary path, validate content and expected date range,
then rename atomically.
- Keep partial files separate from accepted cache entries.
- For one-shot processing, remove request-owned temporary observations in
finally only after the derived artifact and provenance record are durable.
Verification Checklist
- The station identifier scheme and station metadata are explicit.
- All selected observations fall inside the requested UTC interval.
- The report time, receipt time, and retrieval time are not conflated.
- Units, missing sentinels, trace values, and QC flags are handled explicitly.
- Raw reports or rows remain available for audit.
- Duplicate and corrected reports follow a documented rule.
- A no-data response is distinguished from provider failure.
- The final result reports stale, incomplete, or rejected observations.
Security & Safety Notes
- Use only public endpoints or data the user is authorized to access.
- Do not place API keys, credentials, signed URLs, or private station data in
examples, logs, caches, or provenance manifests.
- Keep TLS certificate verification enabled.
- Encode query parameters rather than concatenating untrusted station input into
a URL.
- Bound station count, time span, response size, retries, and parallelism.
- Follow provider terms, rate limits, and attribution requirements.
Common Pitfalls
- The latest METAR is old: The station has not reported recently. Apply the
maximum-age contract and report staleness.
- A station lookup returns the wrong site: ICAO, WMO, USAF/WBAN, and IGRA
identifiers were treated as interchangeable. Preserve the identifier scheme.
- Temperatures look extreme: Missing sentinels or units were converted as
real values. Parse format metadata before unit conversion.
- A sounding has too few levels: Only mandatory levels were retained or the
launch was incomplete. Preserve significant levels and surface data.
- An archive record moved: Station history changed. Join metadata by its
effective period and record the selected version.
Limitations
- Provider schemas, retention windows, station inventories, and usage limits can
change; consult current official documentation.
- Quality flags identify known conditions but do not guarantee that a
measurement is scientifically suitable for a particular analysis.
- This skill does not perform radar retrieval, satellite retrieval, model-data
fetching, or forecast verification.
Additional Resources
1---2name: weather-observation-fetching3description: Retrieve surface and upper-air weather observations from authoritative APIs and archives with station identity, time, units, and quality flags preserved.4---56# Weather Observation Fetching78## Overview910Retrieve measured surface and upper-air weather reports without losing station11identity, observation time, units, raw values, or provider quality flags. Pick12the source by observation type and retention need, then validate the returned13records before normalization.1415This skill covers METARs, historical surface observations, radiosondes, and16station metadata. It excludes model output, radar volumes, and satellite17imagery.1819## When to Use This Skill2021- A task needs recent METAR observations for named stations or a small region.22- Historical hourly or synoptic surface data is needed from NOAA NCEI.23- A sounding workflow needs observed radiosonde profiles rather than model24 profiles.25- Station identifiers, relocations, instruments, or metadata must be resolved.26- A fetch returned duplicate, stale, unit-ambiguous, or quality-flagged values.2728Do not use forecast products as observations, and do not substitute a nearby29model grid point for a missing station report without explicit approval.3031## Choose the Source3233| Need | Preferred source | Notes |34| --- | --- | --- |35| Recent aviation surface reports | NOAA Aviation Weather Center Data API | Query a small station/time set; use published cache files for bulk current data. |36| Historical global surface reports | NOAA NCEI Integrated Surface Database (ISD) | Preserve USAF/WBAN identity, units, and QC fields. |37| Historical or recent radiosondes | NOAA NCEI IGRA | Use the station inventory and retain level and QC metadata. |38| Station history and identifier changes | NOAA NCEI station history/HOMR | Resolve moves, renames, and observing-platform changes. |3940Prefer an existing project adapter when it already handles the provider's41schema, retries, and cache. Record the exact endpoint or archive object used.4243## Define the Observation Request4445Resolve these values before fetching:4647- observation type and variables;48- station identifier system, not just the identifier string;49- start and end instants in UTC, including interval inclusivity;50- maximum acceptable observation age;51- raw, decoded, or both output forms;52- required quality flags and policy for rejected values;53- output units and missing-value representation;54- cache location and retention.5556For spatial queries, also define the search geometry, distance limit, and how a57station is selected. Return the selected station and distance rather than58silently using the nearest report.5960## Fetch Recent METARs6162The Aviation Weather Center exposes machine-readable METAR data under63`/api/data/metar`. Send a descriptive user agent, keep the query narrow, and64handle a valid `204 No Content` separately from an error.6566```python67import json68from urllib.error import HTTPError69from urllib.parse import urlencode70from urllib.request import Request, urlopen717273def fetch_metars(stations, hours=2):74 station_ids = sorted({station.strip().upper() for station in stations})75 if not station_ids or any(len(station) != 4 for station in station_ids):76 raise ValueError("use one or more four-character ICAO station IDs")77 if not 1 <= hours <= 24:78 raise ValueError("hours must be between 1 and 24 for this narrow query")7980 query = urlencode({81 "ids": ",".join(station_ids),82 "format": "json",83 "hours": hours,84 })85 request = Request(86 f"https://aviationweather.gov/api/data/metar?{query}",87 headers={"User-Agent": "weather-observation-fetching/1.0 contact@example.org"},88 )89 try:90 with urlopen(request, timeout=30) as response:91 if response.status == 204:92 return []93 records = json.load(response)94 except HTTPError as exc:95 if exc.code == 429:96 raise RuntimeError("AWC rate limit reached; honor Retry-After") from exc97 raise9899 if not isinstance(records, list):100 raise RuntimeError("unexpected METAR response shape")101 return records102```103104Replace the example contact address with an appropriate project contact. For a105large current snapshot, download the provider's compressed cache file once106instead of issuing many station queries.107108## Fetch Historical Surface Data109110For ISD:1111121. Resolve the station using the current station inventory and its USAF/WBAN113 identifiers.1142. Confirm that the station's coverage overlaps the requested time range.1153. Use bulk HTTPS files for a large historical request; avoid one network call116 per observation.1174. Preserve the original report and source/QC codes before converting units.1185. Treat trace values, missing sentinels, and calm or variable winds according119 to the data format documentation.1206. Join station metadata by both identifier and effective date when station121 history matters.122123Do not assume one station identifier always represents an unchanged location or124instrument throughout its archive.125126## Fetch Radiosonde Profiles127128For IGRA:1291301. Search the station inventory by identifier or location and verify the131 station's record period.1322. Fetch the station file covering the requested dates rather than scraping an133 interactive page.1343. Select by the report's UTC time and retain nominal, launch, and release times135 when the source supplies them.1364. Preserve pressure, height, temperature, moisture, wind, level type, and QC137 fields. Standard and significant levels are both scientifically relevant.1385. Sort the profile only after parsing; do not invent levels or interpolate139 across large gaps during acquisition.1406. Report an absent launch or incomplete profile explicitly.141142Many upper-air stations usually report near 00 and 12 UTC, but the archive is143the authority. Do not manufacture a schedule or select a different day solely144because a nominal time is missing.145146## Normalize Without Erasing Provenance147148Each normalized record should retain:149150- provider and dataset;151- station identifier plus identifier scheme;152- station latitude, longitude, elevation, and metadata effective date;153- observation time in UTC and, when available, receipt or ingestion time;154- raw report or raw archive row;155- decoded values with explicit units;156- provider quality flags and local QC decisions;157- retrieval time, source URL/object, and response identity.158159Store original and converted values side by side when a conversion could affect160rounding. Never use the HTTP `Last-Modified` timestamp as the observation time.161162## Quality Control and Deduplication163164- Treat provider flags as data, not decoration. Define which flags are accepted,165 rejected, or retained with warnings.166- Deduplicate on provider identity, station, observation time, and report type.167 When corrected reports exist, preserve the correction lineage.168- Check physical ranges only after handling missing and trace encodings.169- Verify wind direction conventions, temperature scales, pressure units, and170 precipitation accumulation periods before combining sources.171- Keep station time, observation time, and ingestion time distinct.172- Flag stale reports against the request's maximum age rather than returning173 them as current conditions.174175## Reliability and Caching176177- Honor provider request limits, `Retry-After`, and published bulk-download178 guidance.179- Retry timeouts, `408`, `429`, and transient `5xx` failures with bounded180 backoff and jitter.181- Cache immutable archive files by URL/object identity and current API responses182 for no longer than their update cadence permits.183- Write downloads to a temporary path, validate content and expected date range,184 then rename atomically.185- Keep partial files separate from accepted cache entries.186- For one-shot processing, remove request-owned temporary observations in187 `finally` only after the derived artifact and provenance record are durable.188189## Verification Checklist190191- The station identifier scheme and station metadata are explicit.192- All selected observations fall inside the requested UTC interval.193- The report time, receipt time, and retrieval time are not conflated.194- Units, missing sentinels, trace values, and QC flags are handled explicitly.195- Raw reports or rows remain available for audit.196- Duplicate and corrected reports follow a documented rule.197- A no-data response is distinguished from provider failure.198- The final result reports stale, incomplete, or rejected observations.199200## Security & Safety Notes201202- Use only public endpoints or data the user is authorized to access.203- Do not place API keys, credentials, signed URLs, or private station data in204 examples, logs, caches, or provenance manifests.205- Keep TLS certificate verification enabled.206- Encode query parameters rather than concatenating untrusted station input into207 a URL.208- Bound station count, time span, response size, retries, and parallelism.209- Follow provider terms, rate limits, and attribution requirements.210211## Common Pitfalls212213- **The latest METAR is old:** The station has not reported recently. Apply the214 maximum-age contract and report staleness.215- **A station lookup returns the wrong site:** ICAO, WMO, USAF/WBAN, and IGRA216 identifiers were treated as interchangeable. Preserve the identifier scheme.217- **Temperatures look extreme:** Missing sentinels or units were converted as218 real values. Parse format metadata before unit conversion.219- **A sounding has too few levels:** Only mandatory levels were retained or the220 launch was incomplete. Preserve significant levels and surface data.221- **An archive record moved:** Station history changed. Join metadata by its222 effective period and record the selected version.223224## Limitations225226- Provider schemas, retention windows, station inventories, and usage limits can227 change; consult current official documentation.228- Quality flags identify known conditions but do not guarantee that a229 measurement is scientifically suitable for a particular analysis.230- This skill does not perform radar retrieval, satellite retrieval, model-data231 fetching, or forecast verification.232233## Additional Resources234235- [NOAA Aviation Weather Center Data API](https://aviationweather.gov/data/api/)236- [NOAA NCEI Integrated Surface Database](https://www.ncei.noaa.gov/products/land-based-station/integrated-surface-database)237- [NOAA NCEI Integrated Global Radiosonde Archive](https://www.ncei.noaa.gov/products/weather-balloon/integrated-global-radiosonde-archive)238- [NOAA NCEI station histories](https://www.ncei.noaa.gov/products/land-based-station/station-histories)