Fetch numerical weather prediction data without treating a multi-gigabyte GRIB2
file as one indivisible download. Prefer an existing project adapter or Herbie;
use direct object-store byte ranges only when the supported path cannot express
the request.
This skill covers transport, inventory selection, caching, and verification. It
does not interpret the forecast or decide whether a model is meteorologically
appropriate.
Do not activate this skill for ordinary weather-forecast questions that do not
require model files.
Resolve these values before downloading:
valid = initialization + lead);Confirm that the cycle is complete, the forecast hour exists for that cycle,
and the requested location is inside the model domain. A recent 404 often
means the cycle is not published yet; step back to a completed cycle instead of
retrying indefinitely.
the model.
Azure, and other configured sources and understands their key layouts.
spatial slice from many times or members.
adapter exists.
Do not recursively list a large public bucket to discover one run. Build the
documented prefix for the model, cycle, product, forecast hour, and member, then
probe that exact object and its inventory.
Use an explicit provider priority and record the provider that succeeded. A
fallback must refer to the same model run, product, member, and forecast hour;
never silently substitute a different forecast.
GRIB2 files contain consecutive messages. A companion inventory such as.idx, .grib2.idx, or .grb2.inv records each message's starting byte.
start; request the final selected message through EOF when no end is known.
Range: bytes=START-END request per range. S3 does not supportmultiple ranges in one GetObject request.
206 Partial Content and a matching Content-Range. If a serveranswers 200, do not append the whole object as though it were a fragment.
ETag and/or Last-Modified) whiledownloading. Discard fragments if the object changes.
atomically into the cache.
A GRIB message contains one field over its grid. Message-range subsetting saves
variables and levels, not geography. A point request still downloads the full
grid for every selected message unless the provider offers a point, regional,
Zarr, or other chunked endpoint.
Use the current search argument; searchString is deprecated. Start from the
inventory, fail on an empty match, and keep the download directory explicit.
from pathlib import Path
from herbie import Herbie
PRESSURE_FIELDS = (
r":(?:HGT|TMP|RH|SPFH|UGRD|VGRD):\d+(?:\.\d+)? mb:"
)
def fetch_hrrr_pressure_run(initialization, forecast_hour, cache_dir):
cache_dir = Path(cache_dir)
h = Herbie(
initialization,
model="hrrr",
product="prs",
fxx=forecast_hour,
priority=["aws", "nomads", "google", "azure"],
save_dir=cache_dir,
verbose=False,
)
selected = h.inventory(PRESSURE_FIELDS)
if selected.empty:
raise RuntimeError("inventory matched no pressure-level fields")
downloaded = h.download(PRESSURE_FIELDS, errors="raise")
path = Path(downloaded) if downloaded is not None else None
if path is None or not path.is_file() or path.stat().st_size == 0:
raise RuntimeError("GRIB2 subset was not materialized")
return path, {
"model": h.model,
"product": h.product,
"initialization": h.date.isoformat(),
"forecast_hour": h.fxx,
"valid_time": h.valid_date.isoformat(),
"provider": h.grib_source,
"remote_object": str(h.grib),
"messages": len(selected),
}
For xarray output, call h.xarray(search, ...) and handle either onexarray.Dataset or a list of incompatible GRIB hypercubes. Merge only groups
whose coordinates and dimensions are compatible, and close every dataset when
finished.
NOAA Open Data buckets allow unsigned reads. --no-sign-request prevents the
AWS CLI from loading credentials; it does not disable TLS verification.
aws s3 ls --no-sign-request s3://noaa-hrrr-bdp-pds/hrrr.YYYYMMDD/conus/
aws s3api get-object --no-sign-request \
--bucket noaa-hrrr-bdp-pds \
--key "hrrr.YYYYMMDD/conus/hrrr.tHHz.wrfprsfFF.grib2" \
--range "bytes=START-END" fragment.grib2
Use these commands to inspect a documented public object or reproduce one
known range. For normal multi-message assembly, reuse Herbie or the project's
tested downloader instead of scripting binary concatenation in shell.
A pressure-level file alone may not contain a usable surface row. Before
building a vertical profile, require:
moisture variable (dew point, relative humidity, or specific humidity), and
U/V wind;
Some providers split pressure and surface fields into separate products. Fetch
and join the companion product from the same run, or reject the request with a
list of missing fields. Do not fabricate a ground row or silently reduce the
profile to a short mandatory-level list.
After decoding, sort pressure monotonically, remove duplicate levels, normalize
units and longitude conventions, and run the consuming project's profile QC.
sufficient.
project's model-aware nearest-cell routine; verify the selected latitude,
longitude, and distance.
chunked Zarr or provider-native endpoint before scaling up.
filename alone is not enough provenance.
408, 429, and transient 5xx responses with boundedexponential backoff and jitter; honor Retry-After.
coordinates as transient failures.
cancellation slower.
remote object identity still matches.
directory and remove it in finally after the derived artifact is durable.
delete a shared user cache as request cleanup.
Measure discovery, inventory, transfer, decode, point extraction, and rendering
separately. A slow end-to-end request is not evidence that GRIB decoding is the
bottleneck.
member match the request.
plausible and explicit.
that request.
--no-verify-ssl.
allocating buffers or writing files.
retries before a large batch.
completed cycle and report the fallback.
was too broad, or the server ignored Range.
hypercubes. Process them separately or merge only compatible groups.
chunks. Use a point/regional service or Zarr when available.
and object identity before accepting a cache hit.
can change; verify them against current provider documentation.
the full object or use a different provider.
proprietary-provider credentials and quotas.