写入grib2++java_科学网—Mixed grib-1 and grib-2 data file - 王亚强的博文
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
總結
以上是生活随笔為你收集整理的写入grib2++java_科学网—Mixed grib-1 and grib-2 data file - 王亚强的博文的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 利用jquery的ajax实现文件上传
- 下一篇: 高并发系统设计——系统的容灾备份设计