Using GrADS to visualize NICAM output
H. Miura, Feb 23, 2012
About this document
The document describes how to visualize simulation results of
Non-hydrostatic Icosahedral Atmosphere Model (NICAM) through a use ofGrid Analysis and Display System (GrADS) software. This visualization
software “GrADS” has been developed and updated by a Center for
Ocean-Land-Atmosphere Studies (COLA) and its current version is at 2.0.1.
You can obtain official documents from a GrADS’ website(http://www.iges.org/grads/downloads.html), which offers some tutorials onhow to get used to (http://www.iges.org/grads/gadoc/tutorial.html).
Furthermore, another useful tip can be seen on a “GrADS Commands Quick
Reference Card (http://www.iges.org/grads/gadoc/reference_card.pdf)”, which
provides lists of available commands and can be used for a quick reference. If
you want to know more about this subject, you may refer to the manual(ftp://grads.iges.org/grads/beta/doc/gadoc151.pdf) for details.
However, our aim here is not to study on GrADS itself, but to use GrADS
to visualize outputs from a NICAM simulation. Thus all the necessarycommands are listed in order, and you can finish the exercise by simply
following them. We are hoping that, after you are done with this class, you
should be able to drawcontour plots, shaded plots, and vector plots onlongitude-latitude cross section,

contour plots on latitude-height cross section, and

contour plots on longitude-time cross section

from NICAM output data.
A. Starting up
We will first login to a server, then, move to a computing node.
i.

$ ssh -X (your account)@nicamgate.aori.u-tokyo.ac.jpii.

$ ssh -X compute0 (or compute1)

Then, we will move to a directory contains some sample data files.
iii.

$ cd /data1/tutorial/NICAM_OUTPUT/global
1

Starting up GrADS by typingiv.

$ grads

then, you will see a separate black window on your display. If you exit
GrADS, just typev.

> quithere “>” means a command prompt of GrADS, while “$” means a shellcommand prompt.
B. Opening a data description file (file that describes what kind of data setit contains)
A NICAM output data set used here is “ms_u.dat”, where “m” means
multi-level, “s” means snapshot, and “u” means a zonal wind. The
structure of the data is described in a description file “ms_u.ctl”. If you
want to know more about what data formats GrADS can handle, pleaserefer to a manual. Anyhow, now to access an “ms_u.dat” file, we open
ms_u.ctl by typing as below in a X-termiali.

> open ms_u.ctl

You can look up what type of data set you just opened by typing“> q file”.
C. Longitude-latitude cross sections
You can make a simple contour plot by typingi.

> d ms_u (or > display ms_u)

Horizontal distribution of zonal wind at 80 m height is plotted on theGrADS window. To change vertical level from 80 m to 1570 m (“q file”
command has an info on number of vertical levels that data set has),typing as below.
ii.

> set z 8 (or > set lev 1570)

iii.

> d ms_u

To reset window to blank, enteriv.

> c (or > clear)

If you want to focus on East Asia, enterv.

> set lon 100 150
2vi.

> set lat 20 60

and type “> d ms_u” again. The longitude and latitude ranges are set to100E-150E and 20N-60N, respectively. Not only you can freely choose
geographical location that you seek, also can choose a temporal scale.
For example, to plot a zonal wind at second time level, entervii.

> set t 2

If two numbers are given next to a “> set t” command, as inviii.

> set t 1 24

GrADS will display an animated plot of those two time levels andbetween. When you cannot remember a current time level (or spacedimensions), useix.

> q time (> q dims)

We can also compute time- and space-averages in GrADS, by using“ave” (average) and “aave” (area average) functions. We will have someexamples below.
x.

> d ave(ms_u,t=1,t=24)xi.

> d aave(ms_u,lon=100,lon=150,lat=20,lat=60)

Now, we are going to plot a shaded figure of a temperature. To reset
all of the current settings to defaults, enterxii.

> reinit

then, open a description file of temperature data,xiii.

> open ms_tem.ctl

To change a plot type from a default of contour plot to a shaded plot, typexiv.

> set gxout shaded

When you want to return to a contour plot, type “> set gxout contour”. Todraw a field of temperature, enterxv.

> d ms_tem

If you need to add a color bar, enterxvi.

> cbar.gs

Next is a vector plot of zonal and meridional winds. Reset and open
three description files as below.
3xvii.

> reinit

xviii.

> open ms_u.ctl

xix.

> open ms_v.ctl

xx.

> open ms_tem.ctl

To make a vector plot, typexxi.

> d ms_u.1;ms_u.2

To reduce vector density, use function “skip” as below.
xxii.

> d skip(ms_u.1,3,2);ms_v.2

Wind vectors can be colored by adding temperature to the thirddimension.
xxiii.

> d skip(ms_u.1,3,2);ms_v.2;ms_tem.3

D. Latitude-height cross section
To reset GrADS settings while keeping current data files, enteri.

> resetTo draw a latitude-height cross section, first fixing a longitude byii.

> set lon 0

then allowing multi-levels in a heightiii.

> set z 1 30

and typeiv.

> d ms_u

GrADS can output a latitude-height cross-section of zonal wind by drawing azonal mean of zonal windv.

> d ave(ms_u,lon=0,lon=360)

and superimposed by zonal mean of temperaturevi.

> d ave(ms_tem.3,lon=0,lon=360)

now, you see a well-known thermal wind relationship between a zonal wind
and temperature.
E. Longitude-time cross section
The last exercise is to plot a longitude-time cross section ofoutgoing-longwave-radiation (OLR), which is a proxy of upper-level clouds.
Reset settings to defaults and open description file of OLR.
4

i.

> reinitii.

> open ss_lwu_toa.ctl

Fixing a latitude to 0iii.

> set lat 0

and allowing a time to move from 1 to 72 levelsiv.

> set time 1 72

also plotting an averaged OLR value between 10S and 10N as below.
v.

> d ave(ss_lwu_toa,lat=-10,lat=10)

In this plot, time is advancing forward. But, if you rather want to check in areverse order, typevi.

> set yflip onthen type “d ave(ss_lwu_toa,lat=-10,lat=10)” again.
F.

Save image in file
To save image in a file, use “printim” command of GrADS.
i.

> printim ~/a.png

Now, you have a graphic file “a.png” in your home directory. To checkthis file, use “display” command asii.

$ display ~/a.png

Then exit a GrADS by (> quit).

5