GrADS命令大全模板
- 格式:doc
- 大小:244.00 KB
- 文档页数:15
【grads】ncdump的使⽤总结1、参数ncdumpncdump [-c] [-h] [-v var1,...] [-b lang] [-f lang] [-l len] [-n name] [-d f_digits[,d_digits]] fileWhere:-cShow the values of coordinate variables (variables that are also dimensions) as well as the declarations of all dimensions, variables, and attribute values. Data values of non-coordinate variables are not included in the output. This is the most suitable option to use for a brief look at the structure and contents of a netCDF file.-hShow only the header information in the output, that is the declarations of dimensions, variables, and attributes but no data values for any variables. The output is identical to using the -c option except that the values of coordinate variables are not included. (At most one of -c or -h options may be present.)-v var1,...,varnThe output will include data values for the specified variables, in addition to the declarations of all dimensions, variables, and attributes. One or more variables must be specified by name in the comma-delimited list following this option. The list must be a single argument to the command, hence cannot contain blanks or other white space characters. The named variables must be valid netCDF variables in the input-file. The default, without this option and in the absence of the -c or -h options, is to include data values for all variables in the output.-b langA brief annotation in the form of a CDL comment (text beginning with the characters ``//'') will be included in the data section of the output for each `row' of data, to help identify data values for multidimensional variables. If lang begins with C or c, then C language conventions will be used (zero-based indices, last dimension varying fastest). If lang begins with F or f, then Fortran language conventions will be used (one-based indices, first dimension varying fastest). In either case, the data will be presented in the same order; only the annotations will differ. This option is useful for browsing through large volumes of multidimensional data.-f langFull annotations in the form of trailing CDL comments (text beginning with the characters ``//'') for every data value (except individual characters in character arrays) will be included in the data section. If lang begins with C or c, then C language conventions will be used (zero-based indices, last dimension varying fastest). If lang begins with F or f, then Fortran language conventions will be used (one-based indices, first dimension varying fastest). In either case, the data will be presented in the same order; only the annotations will differ. This option may be useful for piping data into other filters, since each data value appears on a separate line, fully identified.-l lenChanges the default maximum line length (80) used in formatting lists of non-character data values.-n nameCDL requires a name for a netCDF data set, for use by ncgen -b in generating a default netCDF file name. By default, ncdump constructs this name from the last component of the pathname of the input netCDF file by stripping off any extension it has. Use the -n option to specify a different name. Although the output file name used by ncgen -b can be specified, it may be wise to have ncdump change the default name to avoid inadvertantly overwriting a valuable netCDF file when using ncdump, editing the resulting CDL file, and using ncgen -b to generate a new netCDF file from the edited CDL file.-d float_digits[,double_digits]Specifies default number of significant digits to use in displaying floating-point or double precision data values for variables that don't have a `C_format' attribute. Floating-point data will be displayed with float_digits significant digits. If double_digits is also specified, double-precision values will be displayed with that many significant digits. If a variable has a `C_format' attribute, that overrides any specified floating-point default. In the absence of any -d specifications, floating-point and double-precision data are displayed with 7 and 15 significant digits respectively. CDL files can be made smaller if less precision is required. If both floating-point and double-presision precisions are specified, the two values must appear separated by a comma (no blanks) as a single argument to the command. If you really want every last bit of precision from the netCDF file represented in the CDL file for all possible floating- point values, you will have to specify this with -d 9,17.Usage Notesncdump generates an ASCII representation of a specified netCDF file on standard output. The ASCII representation is in a form called CDL (``network Common Data form Language'') that can be viewed, edited, or serve as input to ncgen. ncgen is a companion program that can generate a binary netCDF file from a CDL file. Hence ncgen and ncdump can be used as inverses to transform the data representation between binary and ASCII representations. See ncgen for a description of CDL and netCDF representations.ncdump defines a default format used for each type of netCDF data, but this can be changed if a `C_format' attribute is defined for a netCDF variable. In this case, ncdump will use the `C_format' attribute to format each value. For example, if floating-point data for the netCDF variable Z is known to be accurate to only three significant digits, it would be appropriate touse the variable attributeZ:C_format = "%.3g"ncdump may also be used as a simple browser for netCDF data files, to display the dimension names and sizes; variable names, types, and shapes; attribute names and values; and optionally, the values of data for all variables or selected variables in a netCDF file.ExamplesLook at the structure of the data in the netCDF file foo.nc:ncdump -c foo.ncProduce an annotated CDL version of the structure and data in the netCDF file foo.nc, using C-style indexing for the annotations:ncdump -b c foo.nc > foo.cdlOutput data for only the variables uwind and vwind from the netCDF file foo.nc, and show the floating-point data with only three significant digits of precision:ncdump -v uwind,vwind -d 3 foo.ncProduce a fully-annotated (one data value per line) listing of the data for the variable omega, using Fortran conventions for indices, and changing the netCDF dataset name in the resulting CDL file to omega:ncdump -v omega -f fortran -n omega foo.nc > Z.cdl2、注意①它是在dos底下⽤的,如果在gradsnc中⽤,请在命令前加感叹号。
第一个命令:这样将得到一个动画显示的序列,现在输入:claerset lon -90set lat -90 90set lev 1000 100set t 1d td u该情况下我们设置y(纬度)和z(高度)变化,所以我们得到一个竖直切面图。
我们显示了两个变量,他们重叠在一起。
你可以让任意多的变量重叠在一起,只要你不使用clear命令就行了。
另一个例子,这种情况X和T是变化的(哈莫图):cset lon -180 0set lat 40set lev 500set t 1 5d z现在已经知道怎样使用选定的部分数据绘图了,下面我们学习怎样操作数据。
设置维数环境为Z,Y变化:clearset lon -180 0set lat 0 90set lev 500set t 1现在假设我们想显示华氏温度代替开尔文温度。
可以这样转换:display (t-273.16)*9/5 32任何由标准的运算符,-,* 和/ 组成的表达式都是允许的,并且操作数可以包含常量,变量,或者函数。
一个包含函数的例子:d sqrt(u*u v*v)有一个函数用来计算风的级数。
d mag(u,v)另一个内建函数计算平均值:clear d ave(a,t=1,t=5)这种情况我们可以计算5天的平均。
我们也可以从数据中移除平均值(距平值):d z-ave(z,t=1,t=5)也可以在x方向作平均并求距平:cleard z-ave(z,x=1,x=72)也可以做时间差分:cleard z(t=2)-z(t=1)完整规范的变量名是:name.file(dim |-|=va lue,…) 如果我们打开了两个文件,也许一个是模式输出,另一个是分析,我们应该区分用如下方法二者:display z.2-z.1另一个内置的函数通过有线差分计算水平涡度相关cleard hcurl(u,v)还有另外一个计算数值方向的质量积分:cleard vint(ps,q,275)这儿我们计算了可降水量(单位mm)现在来讨论控制图形输出的话题。
grads基本命令d ave(olr,t+0,t+359,12) ave表示求平均,olr 为变量, t+0表示起始点为当前时次,即00z01jul1974;t+359表示终止时次为当前时次后推359个时次,即00z01jul2003;12表示每12个时次取一次数据;打开nc文件:ga->sdfopen查询信息:ga->q filega->q dimga->q ctlinfo写标题:ga-> draw title清除图面:ga-> c同时打开两个文件: ga->open model.ctlga->open model.le.ctl删除所有设置重新回到刚进入GrADS状态:ga->reinit删除open命令后的所有设置:ga->reset由风场导出涡度场:ga->d hcurl(u,v)以分色图形方式输出:ga->set gxout shaded以等值线方式输出(缺省方式):ga->set gxout contour画图例:ga->cbarn 1 0 (1:相对长短,>1放大;0:水平;1:垂直。
)以箭头方式表示矢量场: ga->gxout vector风矢量场:ga->d u; v; q (显示矢量时,d x分量;y分量<;标量>。
“<>”内的部分只起标颜色的作用。
)以流线方式表示矢量场:ga->set gxout stream风流线场:ga->d u; v; q以WMO风标方式表示矢量场: ga->set gxout barb风标:ga->d u; v; q直接输出网格点数值:ga->set gxout grid设置保留小数位数:ga->set dignum 0设置数字大小:ga->set digsize 0.1ga->set mpdraw on 如为off,不画地图背景(非经纬度数据需此项)ga->set poli on 如为off不画国界省界等。
d ave(olr,t+0,t+359,12) ave表示求平均,olr 为变量, t+0表示起始点为当前时次,即00z01jul1974;t+359表示终止时次为当前时次后推359个时次,即00z01jul2003;12表示每12个时次取一次数据;打开nc文件:ga->sdfopen查询信息:ga->q filega->q dimga->q ctlinfo写标题:ga-> draw title清除图面:ga-> c同时打开两个文件: ga->open model.ctlga->open model.le.ctl删除所有设置重新回到刚进入GrADS状态:ga->reinit删除open命令后的所有设置:ga->reset由风场导出涡度场:ga->d hcurl(u,v)以分色图形方式输出:ga->set gxout shaded以等值线方式输出(缺省方式):ga->set gxout contour画图例:ga->cbarn 1 0 (1:相对长短,>1放大;0:水平;1:垂直。
)以箭头方式表示矢量场: ga->gxout vector风矢量场:ga->d u; v; q (显示矢量时,d x分量;y分量<;标量>。
“<>”内的部分只起标颜色的作用。
)以流线方式表示矢量场:ga->set gxout stream风流线场:ga->d u; v; q以WMO风标方式表示矢量场: ga->set gxout barb风标:ga->d u; v; q直接输出网格点数值:ga->set gxout grid设置保留小数位数:ga->set dignum 0设置数字大小:ga->set digsize 0.1ga->set mpdraw on 如为off,不画地图背景(非经纬度数据需此项)ga->set poli on 如为off不画国界省界等。
目录前言 (5)第一章启动GrADS 及打开文件 (5)一.启动GrADS (5)二.打开文件 (6)第二章维数环境 (6)set lat|lon|lev|time val1<val2> (6)set x|y|z|t vall <val2 > (6)第三章显示命令及动画 (7)一、显示命令 (7)二、动画 (7)set loopdim x︱y|z|t (7)set looping on|off (7)第四章图形输出类型 (8)对格点数据: (8)bar: 直方图 (8)barb:风向杆形式绘二维风场 (8)contour:二维等值现图 (8)errbar:单线图及误差分布 (8)frgid:用指定颜色填充二维格点场 (8)fwrite:图形不在屏幕上显示,而是将输出结果存入一个由“set fwrite 文件名”所指定的文件中。
(8)gid:以网格形式在各网点中央标出该点数值 (8)line:单线图 (8)linefill:两单曲线之间填色 (8)scatter:散点图 (8)shaded:二维填色图 (8)stat:输出有关的统计量 (8)stream:流线形式绘二维风场 (8)vector:向量间箭头形式绘二维风场 (8)对站点数据: (8)barb:在各站点绘风向标 (8)findstn:搜索最近的站点(详见描述语言部分) (8)model:以天气图形式将天气观测各分量填放在站点四周 (8)value:在各站点标值 (8)wxsym:绘wx天气符号 (8)Draw wxsym symbol x y size<color<thicks>> (9)对于model,命令为set gxout model ,然后再添图,形式为displayu;v;t;d;slp;delta;cld;wx;vis (9)第五章 GrADS资料格式 (9)格点资料资料描述文件 (9)以下是一个资料描述文件的例子: (9)1、DSET data-set-name (11)2、TITLE string (11)3、UNDEF value (11)4、OPTIONS <keywords> (12)5、XDEF number<LINEAR start increment>或XDEF number<LEVELS value-list> (12)6、YDEF number mapping start<increment>或YDEF number<LEVELS value-list> (13)7、ZDEF number mapping <start increment>或ZDEF number<value-list> (13)8、TDEF number LINEAR start-time increment (14)9、VARS number (14)二. 台站资料资料描述文件 (15)第六章变量名和表达式 (15)一、变量名和表达式 (15)二、表达式 (16)第七章函数 (16)一. aave函数 (16)二.abs函数 (16)三.acos函数 (17)四、asin函数 (17)五、atan2函数 (17)六、ave函数 (17)七、cdiff函数 (17)八、const函数 (18)九、cos函数 (18)十、exp函数 (18)十一、gr2stn函数 (19)十二、hcurl函数 (19)十三、hdivg函数 (19)十四、log函数 (19)十五、log10函数 (19)十六、mag函数 (19)十七、maskout函数 (20)十八、oacres函数 (20)十九、pow函数 (20)二十、sin函数 (20)二十一、skip函数 (20)二十二、smth9函数 (21)二十三、sqrt函数 (21)二十四、stnave函数 (21)二十五、stnmin函数 (21)二十六、stnmax函数 (21)二十七、tan函数 (22)二十八、tloop函数 (22)二十九、tvrh2q函数 (22)三十、tvrh2t函数 (22)三十一、vint函数 (23)第八章图形要素设置 (23)对于图形类型为contour起作用的设置 (23)set ccolor color——设置等值线颜色 (23)set ccolor rainbow——设定等值线颜色用彩虹表示 (23)set cstyle style——设定等值线线型 (23)Set cthick thckns——设定等值线线宽hckns(取值范围1~20) (23)Set cterp on|off——设置样条差值光滑开关 (23)Set clab on|off|forced|string|auto——控制等值线的标记方式。
GrADS绘图软件安装于入门目录第一章GrADS绘图软件概述1.GrADS绘图软件简介2.GrADS绘图软件的安装〔windows环境〕3.1在windows环境下安装GrADS软件包第二章GrADS绘图模板1.GrADS例如演示1.1 启动GrADS1.2 退出GrADS1.3 例如演示GrADS命令的使用第二章GrADS绘图软件概述1GrADS绘图软件简介The Grid Analysis and Display System(GrADS) 是一套应用广泛、使用方便的科学数据绘图软件包。
其主要特点:●GrADS属于自由软件,可以从Internet上免费获得。
●可运行于各种Windows 和Unix工作平台。
●GrADS可用于4D数据的分析。
既经度、纬度、层〔气压层、高度层等〕和时间/xyzt 4维。
数据可以是格点化的数据或离散点数据。
GrADS特别适用于气象类数据的分析。
但也完全可以用于更广泛类型的数据分析。
●GrADS有多种显示方式:等值线、流线、矢量图、风矢量图、站点填图、折线图、直方图等多种两维图形。
●可处理多种数据格式的数据。
GRIB、NetCDF、HDF-SDS等通用数据格式和系统自定义的一种二进制数据格式。
●采用命令行输入的方式交互式地显示图形。
并有多种命令对数据进展再加工。
如求平均;计算涡度、散度、垂直积分、计算差分等。
●图形可以按多种格式存储:ps、png、jpg、tiff、gif、windows metafile等。
自身以metafile格式存储。
●提供多种辅助工具软件。
如看图、打印、图形格式转换〔gv〕等工具。
2Internet上的GrADS资源2.1 GrADS在Internet上的主页GrADS主页地址:/grads从GrADS主页上可以找到预编译好了的适合于windows环境下的GrADS软件包,2.2 windows环境下GrADS资源●grads-2.0.a7.oga.3-win32_superpack.exe——GrADS软件包安装执行程序。
第一个命令:这样将得到一个动画显示的序列,现在输入:claerset lon -90set lat -90 90set lev 1000 100set t 1d td u该情况下我们设置y(纬度)和z(高度)变化,所以我们得到一个竖直切面图。
我们显示了两个变量,他们重叠在一起。
你可以让任意多的变量重叠在一起,只要你不使用clear命令就行了。
另一个例子,这种情况X和T是变化的(哈莫图):cset lon -180 0set lat 40set lev 500set t 1 5d z现在已经知道怎样使用选定的部分数据绘图了,下面我们学习怎样操作数据。
设置维数环境为Z,Y变化:clearset lon -180 0set lat 0 90set lev 500set t 1现在假设我们想显示华氏温度代替开尔文温度。
可以这样转换:display (t-273.16)*9/5 32任何由标准的运算符,-,* 和/ 组成的表达式都是允许的,并且操作数可以包含常量,变量,或者函数。
一个包含函数的例子:d sqrt(u*u v*v)有一个函数用来计算风的级数。
d mag(u,v)另一个内建函数计算平均值:clear d ave(a,t=1,t=5)这种情况我们可以计算5天的平均。
我们也可以从数据中移除平均值(距平值):d z-ave(z,t=1,t=5)也可以在x方向作平均并求距平:cleard z-ave(z,x=1,x=72)也可以做时间差分:cleard z(t=2)-z(t=1)完整规范的变量名是:name.file(dim |-|=va lue,…) 如果我们打开了两个文件,也许一个是模式输出,另一个是分析,我们应该区分用如下方法二者:display z.2-z.1另一个内置的函数通过有线差分计算水平涡度相关cleard hcurl(u,v)还有另外一个计算数值方向的质量积分:cleard vint(ps,q,275)这儿我们计算了可降水量(单位mm)现在来讨论控制图形输出的话题。
1.ctl文件的编写dset d:\test\test1.dat 数据文件路径名和文件名title monthly precipitation data 数据标题options 365_day_calendar 特殊格式说明365_day_calendar/template(多个文件) undef -9999.0 缺测值,若有多个则用fortran改写成同一个缺测值xdef 144 linear 0 2.5 x维数格点数/排列方式/起始值/间隔*linear线性/levels列举ydef 73 linear -90 2.5 y维数zdef 5 linear 1000 850 700 500 200 z维数tdef 24 linear 00z01Jan1979 1mo 时间维数*mo月yr年vars 1 变量数precip 1 99 *precipitation data 变量名/层数/排列顺序/说明endvars*变量循环顺序:x经度y维度z高度v变量t时间*注释行第一列用‘*’,注释行不能出现在变量列表中2.维数环境设置set lon/lat/lev/time var1 <var2> *实际值set x/y/z/t var1 <var2> *格点数值*两种坐标可以混用3.图形文件的保存gxprint/printim **.png/jpg/pdf/eps…. whiteenable print **.gmfprintdisableprint4.图形类型的设置set gxout typecontour 二位等值线图*默认shaded 二维填色等值线图vector 矢量箭头二维风场图*d u;v时为默认bar 直方图line 折线图*默认…………………5.图形要素设置gxout=contour or shadedset cint value 设置等值线间隔set clevs lev1,lev2,……设置特定等值线set ccols col1,col2,……设置对应于set clevs的等值线的颜色cbarn size 0/1 x y 设置色标gxout=line or contourset ccolor color 设置线条颜色set cstyle style设置线条样式1实线2长虚线3短虚线……set cthick thickns 设置线条粗细1~10set cmark marker 设置数据点标记0无标记*line时有效gxout=barset bargap val 设置直方条间隔*0~100百分比,0为无间隔set barbase val/bottom/top 设置直方条起始值gxout=vectorset arrscl size <magnitude> 设置箭头长度set arrowhead size 设置箭头大小,缺省为0.056.gs文件的编写将命令用单引号括起来7.变量define varname=expression 定义变量‘d air(t=3)’‘d air(t=3,z=5)’‘d air(lev=1000)-air(lev=500)’设置变量维数8.平均函数ave(expr,dimexpr1,dimexpr2,<timeint>) 一维平均aave(expr,dimexpr1,dimexpr2, dimexpr3,dimexpr4,) 二维平均*不能对z、t *需将维度设置成点9.地图投影设置set mproj proj 设置地图投影方式latlon 缺省nps 北半球极地投影sps 南半球极地投影set map color style thickness 设置背景地图线条颜色、线型、宽度10.绘图区域设置set parea xmin xmax ymin ymax11.坐标要素控制set frame on/off/circle 绘制图形边框/不绘制/绘制圆形边框set grads on/off 标记grads及绘图时间draw title <string> 绘制标题draw xlab/ylab <string> 绘制x轴/y轴图注set xyrev on/off xy轴互换set zlog on/off z方向用对数坐标set xlint/ylint value 设置x/y轴坐标刻度间隔set vrange val1 val2 设置y轴范围set vrange2 val1 val2 设置x轴范围set xlopts/ylopts color thickness size x/y轴刻度值的颜色、线宽、大小*缺省1,4,0.12 set tlsupp year 去掉年份显示12.颜色的定义‘define_colors’使用内部默认颜色标号13.基本绘图命令set line color style thickness 设置颜色、线型、线宽draw line x1 y1 x2 y2 绘制直线draw rec/recf x1 y1 x2 y2 绘制不填色/填色矩形draw mark type x y size 绘制标记*1叉2空心圆3实心圆4空心方框5实心方框draw string x y string 绘制字符串set strsiz hsiz <vsiz> 设置字符大小14.文件操作(1)输出二进制变量设置维数环境‘set gxout fwrite’‘set fwrite ***.dat’‘d var’(2)读写有格式文件result=read(filename)result 第一行:返回码(0 OK,1打开错误2文件结束8文件状态为写入9I/O错误)result 第二行:读取的文件内容Text = sublin(result,2) 将result相应行的内容赋值给Textaa=subwrd(Text,#n) 将Text的第n个值赋值给aaresult=write(filename, text, <append>)15.维数查询q w2xy lon lat 将经纬度坐标转换为图形窗口坐标返回值:X=*** Y=*** q xy2w X Y 将图形窗口坐标转为经纬度坐标返回值:Lon=*** Lat=***q w2gr lon lat 将经纬度坐标转换为格点坐标返回值:Xdim=*** Ydim=***q gr2w xdim ydim 将格点坐标转换为经纬度坐标返回值:Lon=*** Lat=***q xy2gr X Y 将图形窗口坐标转换为格点坐标返回值:Xdim=*** Ydim=***q gr2xy xdim ydim 将格点坐标转换为经纬度坐标返回值:X=*** Y=***16.气候平均设置季节变量‘set t 1 12’‘define climate=ave(var,t+0,t=tmax,12)’‘modify climate seasonal’滑动平均‘set t 1 tmax’‘define running_mean=ave(var,t-n,t+n)’17.站点资料绘图(1)转换生成数据文件及格点文件数据文件的顺序为先循环站号再循环时间,每条记录包含站号-纬度-经度-时间-nlev-flag-数据,每循环完一个时间后要加一个不写数据且nlev=0的记录(2)编写ctldtype stationstnmap ***.map**变量层数为0(3)生成.map映射文件!stnmap –i */*/*.ctl(4)插值‘open ***\grid.ctl’‘open ***dat.ctl’‘define varname=oacres(grid,var.2)’(5)绘图‘cnbasemap varname’18.绘制路径图。
GrADS 精致绘图说(一)1. basemap.gs:basemap L | O | U <fill_color> <out_color> <hi/lo>在低分辨率海岸廓线范围内用颜色覆盖陆地/海洋。
适用于各种投影方式,需lpoly.asc, lpoly_hires.asc, lpoly_US.asc, opoly.asc, opoly_hires.asc文件。
其中:L(l):覆盖陆地,O(o):覆盖海洋,U(u):覆盖20N-50N的墨西哥和加拿大领土(低分辨率,适用美国),fill_color:填充色号,缺省为15,out_color:廓线的颜色号,缺省为15,hi/lo:高分辨率('set mpdset hires',仅对15N-53N, 130W-60W区域)/低分辨率。
2. cbar.gs、cbarn.gs、cbarc.gs、cbar_l.gs和cbar_line.gs:cbarn sf vert xmid ymidcbarc center_x center_y back_color绘制'set gxout shaded'图形的填色标尺。
sf:色标尺寸,1为全尺寸,0.5为半尺寸;vert:0为水平,1为垂直;xmid,ymid:色标中心点的位置。
cbar_l -x X -y Y -n number -t text -pcbar_line -x X -y Y -c color -m mark -l linestyle -t text -p加'set gxout line'的图例说明。
其中:-x,-y:图中x和y的位置,-n:线条的数目(最多可为10条),-t:文字说明的内容(最多10条,需双引号括起),-c:线和标记的颜色,-m:定义标记;-l:定义线型,-p:用户可在图中点击给定图例的放置位置。
3. colors.gs:为雪盖(颜色序号40~45)、降水(颜色序号50~59)及温度(颜色序号64~85)资料的shaded图设置填充色。