abbrev is the abbreviation for the variable as
specified in the
data descriptor file
file# is the file number that contains
this variable. If
file# is absent, grads assumes the default file number.
dimexpr is a dimension expression that locally
modifies the current dimension environment.
dimexpr is used to override or modify the current dimension environment only for the
abbrev variable. Only fixed dimensions can be
modified with a
dimexpr can be given in grid or world coordinates. An important note: When you specify a dimension in grid units,
grads always converts it to world coordinates. In general, this conversion
is done using the scaling of the default file. The only exception to this rule is in this case, when a
grid coordinate (x, y, z, t, or e) is supplied within a
dimexpr as part of a variable specification. In the case of this special exception, the conversion is done using the scaling for
the file that variable is to be taken from (i.e., file number
dimexpr uses the "=" operator to override the currently set dimension value:
x|y|z|t|e|lon|lat|lev|time|ens = value
x=1, lat=-10, lev=500, t=1, time=02feb1982, e=1, ens=spr
dimexpr uses the "+" or "-" operators to modify the currently set dimension value with an offset:
x|y|z|t|e|lon|lat|lev|time|ens +/- offset
x+1, lat+30, y-3, t+0, time+12hr
dimexpr that specifies an offset
from the variable's initial time:
offt =/+/- offset
offt=0, offt+4, offt-1
offt dimension override for additional information.
'set t 2'; 'd ps'
'set t 1'; 'd ps(t+1)'
'set t 1'; 'd ps(t=2)'
'set t 1'; 'd ps(offt=1)'
'set t 1'; 'd ps(offt+0)'
dimexpr that contains
offt is especially handy when your data set has multiple ensemble members, and the start time for individual members is not the same. In that case, an expression like:
'set t 1'; 'set e 1 last'; 'd ps(offt=0)'
Examples of complete variable specifications are:
File 3, absolute dimension
tv.1(time-12hr) Relative dimension expression
Default file number is used
q.2(t-1,lev=850) Two dimension expressions
This does have uses....
grads has a few "predefined" variable names. You can think of these as being variables implicitly contained within any opened gridded file. The variable names are:
When used, they will contain the
lev at the
respective grid points, using the scaling of the appropriate
file. You can specify:
lat.2 for example, to get latitudes on
the grid of the 2nd opened data set.
allows you to interactively create a new variable. The syntax is:
define varname = expression
The new variable can then be used in subsequent
display commands. The new
variable is stored in memory, not on disk, so avoid defining variables
over large dimension ranges.
Defined variables cover the dimension ranges in effect
at the time the command is issued. You may define a variable that
has from 0 to 4 varying dimensions. The
define command is the
only case within GrADS where four varying dimensions is valid.
T are varying dimensions, the
evaluates the expression by stepping through
In other words, the expression is evaluated within a dimension environment
that has fixed
T. This will affect how you
compose the expression.
When you use a defined variable, data is taken from the variable in a way similar to data taken from a GrADS data file. For example, say you define a four dimensional variable:
set lat 0 90
set lev 1000 100
set t 1 10
define temp = rh
After issuing the
define command, remember to change the dimension environment so less than 4
dimensions are varying!
set lev 500
The display of the defined variable will display a 2-D slice taken at time 5 and level 500.
If you define a variable that has fixed dimensions, and then later access this variable, the fixed dimensions are treated as "wild cards". The best way to show this is with an example:
set lat 0 90
set lev 500
set t 10
define zave = ave(z,t=1,t=30)
The defined variable has two varying dimensions. If we now
display this variable (or use it in an expression), the fixed
dimensions of the defined variable, namely
T dimension setting:
set lev 200
In the above display, the variable
zave would be displayed as it
was defined, ie you would get a time average of 500mb heights,
even though the level is set to 850.
When the defined variable has varying dimensions, and you have a dimension environment where that dimension is fixed, the proper dimension will be retrieved from the variable:
set lat 0 90
set lev 500
set t 10
define temp = z
set lat 40
In the above example, the defined variable has a varying Y dimension. We then fix the Y dimension to be 40N, and display a 1-D slice. The data from 40N in the defined grid will be accessed. If you then did:
The data from 40S would be accessed from the defined variable. Since this is beyond the dimensions originally used when the variable was defined, the data would be set to missing.
You can also locally override the dimension environment:
If that dimension is a varying dimension within the defined variable. If the dimension is a fixed dimension for that variable, the local override will be ignored:
In the above command, the defined variable temp has fixed T, so the t=15 would be ignored.
define command currently supports only grids.
Once you have defined a grid variables, you may tell GrADS that the new variable is climatological, ie that you wish to treat the time dimension of the new variable in a wild card sense.
The command is:
modify varname <seasonal/diurnal>
varname is the name of a defined variable. If the
grid is described as
seasonal, then it is assumed that
the defined variable contains monthly (or multi month) means. Daily or
multi-day means are not yet supported. If
specified, it is assumed the defined variable contains means over some
time period less than a day.
After describing the defined variable as climatological, then the date/times are treated appropriately when data is accessed from the defined variable.
In the following example, the data set contains 10 years of monthly means:
set lat -90 90
set lev 500
set t 1 12
define zave = ave(z,t+0,t=120,1yr)
This define will set up a variable called
contains 12 times, each time being the 10 year mean for that month. We
are making use here of the fact that the define command loops through
a varying time dimension when evaluating the expression, and within
ave function we are
making use of the variable time offset of t+0, which uses a start time
that is whatever time the
define command is using as
set t 120
d z - zave
The final display will remove the 10 year monthly mean for December from the last December in the data set.
Each variable defined using the
define command reserves
some system resources. If you no longer need a defined variable it is
sensible to free these resources for other use. This is accomplished
undefine command. For example:
would free the resources used by the defined variable
course, the variable
p would no longer be available for GrADS