grib2arl命令使用方法
grib2arl命令使用方法
grib2arl是HYSPLIT提供的一个将GRIB文件转换成ARL文件的命令行工具。
使用时注意以下三点
- 选项和参数之间不要有空格
- 提供的grib文件中的变量应当按时间顺序保存,相同时刻的变量放在一块。
- 如果生成的ARL文件无法使用,考虑需要将气象场按类别分成3个不同的文件,分别储存3维变量,2维变量,和静态场(见附录一)
因为从EC下载的GRIB文件的变量不是严格按时间顺序保存的,需要将变量重新按时间顺序保存。
下面介绍用grib_filter和cat命令对变量按时间顺序保存的大致步骤:
- 创建文件rule_file,这个文件说明了变量的筛选规则。在这个文件写入如下内容。
write "./var/era5.[dataDate].[dataTime].grib";
上面一行的意思是,对GRIB变量按照日期(dataDate)和时间(dataTime)进行保存,文件保存到当前路径下的var文件夹下。 - 在当前路径下建立var文件夹,用于存放分割后的变量。
- 调用grib_filter命令,将原始文件按日期和时刻进行分割:
grib_filter rule_file src.grib
- 使用cat命令将分割得到的变量按照时间顺序进行合并,相同时间的文件放在一块:
显式使用:
cat era5.20170516.0000.grib era5.20170516.0100.grib era5.20170516.0200.grib >3dcn.grib
或用sort命令先排序后合并:
ls *.grib|sort -n |xargs -i cat {} > 3dcn.grib
得到了按时间排序的GRIB变量之后,执行grib2arl命令,生成arl文件
./grib2arl -i3dcn.grib -y35 -x105 -p0 -k37 -s2dcn.grib -cz.grib -p0
需要注意的是,选项和参数之间没有空格。
-i3dcn.grib表示输入文件名为3dcn.grib的GRIB文件
-y35 表示资料的中心纬度为35°
-x105表示资料的中心经度为105°
-p0 表示资料是气压层数据
-k37 表示资料垂直层次37层
-s2dcn.grib 表示补充文件名为2dcn.grib
-c表示静态数据文件名为z.grib
注:该命令运行时,会将运行信息写到MESSAGE文件中。如运行时出现错误,可查看MESSAGE文件寻找出错可能的原因。
附录
一. 示例代码 https://hysplitbbs.arl.noaa.gov/viewtopic.php?t=135
Post by ariel.stein » July 8th, 2013, 11:08 am
In order to convert the ERA interim data to ARL format you need to download the following meteorological fields from the ECMWF web site in 3 different files:
3-D fields: Pressure fields: Geopotential, Relative humidity, Temperature, U velocity, V velocity, and Vertical velocity
2-D fields: Surface: 2 m T, 10 m U, and 10 m V
Invariant: Geopotential
Rain fields are not mandatory unless you are dealing with an application that uses wet deposition.
If for some reason it does not work try the following line of command:
../exec/grib2arl -i3d.grib -y60 -x80 -g3 -p0 -k25 -s2d.grib -cinvariant.grib
where 3d.grib corresponds to the 3-D fields, 2d.grib is the 2-D fields file, and invariant.grib is the invariant file.
二. grib2arl 选项
GRIB1 file processing with data on a regular latitude-longitude grid
Usage: grib2arl [-options]
-i[primary grib data: file name {required}]
-s[supplemental grib data: file name {optional}]
-c[constant grib data: file name {optional}]
-x[subgrid extract center longitude {-80.0}]
-y[subgrid extract center latitude {60.0}]
-g[output projection 0 :conformal extract
1 :fixed northern hemisphere polar
2 :fixed southern hemisphere polar
{3}:lat-lon global grid (as input)
4 :lat-lon extract grid
-n[number of (x:y) extract grid points {100}]
-k[number of output levels including sfc {16}]
-p[surface defined by {1}:pressure or 0:terrain height]
-q[analyze grib file {0} or use saved configuration: 1]
-r[rain fall accumulation time hours: {6}]
-t[the number of time periods to process: {744}]
-z[zero initialization of output file 0:no {1}:yes]
Note-1: for some Linux systems {export MALLOC_CHECK_=0}