日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

wgrib读grib数据

發布時間:2025/6/17 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 wgrib读grib数据 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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);

posted on 2018-10-19 09:40 秦瑞It行程實錄 閱讀(...) 評論(...) 編輯 收藏

轉載于:https://www.cnblogs.com/ruiy/p/9814679.html

總結

以上是生活随笔為你收集整理的wgrib读grib数据的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。