Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong message length error? #297

Open
tsilas3 opened this issue Mar 22, 2024 · 1 comment
Open

Wrong message length error? #297

tsilas3 opened this issue Mar 22, 2024 · 1 comment

Comments

@tsilas3
Copy link

tsilas3 commented Mar 22, 2024

Came across this unusual error I'd never seen before while working with Herbie today. Running the following code:

from herbie import Herbie

H = Herbie(
        "2020-06-06 12:00", # model run date
        model="hrrr", # model name
        product="prs", # model product name (model dependent)
        fxx=0, # forecast lead time
)

ds1 = H.xarray(searchString=":(?:TMP|DPT|HGT|UGRD|VGRD):\d+ mb", remove_grib=False)
ds2 = H.xarray(searchString=":(?:HGT|UGRD|VGRD):\d+ mb", remove_grib=False)

Defining ds1 works as expected. But attempting to define ds2 repeatedly generates the following error message, apparently indefinitely until the script is manually terminated:

skipping corrupted Message
Traceback (most recent call last):
  File "/home/tsilas/.conda/envs/herbie/lib/python3.9/site-packages/cfgrib/messages.py", line 273, in itervalues
    yield self.filestream.message_from_file(file, errors=errors)
  File "/home/tsilas/.conda/envs/herbie/lib/python3.9/site-packages/cfgrib/messages.py", line 340, in message_from_file
    return Message.from_file(file, offset, **kwargs)
  File "/home/tsilas/.conda/envs/herbie/lib/python3.9/site-packages/cfgrib/messages.py", line 96, in from_file
    codes_id = eccodes.codes_grib_new_from_file(file)
  File "/home/tsilas/.conda/envs/herbie/lib/python3.9/site-packages/gribapi/gribapi.py", line 409, in grib_new_from_file
    GRIB_CHECK(err)
  File "/home/tsilas/.conda/envs/herbie/lib/python3.9/site-packages/gribapi/gribapi.py", line 226, in GRIB_CHECK
    errors.raise_grib_error(errid)
  File "/home/tsilas/.conda/envs/herbie/lib/python3.9/site-packages/gribapi/errors.py", line 381, in raise_grib_error
    raise ERROR_MAP[errid](errid)
gribapi.errors.WrongLengthError: Wrong message length

It seems odd that getting temp and dewpoint data would be necessary to also get height and wind, but this is the temporary fix that I've found works.

What is stranger is that this error only occurs when running on our server. I have no issues running the script on my personal laptop. Both are running the same version of herbie, but slightly different versions of python (3.9.16 on laptop vs 3.9.18 on server). Does this suggest that the grib files on the server are somehow corrupted, despite both sets of grib files being downloaded the same way via FastHerbie, or is this some other herbie issue?

@blaylockbk
Copy link
Owner

The errors are coming from cfgrib, not Herbie. That said, it doesn't mean Herbie isn't at fault. It could be the GRIB2 file is corrupt or is an incomplete download.

Check and see if you can read the GRIB2 file with other grib readers (cfgrib, pygrib, any other tool) and see if that is true. Or, delete the GRIB2 file on disk and try downloading it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants