jswhit / pygrib

Python interface for reading and writing GRIB data
https://jswhit.github.io/pygrib
MIT License
319 stars 93 forks source link

possible bug accessing grib parameters #202

Open Yamioni2007 opened 2 years ago

Yamioni2007 commented 2 years ago

I tried the following in a python notebook:

import pygrib
grbs = pygrib.open('Current_db_2021110500_00.grb2')
file = grbs[1]
print(file)

1:Eastward sea water velocity:m s**-1 (instant):regular_ll:depthBelowSea:level 2 m:fcst time 15 mins:from 202111050000

print(file['stepUnits'])

0

print(grbs[1]['stepUnits'])

1

If I first save the single layer in a variable, print it once and access then the 'stepUnits' I get 0, which is correct for my grib file. If I acess the 'stepUnits' directly, I get 1, which is wrong.

jswhit commented 1 year ago

This doesn't make sense to me - and I can't reproduce it with the sample files I have. Can you post your grib file? (if it's small enough you can just gzip it and attach it to this issue)