Home / Market / weather observation fetching

weather observation fetching

Retrieve surface and upper-air weather observations from authoritative APIs and archives with station identity, time, units, and quality flags preserved.

skill★ 508990 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: weather-observation-fetching description: "Retrieve surface and upper-air weather observations from authoritative APIs and archives with station identity, time, units, and quality flags preserved." category: data risk: safe source: self source_type: self date_added: "2026-09-19" author: ShianMike tags: [weather, observations, metar, radiosonde, noaa, quality-control] tools: [claude, cursor, gemini, codex]

---

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

profiles.

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:

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:

  1. Resolve the station using the current station inventory and its USAF/WBAN

identifiers.

  1. Confirm that the station's coverage overlaps the requested time range.
  2. Use bulk HTTPS files for a large historical request; avoid one network call

per observation.

  1. Preserve the original report and source/QC codes before converting units.
  2. Treat trace values, missing sentinels, and calm or variable winds according

to the data format documentation.

  1. 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:

  1. Search the station inventory by identifier or location and verify the

station's record period.

  1. Fetch the station file covering the requested dates rather than scraping an

interactive page.

  1. Select by the report's UTC time and retain nominal, launch, and release times

when the source supplies them.

  1. Preserve pressure, height, temperature, moisture, wind, level type, and QC

fields. Standard and significant levels are both scientifically relevant.

  1. Sort the profile only after parsing; do not invent levels or interpolate

across large gaps during acquisition.

  1. 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:

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

rejected, or retained with warnings.

When corrected reports exist, preserve the correction lineage.

precipitation accumulation periods before combining sources.

them as current conditions.

Reliability and Caching

guidance.

backoff and jitter.

for no longer than their update cadence permits.

then rename atomically.

finally only after the derived artifact and provenance record are durable.

Verification Checklist

Security & Safety Notes

examples, logs, caches, or provenance manifests.

a URL.

Common Pitfalls

maximum-age contract and report staleness.

identifiers were treated as interchangeable. Preserve the identifier scheme.

real values. Parse format metadata before unit conversion.

launch was incomplete. Preserve significant levels and surface data.

effective period and record the selected version.

Limitations

change; consult current official documentation.

measurement is scientifically suitable for a particular analysis.

fetching, or forecast verification.

Additional Resources