gribfile='gfs20191010.0p25' #file containing 384 hours of forecast data for variable Geopotential Height
grbs=pygrib.open(gribfile)
grb1=grbs.select(name='Geopotential Height')[0:24]
day1 = grb1.values
当我运行上面的代码时,我收到以下错误:
AttributeError: 'list' object has no attribute 'values'
.values 键仅在选择列表中的第一项时有效,如下所示:
grb1 = grbs.select(name='Geopotential Height')[0]
但不是当我这样做
grb1 = grbs.select(name='Geopotential Height')[0:24]
我知道 .values 键的格式是 dict.values,但我不知道如何检索前 24 个列表项中的数据。我的目标是将所选变量(Geopotential Height)的前 24 个文件作为一个 numpy 数组,但为了做到这一点,我需要能够使用 .values 提取每个文件中包含的信息。
我一直在关注 pygrib 的文档:https ://jswhit.github.io/pygrib/docs/