MeteoInfo的个人博客分享 http://blog.sciencenet.cn/u/MeteoInfo

博文

Mixed grib-1 and grib-2 data file

已有 6812 次阅读 2017-4-30 12:02 |个人分类:MeteoInfo|系统分类:科研笔记

GRIB是气象领域的常用数据格式,有grib-1和grib-2两个版本。通常一个数据文件的数据格式是唯一的,不过ECMWF作为气象领域的大佬还是比较任性的,弄出个grib-1和grib-2混合文件来,这就比较难为通用的grib数据处理软件了。NCL的email list里有相关的提问,答复只能先用wgrib等工具将数据文件分割为两个分别只包含grib-1和grib-2数据的文件,然后再用NCL读取、绘图。


From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Fri Jun 20 2014 - 11:15:55 MDT

Hi Balazs,

This is a known issue with NCL's GRIB reader. It currently cannot handle
these mixed GRIB 1 and 2 files. We have a ticket in place for this and we
do hope to solve it. If you want NCL to read the data in these files now
you will need to separately extract the GRIB1 and GRIB2 records into
separate files. I believe that you could do this either using the ECMWF
grib_api tool, or you could use the NCEP tools wgrib and wgrib2. wgrib.

Using wgrib and wgrib2 is pretty simple:

wgrib2 EL13040712 -grib grib2.grb
wgrib EL13040712 -grib -d all -o grib1.grb

produced files grib1.grb and grib2.grb that work fine with NCL.

ECMWF has something called grib_copy (
http://old.ecmwf.int/publications/manuals/grib_api/grib_copy.html) that is
also supposed to be easy to use.

Hope this helps.
-dave


MeteoInfo Java版对于grib数据的解码用的是Unidata开发的Netcdf Java库,关于如果读取混合文件的问题得到的答复如下:

Greetings Yaqiang,
netCDF-Java cannot handle this situation. I'm not sure what advantage
there is to ECMWF mixing grib records in a single file, but it would be
interesting to understand.
The only solution is to split the mixed grib file such that all of the
grib1 messages are in one file, and all of the grib2 messages are in
a second file.
I think you can do this using the grib_filter command line tool from
ecCodes (formally grib-api). You can write a rules file with the single
line:
write "./split/all_grib_[editionNumber]_records.grib[editionNumber]";
and then run:
grib_filter rules_files data/mixed.grb
where mixed.grb is the file containing the grib 1 and 2 messages. The result
will be that all of the grib1 messages will be output to:
split/all_grib_1_records.grib1
and all of the grib2 messages will be output to:
split/all_grib_2_records.grib2
For more info, check out:
Cheers,
Sean


同样需要先对混合文件进行分割。仔细看了看Netcdf Java库中相关代码,在读取grib数据时会根据第一个Message判断是grib-1还是grib-2。因此考虑事先给定grib-1或者grib-2格式,对数据文件按照两种格式读取两次,以便读取grib-1和grib-2中的所有变量。对MeteoInfo相关代码进行了修改实现了这样的功能,但是却发现读出来的变量还是偏少,看来这种方式并不能解决问题,目前还是需要先对混合文件进行分隔。



https://blog.sciencenet.cn/blog-611158-1052058.html

上一篇:Little endian HYSPLIT concentration data reading
下一篇:发布MeteoInfo 1.4.3
收藏 IP: 1.180.215.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-12-23 06:49

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部