GRADS in a Nutshell


The "Grid Analysis and Display System" is recommended to visualise GOTM results (select netCDF outputs) since it offers a set of commands (display, legend...), built-in functions (ave, mag,..) and scripts (cbarn, page, output...) that enable to plot easily results (profiles, time evolution, animation) in less than 5 minutes!.


How to use GRADS in less than 5 minutes ....?

GRADS (Grid Analysis and Display System) is a freely distributed visualisation package writen by Brian E. Doty at COLA (Center for Ocean-Land-Atmosphere Interactions, USA). GRADS provides an interactive desktop tool that is in use worldwide for the analysis and display of earth science data.

  • Official Homepage (A good starting point)
  • Complete manual (Grads command description in HTML)
  • Rapid tutorial (Didactic example to run GRADS from the Data Assimilation Office)
  • List Server for FAQ (Key questions answered on a mailing list)
  • Widgets (GUI user interface application)
  • Command rapid reference (Handy reference card in PostScript file)



  • Scripting language

    The GrADS scripting language, used via the GRADS run command, provides a capability to perform a variety of functions, such as allowing a user to point and click on the screen to select something, to animate any desired quantities, to annotate plots with information obtained from GrADS query commands. Some of the following scripts have been specially designed for GOTM (no free-bug guarantee !!). Executable like gxps are used by the GRADS scripts and should be put in the local directory.


    GRADS scripts for general use
    cbarn.gs

    Create a color bar after a shaded contour plot is displayed

    output.gs

    Make hardcopy in PS, EPS, GIF format by using the executables gxps, gxeps, gxgif (to be downloaded on the GRRADS web site)

    page.gs

    Divide the graphical page in sub-windows

    string.gs

    Plots string at point-click location.

    GRADS scripts for GOTM
    gotm.gs

    Generate GOTM outputs for the Web (read netCDF file and call scripts below)

    forcing.gs

    Plot the forcing (zeta, wind stress, heat fluxes...)

    turbu.gs

    Plot the Turbulent quantity and the T/S fields


    Some interesting web sites with further examples:
  • Scripting reference card (Handy reference for scripts in PS format)
  • Built Functions with GRADS (aave, hdiv, hcrul, cdiff,...)
  • Karin Scripts (Animation Examples)
  • Bob Scripts (General Coordinate interpolation)
  • Roby Scripts (ECMWF Grib Analysis Examples)
  • List of Scripts (Five Star Scripts)



  • A tutorial of most classic commands


    COMMAND DESCRIPTION OF WHAT THE COMMAND DOES
    grads

    Open grads (select portrait or landscape mode)

    open filename1

    Open filename1.ctl that reads filename2.dat

    open filename2

    Open filename2 (variables referenced by var.2)

    q filename

    Gives information of file

    q time

    Gives the time

    q dims

    Gives the dimension

    set poli on|off

    Select map with Political boundary

    set display greay|greyscale|color

    Select the mode of display

    quit

    To leave grads

    DIMENSION FUNCTION
    set lev -6 0

    Select depth between -6m and surface

    set t 1 250

    Select the 250 first data

    set z 1 100

    Select the data set for the all water levels

    DISPLAY FUNCTION
    clear

    Clear graphics window

    d var1

    Plot the field var

    d var2

    Superimposes var2 contour if clear was not used

    d var2(t=12)

    Plot var2 at iteration 12

    d var1-var2

    Plot the difference var1-var2

    d log10(var)

    Plot the logarithm of var

    d mag(u,v)

    Plot the module of velocity

    d var.1-var.2

    Plot the difference of var from 2 files

    d ave(var,z=n1,z=n2)

    Depth-averaged of var (n1->n2)

    run cbarn

    Run the script to create a color bar

    set loopdim t || set looping on || set t n1 n2 || d tloop(var)

    To animate a profile graph in time

    set looping off || set t n1 n2 || d var

    Plot the time-depth surface of var

    DRAW & AXIS FUNCTION
    draw ylab Text

    Show the label "Text" on the Y-axis

    draw title Text

    Show the label "Text" for the title

    draw string n1 n2 Text

    Plot "Text" at position x=n1, y=n2

    set string color n1 n2

    String parameters: n1=justification (tc,tr,tl) n2=thickness

    draw line x1 y1 x2 y2

    Plot a line from x1,y1 to x2,y2

    set string n1 tc n3

    n1=color, tc=centered justification n3=thickness

    set axlim n1 n2

    Limit axis between n1 & n2

    set xaxis n1 n2 n3

    Put a scale from n1 to n2 with step n3

    CONTOUR OPTIONS FUNCTION
    set gxout shaded

    Set Graphic type to Shaded contour plot

    set gxout contour

    Set Graphic type to Contour plot

    set gxout stat

    Set Graphic type to Info on statistics

    set gxout grid

    Set Graphic type to Grid boxes with values

    set gxout fgrid

    Set Graphic type to Shaded grid boxes

    set gxout bar

    Set Graphic type to Bar chart

    set cthick n

    Set a thickness n for contours

    set ccolor n

    0-black | 1-white | 2-red | 3-green | 4- blue | 5-cyan | 6-magenta | 7-yellow | 8-orange | 15-grey

    set cmark n

    0-None | 1-cross-hair | 2-open circle | 3-closed circle | 4-open square | 5-closed square

    set cstyle n

    1-solid | 2-long dash | 3-short dash | 4-long, short dashed | 5-dotted

    set clskip 2

    Contour: Skip 2 contour label

    set clevs n1 n2 n3

    Impose contour levels

    set cint n

    Impose contour interval

    set ccols n1 n2 n3...

    Impose contour colors

    set cmin n

    Impose minimum value

    set cmax n

    Impose maximum value

    set black n1 n2

    Contour not drawn within n1,n2

    set rbrange n1 n2

    Impose the range n1,n2

    set cterp on|off

    Impose spline interpolation

    set clab on|off|forced

    Impose contour label

    HARDCOPY FUNCTION
    wi filename.ext

    Unix ImageMagick to create ext file (ext=.ps, .gif, .bmp, .jpeg, .eps...)

    run output ext

    Run script output to create a ps,eps, of gif files. Note that this scripts requires the executable gxps, gxeps, gxgif that can be downloaded from the GRADS website

    VECTOR FUNCTION
    d skip(u,2,2);v

    Diplay velocity and skip one of two