blaylockbk / Herbie

Download numerical weather prediction datasets (HRRR, RAP, GFS, IFS, etc.) from NOMADS, NODD partners (Amazon, Google, Microsoft), ECMWF open data, and the University of Utah Pando Archive System.
https://herbie.readthedocs.io/
MIT License
480 stars 72 forks source link

Bug Fix: Skip downloading invalid cURL range, such was in the RAP model wind messages. #260

Closed blaylockbk closed 9 months ago

blaylockbk commented 9 months ago

The RAP model uses GRIB submessages to store the wind vectors (UGRD and VGRD).

The byte ranges were incorrect for the first grib submessage, and would result in the entire file being downloaded instead of a single message.

image

To fix this, I simply check the byte range is valid (length of byte range is greater than 0). If the byte range is not valid, Herbie simply skips downloading that message.

from herbie import Herbie

model = "rap"
product = "awp130pgrb"
dtg = "2023-12-25 21:00"
fhr = 0
H = Herbie(dtg, model=model, product=product, fxx=fhr)
H.inventory(searchString="GUST|UGRD:10 m|VGRD:10 m|TMP:2 m|DPT:2 m")

ds = H.xarray(
    searchString="GUST|UGRD:10 m|VGRD:10 m|TMP:2 m|DPT:2 m",
    verbose=True,
    overwrite=True,
    remove_grib=False
)
image