爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 21706|回复: 6

[求助] Python读取grib2文件Total precipitation显示no matches found

[复制链接]
发表于 2021-1-15 14:54:19 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
本帖最后由 hong050032 于 2021-1-15 15:02 编辑

用python的pygrib读取grib2文件
  1. import pygrib
  2. grbs = pygrib.open('Z_SURF_C_BABJ_20210115080515_P_CMPA_FAST_CHN_0P05_DAY-PRE-2021011508.GRB2')
  3. grbs.seek(0)
  4. f = open('information.txt', 'w')
  5. for grb in grbs:
  6.     f.write(str(grb)+'\n')
  7. f.close()
复制代码

得到1:Total precipitation:kg m-2 (instant):regular_ll:surface:level 0:fcst time 0 hrs:from 202101150800

但是
  1. grbs.seek(0)
  2. grb = grbs.select(name='Total precipitation')[0]
复制代码


提示:ValueError: no matches found
求大神指点迷津!


密码修改失败请联系微信:mofangbao
发表于 2021-1-18 20:28:04 | 显示全部楼层
同求大神,个人感觉是编码不一致导致的,但是没解决
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-1-19 08:57:45 | 显示全部楼层
掌控云海 发表于 2021-1-18 20:28
同求大神,个人感觉是编码不一致导致的,但是没解决

试了下,pywgrib2_xr可以
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2022-2-16 12:27:27 | 显示全部楼层
pygrib怎么安装的,我的怎么安装不了?求指教
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2024-3-9 17:13:27 | 显示全部楼层
博主这个问题现在解决了吗
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2024-11-29 15:39:04 | 显示全部楼层
niecj09 发表于 2024-3-9 17:13
博主这个问题现在解决了吗

1:Temperature:K (instant):regular_ll:surface:level 0:fcst time 1 hrs:from 202101010000
2:2 metre temperature:K (instant):regular_ll:heightAboveGround:level 2 m:fcst time 1 hrs:from 202101010000
3:2 metre relative humidity:% (instant):regular_ll:heightAboveGround:level 2 m:fcst time 1 hrs:from 202101010000
4:Total snowfall:m (accum):regular_ll:surface:level 0:fcst time 0-1 hrs (accum):from 202101010000
5:Surface pressure:Pa (instant):regular_ll:surface:level 0:fcst time 1 hrs:from 202101010000
6:Pressure reduced to MSL:Pa (instant):regular_ll:meanSea:level 0:fcst time 1 hrs:from 202101010000
7:224:224 (instant):regular_ll:surface:level 0:fcst time 1 hrs:from 202101010000
8:224:224 (max):regular_ll:surface:level 0:fcst time 0-1 hrs (max):from 202101010000
9:Total precipitation:kg m-2 (accum):regular_ll:surface:level 0:fcst time 0-1 hrs (accum):from 202101010000
10:10 metre U wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 1 hrs:from 202101010000
11:10 metre U wind component:m s**-1 (max):regular_ll:heightAboveGround:level 10 m:fcst time 0-1 hrs (max):from 202101010000
12:10 metre V wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 1 hrs:from 202101010000
13:10 metre V wind component:m s**-1 (max):regular_ll:heightAboveGround:level 10 m:fcst time 0-1 hrs (max):from 202101010000
14:15:15 (max):regular_ll:heightAboveGroundLayer:levels 5000.0-2000.0 m:fcst time 0-1 hrs (max):from 202101010000
15:237:237 (instant):regular_ll:heightAboveGroundLayer:levels 600-0 m:fcst time 1 hrs:from 202101010000
16:238:238 (instant):regular_ll:heightAboveGroundLayer:levels 600-0 m:fcst time 1 hrs:from 202101010000
17:224:224 (instant):regular_ll:surface:level 0:fcst time 1 hrs:from 202101010000

#####可以利用索引进行选取###
grbs = pygrib.open(path_nwp)
tp  =(grbs[9]).values
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2024-11-29 19:46:45 来自手机 | 显示全部楼层
【气小Py-012:GRIB解码(以EC细网格降水相态为例)_2023.08.01-哔哩哔哩】 https://b23.tv/yrUCaRf
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表