A brief introduction to the GrADS software package.
- Example output
- File formats catered for
- Typical operations
- Quick start tutorial
- Further information
Grid Analysis and Display System (GrADS) is a freely available package used for analysis, manipulation and plotting of earth science data. It is designed for gridded datasets but can also cope with station data.
Below are some key features of GrADS:
- available for multiple platforms as an executable (including Windows).
- accessible by both a command-line and scripting interface.
- support for multiple common data formats.
- significant support for user-defined plotting.
- manipulation of large 4-D datasets.
- a rich set of built-in functions for data manipulation.
Figure 1 shows a GrADS plot and the command-line interface running on a Linux operating system.
Figure 1. GrADS example output.
File formats catered for
GrADS can open the following file formats:
- NetCDF - directly (using sdfopen filename at the command line).
- GRIB - using the GrADS/GRIB interface. You must generate a control ('.ctl') file and gribmap (index - '.idx') file before opening (using open ctl_file). Note that GrADS will only understand regular (rectilinear) gridded data.
- HDF-SDS - a separate executable exists for opening HDF files.
- GrADS binary format - consisting of a binary data file ('.dat') and a control file ('.ctl').
GrADS writes output to GrADS binary format as standard.
GrADS will typically be used for operations such as:
- Plotting a variable from a file on a shaded plot and overlaying contours from a second variable.
- Aggregating multiple files into one control file so that slices of data can be read in across multiple files.
- Differencing 2 different datasets.
- Calculating departures from a climatology from a dataset.
- Regridding a dataset.
- Calculating the statistical data from variables.
Quick start tutorial
In order to use GrADS you must have it installed on your machine. It can be downloaded from:
Note that you can download either the source code or a pre-compiled binary. Use the latter if you are not sure about building the software yourself, the binary executable should work straight away on your system.
This tutorial requires that you have a sample NetCDF file. You can download the sample file here (84KB). The file (called 'wind_comps.nc') is a NetCDF file containing u-wind and v-wind data over the globe at a 2.5° resolution at the 1000hPA level. Save the NetCDF in the directory you are working in before you start the tutorial.
The following commands should allow you to calculate the wind-speed ('wspd') from the u-wind ('u') and v-wind ('v'), plot the resulting variable and write it to an output NetCDF file.
The command to type is shown in bold and the output in plain type. The commands are annotated in normal font in the right-hand column. The tutorial follows:
|ga-> grads||This starts the GrADS shell. Windows users will need to click on the GrADS icon to start it, or select it from the 'Start' menu.|
| Grid Analysis and Display System (GrADS) Version 1.8SL11
Copyright (c) 1988-2001 by Brian Doty
Center for Ocean-Land-Atmosphere Studies
Institute for Global Environment and Society
All Rights Reserved
Config: v1.8SL11 32-bit little-endian readline sdf/xdf netcdf lats printim
Issue 'q config' command for more information.
Landscape mode? (no for portrait): y
GX Package Initialization: Size = 11 8.5
|ga-> sdfopen 'wind_comps.nc'||Opens the NetCDF file.|
| Scanning self-describing file: wind_comps.nc
Found 2 data variables in SDF file.
Found displayable variable u with 0 levels in SDF file.
Found displayable variable v with 0 levels in SDF file.
SDF file wind_comps.nc is open as file 1
LON set to 0 360
LAT set to -90 90
LEV set to 0 0
Time values set: 2003:1:1:0 2003:1:1:0
|ga-> q file||Gives details of the file contents.|
| File 1 : BADC test data: u and v wind component.
Type = Gridded
Xsize = 144 Ysize = 73 Zsize = 1 Tsize = 1
Number of Variables = 2
u 0 -999 ** U-velocity m s**-1
v 0 -999 ** V-velocity m s**-1
|ga-> wspd=mag(u,v)||Calculates the combined wind speed and assigns it to the variable 'wspd'. The function mag(u,v) is a built function equivalent to sqrt(uexpr*uexpr+vexpr*vexpr).|
|Define memory allocation size = 42340 bytes|
|> d wspd||Plot the wind speed variable.|
|> set fwrite output.dat||Open a file to write to called 'output.dat' in GrADS binary format.|
|FWrite file name = out2.dat FWwrite byte order is little_endian; format is stream|
|> set gxout fwrite||Direct the output to the file.|
|> d wspd||Writes output to the file.|
|Wrote 10585 elements to out2.dat as Stream Little_Endian|
|> quit||Closes GrADS.|
If you have problems with the tutorial please contact BADC Support.
Further documentation, tutorials, download and installation instructions for GrADS can be found at the GrADS web pages (http://www.iges.org/grads/).