GRIB格式转换心得(转自博客:http://windforestwing.blog.163.com/blog/static/19545412007103084743804/)
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[i] = GribText.ReadLine();
aryData[i] = Convert.ToSingle(aryReadResult[i]);
}
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[i]);
}
for( i=0; i<GRIBNUMBER; i++)printf("%f ",wava[i]);
fclose(fp);
GRIB格式转换心得(转自博客:http://windforestwing.blog.163.com/blog/static/19545412007103084743804/)的更多相关文章
- 使用Javascript/jQuery将javascript对象转换为json格式数据 - 海涛的CSDN博客 - 博客频道 - CSDN.NET
body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...
- 利用爬虫爬取指定用户的CSDN博客文章转为md格式,目的是完成博客迁移博文到Hexo等静态博客
文章目录 功能 爬取的方式: 设置生成的md文件命名规则: 设置md文件的头部信息 是否显示csdn中的锚点"文章目录"字样,以及下面具体的锚点 默认false(因为csdn中是集 ...
- 所有博客已经迁移到个人空间 blog.scjia.cc
所有博客已经迁移到个人空间 blog.scjia.cc
- 博客搬家到CSDN:http://blog.csdn.net/yeweiouyang
博客搬家到CSDN:http://blog.csdn.net/yeweiouyang
- Golang拼接字符串的5种方法及其效率_Chrispink-CSDN博客_golang 字符串拼接效率 https://blog.csdn.net/m0_37422289/article/details/103362740
Different ways to concatenate two strings in Golang - GeeksforGeeks https://www.geeksforgeeks.org/di ...
- 使用express+mongoDB搭建多人博客 学习(1) 安装blog工程
一.安装 1.安装express npm install -g expressnpm install -g express-generator 2.用ejs做模板,新建blog工程express -e ...
- 我的Android进阶之旅------>经典的大牛博客推荐(排名不分先后)!!
本文来自:http://blog.csdn.net/ouyang_peng/article/details/11358405 今天看到一篇文章,收藏了很多大牛的博客,在这里分享一下 谦虚的天下 柳志超 ...
- Django 搭建简易博客
新增一个 APP 博客算是一个功能集,因此我们应将其体现为一个模块.这表现在 Django 应用里则是为其创建一个 APP Package.现在让 manage.py 中的 startapp 闪亮登场 ...
- iOS的非常全的三方库,插件,大牛博客
转自: http://www.cnblogs.com/zyjzyj/p/6015625.html github排名:https://github.com/trending, github搜索:http ...
随机推荐
- 三类,23种设计模式,速记理解法!PHP
一,创建型设计模式 1.FACTORY—追MM少不了请吃饭了,麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西,虽然口味有所不同,但不管你带MM去麦当劳或肯德基,只管向服务员说“来四个鸡翅”就行了.麦当劳 ...
- css 面试学习
最经在学习前端的一些东西 转载于http://www.cnblogs.com/lei2007/archive/2013/08/16/3262897.html 雅虎的css前端的35条定律
- Git之不明觉厉11-利其器source tree
前面10篇文章都在用命令行,虽然装逼不错,但是我想说一句,平时我也是用source tree比较多点,命令行一般都是在source tree的图形按钮找不到在哪里,就直接用命令行.对于初次用git的同 ...
- RegisterClientScriptBlock CommandName 模块列 操作完成 提示
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Remind", "alert('获取成功!') ...
- 获取局域网ip
显然不可使用基于request请求的request.getRemoteAddr()这个是获取广域网内的服务器地址,比如我请求百度使用这个方法就可以获取到百度的服务器地址 那么InetAddress的I ...
- Xcode 合并分支报错
原理和操作步骤见如下转载的两篇文章, 我所使用的 svn 客户端软件是 Mac 下面的 Versions.app v1.06 这个版本包含一个多人开发的bug bug 的解决方案见我之前转载的两篇文章 ...
- Mac下安装Redis图解教程
去redis官网(http://redis.io/download)自行下载安装包解压缩到本地文件夹,比如放在Mac应用程序文件夹(/Applications/),在终端进入redis文件夹. 需要进 ...
- 3111: [Zjoi2013]蚂蚁寻路 - BZOJ
题目描述 Description在一个 n*m 的棋盘上,每个格子有一个权值,初始时,在某个格子的顶点处一只面朝北的蚂蚁,我们只知道它的行走路线是如何转弯,却不知道每次转弯前走了多长.蚂蚁转弯是有一定 ...
- linux复制多个文件到文件夹
linux复制多个文件到文件夹 cp file1 file2 file3 directory即将文件file1 file2 file3复制到directory
- having——至少被订购过两回的订单
此篇介绍having的用法 一.表:订单表,产品表 说明:订单表order ,包含prodectid 二.查询至少被订购过两回的订单 800x600 Normal 0 7.8 磅 0 2 false ...