Open NWP forecasts — catalog explorer (no network)¶
Explore the bundled NWP model catalog offline: the models, their providers / fetch backends, and one model's forecast axis + bands. No bucket or Herbie access — runs deterministically at docs-build time.
Setup¶
Consolidate the imports up front. earthlens.nwp.Catalog loads the bundled NWP model catalog (no network); Counter tallies the models by category and matplotlib draws the summary chart at the end.
from collections import Counter
from cleopatra.glyphs.stats.bar_glyph import BarGlyph
from earthlens.nwp import Catalog
Load the catalog¶
Instantiate the catalog and count how many NWP models it ships with.
cat = Catalog()
print(f'NWP models: {len(cat.datasets)}')
Models by fetch backend¶
Each model is fetched through one of a handful of backends (herbie / ecmwf-opendata / direct-https / meteofrance-api). Group the models by backend to see how the catalog splits across them.
# Models grouped by fetch backend (herbie / ecmwf-opendata / direct-https / meteofrance-api)
dict(sorted(Counter(m.backend for m in cat.datasets.values()).items()))
Models by provider¶
The same models, grouped instead by provider — the upstream organisation (NOAA NODD, DWD, ECMWF, …) that publishes each forecast.
# Models grouped by provider
dict(sorted(Counter(m.provider for m in cat.datasets.values()).items()))
One model's forecast axis and bands¶
Pull a single model (gfs) and inspect its forecast geometry — the run cycles, the forecast horizon, the step cadence, and a sample of its bands.
# One model's forecast axis and a few bands
gfs = cat.get_dataset('gfs')
print('provider :', gfs.provider, '| backend:', gfs.backend)
print('cycles :', gfs.cycles_utc)
print('horizon :', gfs.horizon_h, 'h | step cadence:', gfs.step_cadence_h, 'h')
print('bands :', list(gfs.bands)[:6], f'... ({len(gfs.bands)} total)')
Chart: models by fetch backend¶
Finally, draw the backend tally as a bar chart for a quick visual of how the catalog is distributed across fetch backends.
by_backend = Counter(m.backend for m in cat.datasets.values())
_fig, ax, _bars = BarGlyph(
list(by_backend), list(by_backend.values()), figsize=(8, 4)
).plot(
title=f'{len(cat.datasets)} NWP models by fetch backend',
ylabel='models',
colors=['tab:green'] * len(by_backend),
)
# Backend names are long; angle them on the glyph's own axes.
ax.tick_params(axis='x', rotation=20)