当前位置:   article > 正文

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

java 解析 grib2

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/293786
推荐阅读
相关标签
  

闽ICP备14008679号