Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > dcaf9bd555d1ce386641f56c6523d3ed > files > 376

grads-2.0.2-1.fc18.i686.rpm

<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->

<html>
<head>
<title>GrADS Tutorial</title>
<link href="GrADS.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="e0f0ff" text="#000000">

<h1>Tutorial (<a href="Tutorial_Espanol.doc">En Espa&ntilde;ol</a>)</h1>
<p>
<h3>What is it?</h3>
This document presents a brief tutorial for Brian Doty's <a
href="http://grads.iges.org/grads">Grid
Analysis and Display System (GrADS)</a>. The following sample
session
will give you a feeling for how to use the basic capabilities of
GrADS. This sample session takes about 30 minutes to run through. Here is a copy of
<p>

<h3>Before you start:download the sample data</h3>
You will need the following sample data files in order to go through
this tutorial: 
<p>
<ul>
<a href="ftp://cola.gmu.edu/grads/sprite/tutorial/model.ctl">
<code>model.ctl&nbsp;&nbsp;&nbsp;</code></a>GrADS descriptor file (0.7 kb) <br>
<a href="ftp://cola.gmu.edu/grads/sprite/tutorial/model.grb">
<code>model.grb&nbsp;&nbsp;&nbsp;</code></a>GrADS (GRIB) data file (579 kb) <br>
<a href="ftp://cola.gmu.edu/grads/sprite/tutorial/model.gmp">
<code>model.gmp&nbsp;&nbsp;&nbsp;</code></a>GrADS gribmap index file (4 kb) <br>
</ul>

<p>
This data file is described by the data descriptor file
<a href="ftp://cola.gmu.edu/grads/sprite/tutorial/model.ctl">
<code>model.ctl</code></a>. You may want to look at this file before
continuing.  The data descriptor file describes the actual data file,
which in the case contains 5 days of global grids that are 72 x 46
elements in size.<p> Please download these 3 files to a local
directory before proceeding. 
<p> 
<h3>Sample Session</h3>
<p>
To start up GrADS, enter:
<p>
<dd><a href="gradcomdgrads.html"><code>grads</code></a> 
  <p> If the <span class="code">grads</span> 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: 
  <p>
<dd><code>/usr/homes/smith/grads/grads</code> 
  <p>
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 resize 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.
<p>
In the text window (where you started grads from), you should now
see a prompt:  <code>ga-></code>    You will enter GrADS commands at this
prompt and see the results displayed in the graphics output
window.<p>

The first command you will enter is:<p>

<dd><code><a href="gradcomdopen.html">open</a> model.ctl</code><p>

You may want to see what is in this file, so enter:<p>

<dd><code><a href="gradcomdquery.html">query</a> file</code><p>

One of the available variable is called <code>ps</code>, for surface pressure. 
We can display this variable by entering:<p>

<dd><code><a href="gradcomddisplay.html">d</a> ps</code><p>

<code>d</code> is short for <a href="gradcomddisplay.html"><code>display</code></a>.   You
will note that by default, GrADS
will display an X, Y plot at the first time and at the lowest
level in the data set.<p>
<center><img src="tutorial_fig1.gif"></center><p><br>

Now you will enter commands to alter the <a
href="dimenv.html"><code>dimension environment</code></a>. 
The <a href="gradcomddisplay.html"><code>display</code></a> command (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 <code>set</code> command:

<p>
<ul>
<code>
<a href="gradcomdclear.html">clear</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>clears the display<br> 
<code><a href="gradcomdsetlatlonlevtimeens.html">set lon</a> -90
&nbsp;&nbsp;&nbsp;&nbsp;</code>sets longitude to 90 degrees West<br> 
<code><a href="gradcomdsetlatlonlevtimeens.html">set lat</a> 40
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>sets latitude to 40 degrees North<br> 
<code><a href="gradcomdsetlatlonlevtimeens.html">set lev</a> 500
&nbsp;&nbsp;&nbsp;&nbsp;</code>sets level to 500 mb<br>
<code><a href="gradcomdsetlatlonlevtimeens.html">set t</a> 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>sets time to first time step<br> 
<code><a href="gradcomddisplay.html">d</a> z
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>displays the variable 'z'<br>
</ul>

<p>
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 at the location 90W, 40N, 500mb,
and the 1st time in the data set.<p>

If we now enter:<p>
<ul>
<code><a href="gradcomdsetlatlonlevtimeens.html">set lon</a> -180 0</code>&nbsp;&nbsp;&nbsp;&nbsp;         X is now a varying
dimension<br>
<code><a href="gradcomddisplay.html">d</a> z</code></ul><p>

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.<p>
<center><img src="tutorial_fig2.gif"></center><p><br>
Now enter:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lat</a> 0 90<br> 
<a href="gradcomddisplay.html">d</a> z</code></ul><p>

We now have two varying dimensions, so by default we get a
contour plot.  If we have 3 varying dimensions:<p>
<ul>
<code><a href="gradcomdclear.html">c</a><br>
<a href="gradcomdsetlatlonlevtimeens.html"> set t</a> 1 5<br>
<a href="gradcomddisplay.html">d</a> z</code></ul><p>

we get an animation sequence, in this case through time.<p>

Now enter:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lon</a> -90<br>
<a href="gradcomdsetlatlonlevtimeens.html">set lat</a> -90 90<br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lev</a> 1000 100<br>
<a href="gradcomdsetlatlonlevtimeens.html">set t</a> 1<br>
<a href="gradcomddisplay.html"> d</a> t<br>
<a href="gradcomddisplay.html"> d</a> u</code></ul><p>

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
enter the <code><a href="gradcomdclear.html">clear</a></code> command.<p>
<center><img src="tutorial_fig3.gif"></center><p><br>
Another example, in this case with X and T varying (Hovmoller
plot):<p>
<ul>
<code><a href="gradcomdclear.html">c</a><br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lon</a> -180 0<br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lat</a> 40<br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lev</a> 500<br>
<a href="gradcomdsetlatlonlevtimeens.html"> set t 1 5<br>
<a href="gradcomddisplay.html"> d z</a></code></ul><p>
<center><img src="tutorial_fig4.gif"></center><p><br>
Now that you know how to select the portion of the data set to
view, we will move on to the topic of operations on the data. 
First, set the dimension environment to an Z, Y varying one:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lon</a> -180 0<br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lat</a> 0 90<br>
<a href="gradcomdsetlatlonlevtimeens.html"> set lev</a> 500 <br>
<a href="gradcomdsetlatlonlevtimeens.html">set t</a> 1</code></ul><p>

Now lets say that we want to see the temperature in Fahrenheit
instead of Kelvin.  We can do the conversion by entering:<p>

<dd><code><a href="gradcomddisplay.html">display</a> (t-273.16)*9/5+32</code><p>

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:<p>

<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomddisplay.html">d</a> <a
href="gradfuncsqrt.html">sqrt</a>(u*u+v*v)</code></ul><p>


to calculate the magnitude of the wind.  A function is provided
to do this calculation directly:<p>

<dd><code><a href="gradcomddisplay.html">d</a> <a
href="gradfuncmag.html">mag</a>(u,v)</code><p>
<center><img src="tutorial_fig5.gif"></center><p><br>
Another built in function is the averaging function:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomddisplay.html">d</a> <a
href="gradfuncave.html">ave</a>(z,t=1,t=5)</code></ul><p>

In this case we calculate the 5 day mean.  We can also remove the
mean from the current field:<p>

<dd><code><a href="gradcomddisplay.html">d</a> z - <a
href="gradfuncave.html">ave</a>(z,t=1,t=5)</code><p>

We can also take means over longitude to remove the zonal mean:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a> d z-<a href="gradfuncave.html">ave</a>(z,x=1,x=72)<br>
<a href="gradcomddisplay.html">d</a> z</code></ul><p>

We can also perform time differencing:<p>
<ul>
<a href="gradcomdclear.html">clear</a><br>
<a href="gradcomddisplay.html">d</a> z(t=2)-z(t=1)</code></ul><p>

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:<p>

<dd><code><a href="gradcomddisplay.html">d</a> z(t+1) - z</code><p>

The complete specification of a variable name is:<p>

<dd><code>name.file(dim +|-|= value, ...)</code><p>

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:<p>


<dd><code><a href="gradcomddisplay.html">display</a> z.2 - z.1</code><p>

Another built in function calculates horizontal relative
vorticity via finite differencing:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomddisplay.html">d</a> <a
href="gradfunchcurl.html">hcurl</a>(u,v)</code></ul><p>

Yet another function takes a mass weighted vertical integral:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomddisplay.html">d</a> <a href="gradfuncvint.html">
vint</a>(ps,q,275)</code></ul><p>

Here we have calculated precipitable water in mm.<p>

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:<p>

<ul><code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetcint.html">set cint</a> 30<br>
<a href="gradcomddisplay.html">d</a> z</code></ul><p>

We can also control the contour color by:<p>
<ul>
<code><a href="gradcomdclear.html">clear</br>
<a href="gradcomdsetccolor.html">set ccolor</a> 3<br>
<a href="gradcomddisplay.html">d</a> z</code></ul><p>

We can select alternate ways of displaying the data:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetgxout.html">set gxout</a> shaded<br>
<a href="gradcomddisplay.html">d</a> <a href="gradfunchcurl.html">
hcurl</a>(u,v)</code></ul><p>

This is not very smooth; we can apply a cubic smoother by
entering:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetcsmooth.html">set csmooth</a> on<br>
<a href="gradcomddisplay.html">d</a> <a href="gradfunchcurl.html">
hcurl</a>(u,v)</code></ul><p>
<center><img src="tutorial_fig6.gif"></center><p><br>
We can overlay different graphics types:<p>
<ul>
<code><a href="gradcomdsetgxout.html">set gxout</a> contour<br>
<a href="gradcomdsetccolor.html">set ccolor</a> 0<br>
<a href="gradcomdsetcint.html">set cint</a> 30<br>
<a href="gradcomddisplay.html">d</a> z</code></ul><p>

and we can annotate:<p>

<dd><code><a href="gradcomddrawtitle.html">draw title</a> 500mb Heights and
Vorticity</code><p>

We can view wind vectors:<p>

<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetgxout.html">set gxout</a> vector<br>
<a href="gradcomddisplay.html">d</a> u;v</code></ul><p>
<center><img src="tutorial_fig7.gif"></center><p><br>
Here we are displaying two expressions, the first for the U
component of the vector; the 2nd the V component of the vector. 
We can also colorize the vectors by specifying a 3rd field:<p>

<dd><code><a href="gradcomddisplay.html">d</a> u;v;q</code><p>

or maybe:<p>

<dd><code><a href="gradcomddisplay.html">d</a> u;v;<a
href="gradfunchcurl.html">hcurl</a>(u,v)</code><p>

You may display pseudo vectors by displaying any field you want:<p>

<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomddisplay.html">d</a> <a href="gradfuncmag.html">mag</a>(u,v) ;
q*10000</code></ul><p>

Here the U component is the wind speed; the V component is
moisture.<p>

We can also view streamlines (and colorize them):<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetgxout.html">set gxout</a> stream<br>
<a href="gradcomddisplay.html">d</a> u;v;<a
href="gradfunchcurl.html">hcurl</a>(u,v)</code></ul><p>

Or we can display actual grid point values:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br>
<a href="gradcomdsetgxout.html">set gxout</a> grid<br>
<a href="gradcomddisplay.html">d</a> u</code></ul><p>
<center><img src="tutorial_fig8.gif"></center><p><br>
We may wish to alter the map background:<p>
<ul>
<code><a href="gradcomdclear.html">clear</a><br> 
<a href="gradcomdsetlatlonlevtimeens.html">set lon</a> -110 -70<br>
<a href="gradcomdsetlatlonlevtimeens.html">set lat</a> 30 45<br>
<a href="gradcomdsetmpdset.html">set mpdset</a> nam<br>
<a href="gradcomdsetdigsize.html">set digsize</a> 0.2<br>
<a href="gradcomdsetdignum.html">set dignum</a> 2<br> 
<a href="gradcomddisplay.html">d</a> u</code></ul><p>

To alter the projection:<p>
<ul>
<code><a href="gradcomdsetlatlonlevtimeens.html">set lon</a> -140 -40<br>
<a href="gradcomdsetlatlonlevtimeens.html">set lat</a> 15 80 <br>
<a href="gradcomdsetmpvals.html">set mpvals</a> -120 -75 25 65<br>
<a href="gradcomdsetmproj.html">set mproj</a> nps<br>
<a href="gradcomdsetgxout.html">set gxout</a> contour<br>
<a href="gradcomdsetcint.html">set cint</a> 30<br> 
<a href="gradcomddisplay.html">d</a> z</code></ul><p>

In this case, we have told grads to access and operate on data
from longitude 140W 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.<p>
<center><img src="tutorial_fig9.gif"></center><p><br>
This concludes the sample session.  At this point, you may wish
to examine the data set further, or you may want to go through
the GrADS documentation and try out the other options described
there.

</body>
</html>