wgrib读grib数据
该文章来自博客:http://windforestwing.blog.163.c ... 412007103084743804/如有错误 ,大家及时指出啊!ps:meteoinfo可以直接处理grib数据
===========================
grib格式转换心得
1、wgrib的使用
在cmd命令行下键入wgrib后即可察看wgrib相关命令参数,简要介绍如下:
l Inventory/diagnostic–output selections 详细目录或诊断的输出选择
-s short inventory 简短目录
-v verbose inventory 详细目录
-V diagnostic output <not inventory> 诊断输出
<none> regular inventory 一般目录
例如:wgrib E:\GrADS\Data\grib2005071500 –v>a.txt
Options 相关选项
-PDS/-PDS10 print PDS in hex/decimal
十六进制或二进制绘制PDS图
-GDS/-GDS10 print GDS in hex/decimal
十六进制或二进制绘制GDS图
-verf print forecast verification time
-ncep_opn/-ncep_rean default T62 NCEP grib table
-4yr print year using 4 digits
l Decoding GRIB selection GRIB格式解码选项
-d [record number|all] decode record number
按编号输出数据
-p [byte position] decode record at byte position
按二进制位置输出数据
-i decode controlled by stdin <inventory list>
按输入流控制编码,一般转化Grib文件都要加
<none> no decoding
Options 相关选项
-text/-ieee/-grib/-bin conver to text/ieee/grib/bin
转化格式控制
-nh/-h output will have no headers/headers
是否包含标题头
-H output will include PDS and GDS <-bin/-ieee only>
输出否否包含PDS和GDS
-append append to output file
在输出文件上添加而不是替换
-o [file] output file name, ‘dump’ is default
输出文件名
综合使用实例:
DOS命令行下:
>wgrib grib_file_name | find “:GAP:” | wgrib grib_file_name –i –nh –text –o temp
linux shell命令行下:
% wgrib grib_file_name | grep “:GAP:” | wgrib grib_file_name –i –nh –text –o temp
从Grib格式文件中选择GAP参数相关的数据生成名为temp的文本文件
2、 Grib文件目录说明
l wgrib –s生成目录:
1:0:d=05071500:HGT:1000 mb:anl:NAve=0
1) 记录号
2) 二进制位置
3) 时间
4) 参数名称
5) 层次值
6) analysis分析数据,也可能是fcst(forecast 预报数据)
7) 用于求平均的格点数
l wgrib –v 生成目录:
1:0:D=2005071500:HGT:1000 mb:kpds=7,100,1000:anl:"Geopotential height [gpm]
1) 记录号
2) 二进制位置
3) 时间
4) 参数名称
5) 层次值
6) kpds,第一个数字是Grib参数编号,比如PRES是1,TMP是11;第二个数字是层次类型(高度层或等压面层);第三个数字是层次值;
7) analysis分析数据,也可能是fcst(forecast 预报数据)
8) 该参数的解释及单位
l wgrib –V 生成目录:
rec 1:0:date 2005071500 HGT kpds5=7 kpds6=100 kpds7=1000 levels=(3,232) grid=3 1000 mb anl:
HGT=Geopotential height [gpm]
timerange 10 P1 0 P2 0 TimeU 1 nx 360 ny 181 GDS grid 0 num_in_ave 0 missing 0
center 7 subcenter 0 process 82 Table 2
latlon: lat 90.000000 to -90.000000 by 1.000000 nxny 65160
long 0.000000 to -1.000000 by 1.000000, (360 x 181) scan 0 mode 128 bdsgrid 1
min/max data -631 334 num bits 14 BDS_Ref -6310 DecScale 1 BinScale 0
这个综合几种两种目录显示目前只能看明白其中一部分……
l wgrib <none> 生成目录:
1:0:d=05071500:HGT:kpds5=7:kpds6=100:kpds7=1000:TR=10:P1=0:P2=0:TimeU=1:1000 mb:anl:NAve=0
1) 记录号
2) 二进制位置
3) 时间
4) 参数名称
5) Grib参数编号,比如PRES是1,TMP是11
6) 层次类型(高度层或等压面层)
7) 层次值
8) 时间范围
9) 时间1的时段
10) 时间2的时段
11) 预报时间单位
12) 层次值
13) analysis分析数据,也可能是fcst(forecast 预报数据)
14) 用于求平均的格点数
3、 利用C程序转化Grib格式文件与读取Grib文件
C# 实例(Web平台上)
/*调用Dos命令实现Grib文件到Text文件的转换*/
private void GribToText()
{
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true; //不创建窗口
process.Start();
string command = "wgrib E:\\Projects\\AtmosData\\grib2005071500 | find \":5WAVA:\" | wgrib E:\\Projects\\AtmosData\\grib2005071500 -i -nh -text -o E:\\Projects\\AtmosData\\temp";
process.StandardInput.WriteLine(command); //调用Dos命令
process.StandardInput.WriteLine("exit");
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
Response.Write(output); //将执行结果输出
}
/*将Text文件中的Grib数据读入临时数组*/
private void ReadTextData()
{
StreamReader GribText = new StreamReader("E:\\Projects\\AtmosData\\temp");
string[] aryReadResult = new string[65160]; //360*181个格点数据
float[] aryData = new float[65160];
for (int i = 0; i < 1000; i++)
{
aryReadResult = GribText.ReadLine();
aryData = Convert.ToSingle(aryReadResult);
}
GribText.Close();
}
C++实例(控制台下)
/*调用DOS命令将Grib文件转化为临时文本文件*/
system("wgrib E:\\Projects\\AtmosData\\grib2005071500 | find \":5WAVA:\" | wgrib E:\\Projects\\AtmosData\\grib2005071500 -i -nh -text -o E:\\Projects\\AtmosData\\temp");
/*使用文件输入输出流将text文件读入数组中*/
FILE *fp;
long int i;
float wava[65160] ={0};
char *path ="E:\\Projects\\AtmosData\\temp";
if((fp=fopen(path,"r")) == NULL)
{
printf("Can not open file!");
exit(1);
}
for( i=0; i<GRIBNUMBER; i++)
{
fscanf_s(fp,"%f",&wava);
}
for( i=0; i<GRIBNUMBER; i++)printf("%f ",wava);
fclose(fp);
wgrib读grib数据的更多相关文章
- Windows下Python读取GRIB数据
之前写了一篇<基于Python的GRIB数据可视化>的文章,好多博友在评论里问我Windows系统下如何读取GRIB数据,在这里我做一下说明. 一.在Windows下Python为什么无法 ...
- Flink RichSourceFunction应用,读关系型数据(mysql)数据写入关系型数据库(mysql)
1. 写在前面 Flink被誉为第四代大数据计算引擎组件,即可以用作基于离线分布式计算,也可以应用于实时计算.Flink的核心是转化为流进行计算.Flink三个核心:Source,Transforma ...
- Qt 实时读串口数据,并将读到的数据从网口发送出去
需求: 1. 要试试从串口读取数据 2. 将读到的数据从网口发送出去 3.开机启动 4. 没有界面 第一部分 配置Qt Pro文件 需要Qt += serialport network 第二部分 - ...
- 读<<大数据时代>>的一些感想
第一次听说<<大数据时代>>这本书,是在网上看到的央视搞的一个2013中国好书评选活动推荐的25本“中国好书”的榜单中看到的.然后迅速上豆瓣上查看了一下对该书的评价,一看非常高 ...
- jxl读数据库数据生成xls 并下载
1.所需jar jxl-2.6.10.jar jxls-core-1.0-RC-3.jar jxls-reader-1.0-RC-3.jar 2. excel修改行宽度封装 SheetColumn.j ...
- WinRT知识积累1之读xml数据
前述:这个知识是在Windows8.1或WP8.1中运用Linq to xml获取一个xml文件里的数据.(网上也很多类似的知识,可以借鉴参考) 平台:windows8.1 metro 或者WP8.1 ...
- 往Android SDCard中读写入数据
一.用Environment (写) 1.API获取sdcard的路径 File path=Environment.getExternalStorageDirectory(); path=new Fi ...
- A站有一个页面需要PV统计 A站读写该数据 B站读该数据 需要数据同步
A站弄个缓存,并且开放出一个读取借口给B站 B站读取数据的时候,调用该接口和数据库内的数据累加,然后进行限时即可 ---------------------- 另外其他方法 session服务.mem ...
- matlab读xls数据
[ndata,label,abalone]=xlsread('data.xls') ndata:表示数字属性 label:表示类别属性 abalone:全部数据
随机推荐
- DEBUG模式详解
1. 如果开启了DEBUG模式,那么以后我们修改了Django项目的代码,然后按下ctrl+s,那么Django就会自动的给我们重启项目,不需要手动重启.2. 如果开启了DEBUG模式,那么以后Dja ...
- debian的python蓝牙库
sudo apt--dev pip install bluepy
- Ubuntu 14.04 下安装 MongoDB 服务器 和 PHP MongoDB Driver 数据驱动
https://laravel-china.org/topics/309/install-mongodb-server-and-php-mongodb-driver-data-driver-under ...
- elasticsearch 口水篇(9)Facet
FACET 1)Terms Facet { "query" : { "match_all" : { } }, "facets" : { &q ...
- springboot(整合事务和分布式事务)
springboot +mybatis 单数据源,事务 事务:简单理解指的是一组操作,里面包含许多个单一的逻辑,只要有一个逻辑没有执行成功 ,那么都算失败.所有的数据都回归到最初的状态(回滚) 代码实 ...
- Java学习——Applet菜单
程序功能:在窗口中添加菜单栏,在菜单栏添加菜单项,并添加下拉菜单和 2 级菜单,通过选择菜单项可以执行不同操作,生成如下图所示窗口. package cys; import java.awt.*; i ...
- JSON 简介
ylbtech-JSON: JSON 简介 JSON:JavaScript Object Notation(JavaScript 对象表示法) JSON是存储和交换文本信息的语法,类似 XML. JS ...
- 在HP-UX 11.11用swinstall安装gcc 4.2.3
agent60 在linux上执行不了,原因是操作系统内核版本不一致,需要重新编译包. file $SHELL 显示 PA-RISC1.1 在HP-UX 11.31 PA-RISC1.1 版本中 编 ...
- [UE4]编辑器偏好设置,在同一个窗口以标签打开蓝图
- vs2015 编译google v8
转自:http://blog.csdn.net/runningman2012/article/details/54692010 系统Win10 64位,vs2015 1. git 下载depot_to ...