GrADS

This page provides an introduction to the GrADS plotting utility and scripting language. In the task here, GrADS is applied mainly to the GRIB files of the NCAR/NCEP Reanalysis Data. For a sample of what GrADS plot looks like, you may want to check my rather limited GrADS-powered online reanlysis plotter. Your next stop should perhaps be at the official GrADS Home Page, and then to the official GrADS tutorial. (Use wget to move the 3 files to Gentry, as explained in Tips).

Fortunately, you can use GRIB data fairly easily without becoming an expert on GRIB. This succinct introduction to GRIB, GrADS, and wgrib has a plug for GrADS. Recall the wgrib utility can be used to extract and convert GRIB data to familiar text and binary forms. Using wgrib with GRIB files was introduced in numpy. Using wgrib to extract a times series was done with a modified version, wgrib_hacked.c, in Statistical Analysis of Norman Temperature. GrADS can open and read GRIB files with simple commands. You might be able to get your work done, without a need for either Python or wgrib. That should be the true for the task here, but a Python alternative to the GrADS scripting is demonstrated at my old grads site. For my own research purposes, I don't really need GrADS anymore. I would prefer to use wgrib to extract the data, Python to process the data, and the basemap toolkit (within matplotlib) to plot the result. Plotting with basemap was demonstrated in NetCDF. For example, these netCDF files can be opened analyzed and plotted using the methods in NetCDF.

But your boss may want you to use GrADS. Also, you may appreciate Python more after you try GrADS. The task here is pure GrADS.

A critique of GrADS

As a user of Python, Perl, Ferret and R, let me share with you some of my reactions to GrADS and its scripting language.

Plotting capabilities appear to be similar to Ferret, though GrADS is most friendly with GRIB data, and Ferret is most friendly with netCDF.

The GrADS scripting language, like that for Ferret, is very limited as compared with Python and R.

You cannot do much of anything with GrADS until a file is open and and a two-diemnsional field is plotted. For example, after setting a longitude and latitude window, and drawing a map backgrounds, you still cannot use w2xy, and therefore cannot plot a single hurricane position with graphic primitives, until a two-dimensional field is plotted.

The GrADS scripting language is NOT the same as the command line language. This make GrADS somewhat uniquely peculiar. As discussed in the manual, instructions for plotting, opening files, etc. that you want to behave like on GrADS command line must be entirely quoted or otherwise formed as a single string. New variables can be defined with the scripting language.

But here is something to beware of. From the GrADS command line:

        y=3+1
        display y
        x=sqrt(y)
        display x

But from the scripting language,

        y=3+1
        say y
        'display sqrt('y')'
        x=subwrd(result,4)
        say x

There is no sqrt function that can be used directly within the scripting language. Likewise, there appears to be limited string processing in GrADS; the subwrd function is useful to prepare labels for plots, but if only found in the scripting language.

Needless to say, doing any data processing within GrADS could be rather frustrating, as compared with Python, R or Ferret.

The implicit concatenation of strings, as in 'display sqrt('y')', is useful, but can be very difficult to edit or to understand without syntax highlighting. Fortunately, vim does an admirable job in highlighting the syntax.

GrADS does not tolerate indenting with tabs.

TASK: comparing reanalyses

Grab this {*} : gradstask.tar

We compare Reanalysis-2 files available at NCEP server 1 nomad3 with some ancient (circa 1996) reanalysis data, which was originally distributed on CDs. Gentry has many GB of the ancient data in /REANALYSIS, copied through mulitple computers over the past decade. That data has occasionally been updated with a purchase of CDs for recent years. Perhaps there is better reanalysis data than that contained within /REANALYSIS. Indeed, we can read at NCEP/DOE AMIP-II Reanalysis that The goal of Reanalysis-2 is to improve upon the NCEP/NCAR Reanalysis by fixing the errors and by updating the parameterizations of the physical processes.

Nevertheless, there is still a continuing project known as NCEP/NCAR Reanalysis 1 If you navigate that site, you will find data distributed as netCDF files.

This tutorial will emphasize the use of grib files, with the classic GrADS program, which in recent years is now titled gradsc.

For example, Gentry already has pgp.197901 and pgp.197907 , downloaded from here, and available on Gentry within /it. (In the task you will make symbolic links to those files, rather than copy them to your directory). Despite the absence of a .grb extension, those files are in grib format.

If you visited the official GrADS tutorial, to became acquainted with how GrADS uses the associated descriptor file (.ctl) and an index file (.gmp or .idx) in conjunction with the GRIB file (.grb).

The .ctl files that came with our ancient reanalysis data are dysfucntional with the current version of GrADS on Gentry: v1.9b4 . Fortunately, it is simple to reconstitute a .ctl and .idx file from the GRIB file using the utilities grib2ctl.pl and gribmap. Thes utilities are available from the command line on Gentry, and have already been scripted as part of the task file that you can download. The simple usage of these utilities are described at grib2ctl home page.

The GrADS script tworean.gs within gradstask will produce some PNG images, among which is:

janboth.png

required plots

You will need to add to tworean.gs the ability to produce the following:

julboth.png

janavgdifference.png

julavgdifference.png

Link Summary