写入grib2++java_科学网—Mixed grib-1 and grib-2 data file - 王亚强的博文

这篇博文讨论了如何处理混合了grib-1和grib-2数据的文件,这是由ECMWF创建的一个问题。NCL和netCDF-Java库目前无法直接读取这种格式的文件,需要使用wgrib、wgrib2或ecCodes的grib_filter工具进行分割。文章提到了MeteoInfo Java版的尝试和面临的困难,指出目前最佳解决方案仍然是先分割文件。
摘要由CSDN通过智能技术生成

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

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相关代码进行了修改实现了这样的功能,但是却发现读出来的变量还是偏少,看来这种方式并不能解决问题,目前还是需要先对混合文件进行分隔。

转载本文请联系原作者获取授权,同时请注明本文来自王亚强科学网博客。

链接地址:http://blog.sciencenet.cn/blog-611158-1052058.html

上一篇:Little endian HYSPLIT concentration data reading

下一篇:发布MeteoInfo 1.4.3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值