NumLab2013: Instructions for using GrADS


GrADS (Grid Analysis and Display System) is a freely available graphics and analysis program, which is well suited for analysis of meteorological model output. This web page tells the basics of using GrADS on the NumLab 2013 course. A much more detailed documentation of GrADS commands is avilable at the GrADS home page.

Starting GrADS

GrADS is available in numlab.fmi.fi. If you want to install the program in your own PC, go to the GrADS home page and follow the instructions.

To start the program, write either the command

   grads -p or grads -l
Try both alternatives to find out what -p and -l do. For hardcopy output (e.g., for the course report) grads -p is usually better.

If you did not manage to start GrADS with one of these two commands, this is probably because you forgot to follow the X instructions.

Opening files in GrADS

A two-step procedure is needed to convert the MUSC output two grads binaries: (1) from lfa to text files and (2) from text files to grads binaries and the corresponding descriptor (or ctl) files. See here for instructions.

Once you have the .grads and .ctl files available, open the file with

  open filename.ctl
where filename.ctl is the name of your data descriptor file. Thus, you do not open the grads binary file (.grads) directly, but rather the data descriptor file (.ctl) that refers to this binary file.

The data descriptor (.ctl) files can be read from the screen or within a editor. One can inspect their contents to get an idea of what the actual binary file (.grads) contains.

Drawing figures in GrADS

The basic principle of producing figures on the screen is simple:
  1. Open the necessary file(s) by using the open command
  2. Do the relevant calculations and draw the figure using the display (d) command. 
The harder part is step (2). GraDS has a very large number of commands, which are documented here.

You can write all GrADS commands directly from the keyboard, but this is not an efficient way of working. Generally, it is preferable to write the commads to a separate command file, which is then executed in GrADS by using the exec command

   exec commandfilename    

Producing graphics files for later use

GrADS has several commands for producing graphics output files. Three of them are described below:


The gxps command is good for producing high-quality postscript (.ps) output. Two use it, add the following steps to the previous sequence:

  1.5 Give the command enable print figurename (or whatever filename)
  3. Give the command print
  4. Give the command disable print 
  5. Give the command !gxps -i figurename -o figurename.ps
A disadvantage of gxps is that MS Office does not recognize the .ps format. One way to use these files in your MS Office documents is to add the header fields given in epshead.eps and modify the BoundingBox values to crop unnecessary margins:

  - cat epshead.eps figurename.ps > figurename.eps
  - edit the values in BoundingBox, and remove the second initgraphics line.
Another, possibly easier alternative is the Inkscape program, which is directly available in Linux computers in the Physicum computer classes (though not in numlab.fmi.fi). In inkscape,
  - First open the file (default import settings should be OK)
  - Then choose file -> save as and after this Encapsulated Postscript from the lower right menu.
  - In the Encapsulated Postscript window which should open now, check that there is a tick mark in the "Export area is drawing" box.
  - You can still edit the BoundingBox in the resulting .eps file manually if you are not happy with the outcome. 


The gxeps command produces encapsulated postrcipt files (.eps) directly, without the need for manual intervention. The disadvantage is that the quality is slighty lower, and the files are actually sometimes shown erroneously in MS Office documents.

To use this command, just replace the step (5) above with

  5. Give the command !gxeps -i figurename -o figurename.eps


The printim command produces a .png [default], .gif, or .jpg file based on the output visible of the screen. You can use the command whenever you want, i.e., there is no need to say enable print before. Examples

  printim figure.png produces a png file on black background
  printim figure.jpg jpg white produces a jpg file on white background
printim is only available in relatively recent versions of GrADS.

Examples and a tutorial

The best way to learn is to use GrADS actively for a few years. However, for a faster start of the learning process, there are some examples available in this directory.

Copy the contents of the directory to a suitable place in numlab.fmi.fi. Then execute each of the three command files, i.e.

   exec example1   
   exec example2   
   exec example3   
to see what happens on the screen. At the same time, study the contents of the command files in emacs or another editor, to learn the commands that were used to produce the output.

A longer tutorial on using GrADS is available on the GrADS home page, more specifically here.

Back to the NumLab2013 homepage.