(Tutorial (En Español
What is it?
Download the sample data
tar xvfz example.tar.gz
model.ctl(A grads descriptor file)
model.dat(A grads binary data file)
tutorial(A text file containing the contents of this tutorial)
This example data set is a a binary data file containing sample model output (model.dat) and data descriptor file (model.ctl), a text file that contains the necessary metadata that grads needs. The data descriptor file describes the structure of the data file, which in the case contains 5 days of global grids that are 72 x 46 elements in size. The text of the sample session below is also included for your convenience.
To start up GrADS, enter:
If the grads executable is not in your current directory, or if it is not in your PATH somewhere, you may need to enter the full pathname, ie:
GrADS will prompt you with a landscape vs. portrait question; just press enter. At this point a graphics output window should open on your console. You may wish to move or resiae this window. Keep in mind that you will be entering GrADS commands from the window where you first started GrADS -- this window will need to be made the 'active' window and you will not want to entirely cover that window with the graphics output window.
In the text window (where you started grads from), you should now
see a prompt:
ga-> You will enter GrADS commands at this
prompt and see the results displayed in the graphics output
The first command you will enter is:
You may want to see what is in this file, so enter:
One of the available variable is called
ps, for surface pressure.
We can display this variable by entering:
d is short for
will note that by default, GrADS
will display a lat/lon plot at the first time and at the lowest
level in the data set.
dimension environment. The
displaycommand (and implicitly, the access, operation, and output of the data) will do things with respect to the current dimension environment. You control the dimension environment with the
clearclears the display
set lon -90sets longitude to 90 degrees West
set lat 40sets latitude to 40 degrees North
set lev 500sets level to 500 mb
set t 1sets time to first time step
d hgtdisplays the variable called 'hgt'
GrADS will not draw anything to the display window, but instead prints out "Result value = 5447.17" to the command window.
In the above sequence of commands, we have set all four GrADS dimensions to a single value. When we set a dimension to a single value, we say that dimension is "fixed". Since all the dimensions are fixed, when we display a variable we get a single value, in this case the value of 'hgt' at the location 90W, 40N, 500mb, at the 1st time in the data set.
If we now enter:
set lon -180 0X is now a varying dimension
We have set the X dimension, or longitude, to vary. We have done this by entering two values on the set command. We now have one varying dimension (the other dimensions are still fixed), and when we display a variable we get a line graph, in this case a graph of 500mb Heights at 40N.
set lat 0 90d hgt
We now have two varying dimensions, so by default we get a contour plot. If we have 3 varying dimensions:
set t 1 5d hgt
we get an animation sequence, in this case through time. For some modern computers, the display of all 5 time steps may be so fast that the animation may not be evident.
set lon -90set lat -90 90set lev 1000 100set t 1d taird u
In this case we have set the Y (latitude) and Z (level)
dimensions to vary, so we get a vertical cross section. We have
also displayed two variables, which simply overlay each other.
You may display as many items as you desire overlaid before you
set lon -180 0set lat 40set lev 500set t 1 5d hgt
set lon -180 0set lat 0 90set lev 500set t 1
Now say that we want to see the temperature in Fahrenheit instead of Kelvin. We can do the conversion by entering:
Any expression may be entered that involves the standard operators of +, -, *, and /, and which involves operands which may be constants, variables, or functions. An example involving functions:
to calculate the magnitude of the wind. A function is provided to do this calculation directly:
In this case we calculate the 5 day mean. We can also remove the mean from the current field:
d hgt - ave(hgt,t=1,t=5)
We can also take means over longitude to remove the zonal mean:
d hgt-ave(hgt,x=1,x=72)d hgt
We can also perform time differencing:
d hgt(t=2) - hgt(t=1)
This computes the change between the two fields over 1 day. We could have also done this calculation using an offset from the current time:
d hgt(t+1) - hgt
The complete specification of a variable name is:
name.file(dim +|-|= value, ...)
If we had two files open, perhaps one with model output, the other with analyses, we could take the difference between the two fields by entering:
display hgt.2 - hgt.1
Another built in function calculates horizontal relative vorticity via finite differencing:
Yet another function takes a mass weighted vertical integral:
Here we have calculated precipitable water in mm.
Now we will move on to the topic of controlling the graphics output. So far, we have allowed GrADS to chose a default contour interval. We can override this by:
set cint 30d hgt
We can also control the contour color by:
set ccolor 3d hgt
We can select alternate ways of displaying the data:
set gxout shadedd hcurl(u,v)
This is not very smooth; we can apply a cubic smoother by entering:
set csmooth ond hcurl(u,v)
set ccolor 0set cint 30d hgt
and we can annotate:
draw title 500mb Heights and Vorticity
We can view wind vectors:
set gxout vectord u;v
You may display pseudo vectors by displaying any field you want:
d mag(u,v) ; q*10000
Here the U component is the wind speed; the V component is moisture.
We can also view streamlines (and colorize them):
set gxout streamd u;v;hcurl(u,v)
Or we can display actual grid point values:
set gxout gridd u
set lon -110 -70set lat 30 45set mpdset mresset digsize 0.2set dignum 2d u
To alter the projection:
set lat 15 80set mpvals -120 -75 25 65set mproj npsset gxout contourset cint 30d hgt
In this case, we have told grads to access and operate on data from longitude 145W to 40W, and latitude 15N to 80N. But we have told it to display a polar stereographic plot that contains the region bounded by 120W to 75W and 25N to 65N. The extra plotting area is clipped by the map projection routine.