In this section, visualisation using the graphics package \verb#GrADS#
({\bf Gr}id {\bf A}nalysis and {\bf D}isplay {\bf S}ystem) is
described. A useful Internet site for reference and for installation
instructions is
\begin{quote}
{\url{http://grads.iges.org/grads/grads.html}}.
\end{quote}
The latest version of \verb#GrADS# can handle data in \verb#NetCDF#
format via the command \verb#sdfopen#.
Any file produced by the \verb#Pumaburner# with the option NETCDF=1
can be read directly by \verb#GrADS#.
For files in the \verb#SERVICE# format is possible to use
a converter, which translates from the \verb#SERVICE# format into \verb#NetCDF#.
But in the following it is assumed that the \verb/PUMA/ output has been
postprocessed into the \verb#SERVICE# format with the \verb#Pumaburner# and that the
resulting file is called \verb/puma.srv/. Using the option -g for the \verb#Pumaburner# 
creates the related GrADS control file \verb/puma.ctl/.
Monthly mean data is either obtained
directly from the \verb#Pumaburner# (\verb#namelist# parameter
\verb#MEAN=1#, see section \ref{Pumaburner}) or via a
\verb/CDO/ command:
\begin{quote}
\verb/cdo monmean puma.srv puma_m.srv/
\end{quote}
\noindent Information on the {\bf C}limate {\bf D}ata {\bf O}perators ({\bf CDO}'s)
can be found in the \verb#CDO User's Guide# at
\begin{quote}
 {\url{http://www.mpimet.mpg.de/fileadmin/software/cdo/}}.
\end{quote}
When the \verb#GrADS# control file was not created via the \verb#Pumaburner# 
option -g, it can be done by the command:

\begin{quote}
\verb#srvctl puma_m.srv#
\end{quote}
\noindent which creates the file \verb/puma_m.ctl/. 
It contains information on the grid, time steps, and variable names. The file
\verb/puma_m.srv/ is still needed in addition.
The program
\verb#srvctl.f90# is one of the post-processing tools available at
\begin{quote}
{\url{http://mi.uni-hamburg.de/puma/}}.
\end{quote}
If you chose to compile it yourself, please read the comments in the
first few lines of the program text. Sometimes the
\verb/srvctl/ tool has difficulty calculating an appropriate time axis 
from the data headers of the data records, so you should check this. 
In particular the number of days per year is concerned: \verb#GrADS# may assume 365
days per year even though the data header says 360 days per year.
This is an example of what the \verb/puma_m.ctl/ should look like:
\begin{verbatim}
DSET ^puma_m.gra
UNDEF 9e+09
XDEF     64 LINEAR   0.0000   5.6250
OPTIONS YREV
YDEF     32 LEVELS 
  -85.7606  -80.2688  -74.7445  -69.2130  -63.6786  -58.1430  -52.6065  -47.0696
  -41.5325  -35.9951  -30.4576  -24.9199  -19.3822  -13.8445   -8.3067   -2.7689
    2.7689    8.3067   13.8445   19.3822   24.9199   30.4576   35.9951   41.5325
   47.0696   52.6065   58.1430   63.6786   69.2130   74.7445   80.2688   85.7606
ZDEF      5 LEVELS 
     20000
     50000
     70000
     85000
    100000
TDEF 12 LINEAR 00:00Z01jan0001        1mo
VARS  3
c130     5 99    130     0     0
c131     5 99    131     0     0
c132     5 99    132     0     0
ENDVARS
\end{verbatim}
Here, since we are handling monthly mean data, the line starting 
with \verb/TDEF/ ends with \verb/1mo/. When the \verb/PUMA/ output is used
without averaging, this should correspond to the output interval given
by the \verb#nwpd# variable used in the \verb#namelist# of your \verb#PUMA#
run (see Appendix \ref{Namelist}). The number of variables
depends on how the Pumaburner was
called. In this example, only three variables were processed, i.e.\ the
temperature (\verb/c130/), the zonal wind (\verb/c131/) and the meridional 
wind (\verb/c132/). Refer to Appendix \ref{Pumacodes} for a list of the codes.
\\
The GrADS program is started by typing \verb/grads/ in a terminal window. 
Then, the data is displayed either by typing commands line-by-line, 
or preferably by using scripts. The following script, called \verb/tglob.gs/, 
displays the monthly mean temperature at 500hPa:
\begin{verbatim}
# tglob.gs
function pass(m)
'reinit'
'open puma_m'
'enable print print.mf'
'set t 'm
'set lev 50000'
'c'
'set gxout shaded'
'd (c130-273.16)'
'cbar.gs'
'set gxout contour'
'd (c130-273.16)'
'draw title Temperature (deg C) 500hPa month 'm
'print'
'disable print'
'!gxps -i print.mf -o tglob'm'.ps'
\end{verbatim}
The variable \verb/m/ at the beginning of the script defines the month 
which should be displayed. It is passed from the terminal with the 
script call. Note that no quotation marks are present in this line, 
since only \verb/GrADS/ specific commands are framed by quotation marks. 
Script commands, variable definitions, if-clauses, etc. are used without 
quotation marks. The script is executed by typing its name, without 
the suffix \verb/.gs/, followed by the number of the month to be shown. 
For example, \verb/tglob 7/ displays the monthly mean temperature at 500hPa
in July. The resulting output file is called \verb/tglob7.ps/. 
\par
\vspace{3mm}
The following script \verb/thh/ displays the time dependent 
temperature (in 1000hPa) of Hamburg. Here, two variables are passed to \verb/GrADS/ to plot, 
the first day and the last day. (Note that here, the file \verb/puma.gra/ 
is opened, which contains data on a daily basis). The call \verb/thh 91 180/ 
displays the temperature in 1000hPa of Hamburg for the spring season 
from April 1st to June 30th.

\begin{verbatim}
# thh.gs
function pass(d1 d2)
'reinit'
'open puma'
'enable print print.mf'
'set lat 53'
'set lon 10'
'set lev 100000'
'set t 'd1' 'd2
'c'
'd (c130-273.16)'
'draw title Temperature (deg C) 1000hPa in Hamburg'
'print'
'disable print'
'!gxps -i print.mf -o thh.ps'
\end{verbatim}

\vspace{3mm}
It is possible to have more than one figure in a plot, which is 
illustrated in the following script. It plots the seasonal means 
of the sea level pressure. The data file is prepared like this:

\begin{verbatim}
cdo selcode,151 puma.srv slp.srv    #code 151 has to be in puma.srv  
cdo seasmean slp.srv slp_sm.srv
srv2gra slp_sm.srv
\end{verbatim}

The command \verb/set vpage/ sets a virtual page inside the graphic 
window. The full window is 11 inch wide and 8.5 inch high, so 
\verb/set vpage 0 5.5 4.25 8.5/ defines the upper left corner. 
If \verb/setlevs=1/ is specified, then the pressure levels as given are used. 
Otherwise, \verb/GrADS/ defines contour levels depending on the data set.

\begin{verbatim}
# slp_sm.gs
setlevs=1
'reinit'
'open slp_sm'
'enable print print.mf'
'c'
'set vpage 0 5.5 4.25 8.5'
'set gxout contour'
if (setlevs=1)
'set clevs 990 995 1000 1005 1010 1015 1020'
endif
'set ccols 1'
'set grads off'
'set t 1'
'd c151/100'
'draw title SLP [hPa] yr 'ny' DJF'
'set vpage 5.5 11 4.25 8.5'
'set gxout contour'
if (setlevs=1)
'set clevs 990 995 1000 1005 1010 1015 1020'
endif
'set ccols 1'
'set grads off'
'set t 2'
'd c151/100'
'draw title yr 'ny' MAM'
'set vpage 0 5.5 0 4.25'
'set gxout contour'
if (setlevs=1)
'set clevs 990 995 1000 1005 1010 1015 1020'
endif
'set ccols 1'
'set grads off'
'set t 3'
'd c151/100'
'draw title yr 'ny' JJA'
'set vpage 5.5 11 0 4.25'
'set gxout contour'
if (setlevs=1)
'set clevs 990 995 1000 1005 1010 1015 1020'
endif
'set ccols 1'
'set grads off'
'set t 4'
'd c151/100'
'draw title yr 'ny' SON'
'print'
'disable print'
'!gxps -c -i print.mf -o slp_sm.ps'
\end{verbatim}
