graphics_grads.tex 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. In this section, visualisation using the graphics package GrADS is
  2. described. A useful Internet site for reference and installation
  3. instructions is
  4. \begin{quote}
  5. \verb#<http://grads.iges.org/grads/grads.html>#.
  6. \end{quote}
  7. Latest versions of \verb#GrADS# can handle data in \verb#NETCDF#
  8. format (via the command
  9. \verb#sdfopen#), \verb#GRIB#, \verb#HDF-SDS#, and in its native binary
  10. format. The native format can
  11. conveniently be derived from \verb#SERVICE# format.
  12. In the following it is assumed that the \verb/PUMA/ output has been
  13. converted to \verb#SERVICE# format with the \verb#pumaburner# and the
  14. resulting
  15. file is called \verb/puma.srv/. Monthly mean data is either obtained
  16. directly from the \verb#pumaburner# (\verb#namelist# parameter
  17. \verb#MEAN=1#, see section \ref{Pumaburner}) or via a
  18. \verb/PINGO/ command:
  19. \begin{quote}
  20. \verb/srv monmeans puma.srv puma_m.srv/
  21. \end{quote}
  22. \noindent Information on the \verb/PINGO/ package can be
  23. found in DKRZ report 11 at
  24. \begin{quote}
  25. \verb#<http://www.mad.zmaw.de/Pingo/repdl.html>#.
  26. \end{quote}
  27. The \verb#SERVICE# file has to be converted to
  28. \verb#GrADS#'s native format by the command:
  29. \begin{quote}
  30. \verb#srv2gra puma_m.srv#
  31. \end{quote}
  32. \noindent which results in the files \verb/puma_m.gra/ and
  33. \verb/puma_m.ctl/. The first file contains the data, the latter one
  34. information on the grid, time steps, and variable names. The program
  35. \verb#srv2gra# is one of the postprocessing tools available at
  36. \begin{quote}
  37. \verb#<http://puma.dkrz.de/puma/download/map/>#.
  38. \end{quote}
  39. If you chose to compile it yourself, please read the comments in the
  40. first few lines of the program text.
  41. Sometimes the
  42. \verb/srv2gra/ tool has difficulties to calculate an appropriate time
  43. increment from the date headers of the data records, so you should
  44. check this. In this example the file \verb/puma_m.ctl/ should look like this:
  45. \begin{verbatim}
  46. DSET ^puma_m.gra
  47. UNDEF 9e+09
  48. XDEF 64 LINEAR 0.0000 5.6250
  49. OPTIONS YREV
  50. YDEF 32 LEVELS
  51. -85.7606 -80.2688 -74.7445 -69.2130 -63.6786 -58.1430 -52.6065 -47.0696
  52. -41.5325 -35.9951 -30.4576 -24.9199 -19.3822 -13.8445 -8.3067 -2.7689
  53. 2.7689 8.3067 13.8445 19.3822 24.9199 30.4576 35.9951 41.5325
  54. 47.0696 52.6065 58.1430 63.6786 69.2130 74.7445 80.2688 85.7606
  55. ZDEF 1 LINEAR 1 1
  56. TDEF 12 LINEAR 00:00Z01jan0001 1mo
  57. VARS 3
  58. c139 0 99 139 0 0
  59. c151 0 99 151 0 0
  60. c175 0 99 175 0 0
  61. ENDVARS
  62. \end{verbatim}
  63. Here, the line starting with \verb/TDEF/ ends with \verb/1mo/, since
  64. we are handling monthly mean data. When the \verb/PUMA/ output is used
  65. without averaging, this should correspond to the output interval given
  66. by the \verb#nafter# variable used in the \verb#namelist# of your \verb#PUMA#
  67. run (see section \ref{Namelist}). The number of variables
  68. depends on how the pumaburner was
  69. called. In this example, only 3 variables were processed, i.e.\ the
  70. surface temperature (\verb/c139/), the sea level pressure
  71. (\verb/c151/) and the albedo (\verb/c175/; refer to appendix
  72. \ref{Pumacodes} for a list of codes).
  73. \\
  74. The GrADS program is started by typing \verb/grads/ in a terminal window. Then, data is visualised either by typing commands line-by-line, or, preferably, by using scripts. The following script, called \verb/tglob.gs/, displays the monthly mean surface temperature:
  75. \begin{verbatim}
  76. # tglob.gs
  77. function pass(m)
  78. 'reinit'
  79. 'open puma_m'
  80. 'enable print print.mf'
  81. 'set t 'm
  82. 'c'
  83. 'set gxout shaded'
  84. 'd (c139-273.16)'
  85. 'cbar.gs'
  86. 'set gxout contour'
  87. 'd (c139-273.16)'
  88. 'draw title Surface Temperature (deg C) month 'm
  89. 'print'
  90. 'disable print'
  91. '!gxps -i print.mf -o tglob'm'.ps'
  92. \end{verbatim}
  93. 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 in this line, no quotation marks are present, since only \verb/GrADS/ specific commands are framed by quotation marks. Script commands, like variable definitions, if-clauses etc. are used without quotation marks. The script is executed by typing its name without the ending and the number of the month to be shown. For example, \verb/tglob 7/ displays the monthly mean surface temperature in July. The resulting output file is called \verb/tglob7.ps/.
  94. \par
  95. \vspace{3mm}
  96. The following script \verb/thh/ displays the time dependent surface temperature of Hamburg. Here, two variables are passed to \verb/GrADS/, the first and last day to plot (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 surface temperature of Hamburg for the spring season from April 1st to June 30th.
  97. \begin{verbatim}
  98. # thh.gs
  99. function pass(d1 d2)
  100. 'reinit'
  101. 'open puma'
  102. 'enable print print.mf'
  103. 'set lat 53'
  104. 'set lon 10'
  105. 'set t 'd1' 'd2
  106. 'c'
  107. 'd (c139-273.16)'
  108. 'draw title Surface Temperature (deg C) in Hamburg'
  109. 'print'
  110. 'disable print'
  111. '!gxps -i print.mf -o thh.ps'
  112. \end{verbatim}
  113. \vspace{3mm}
  114. It is possible to have more than one figure in a plot, which is illustrated in the following script. It plots seasonal means of the sea level pressure. The data file is prepared like this:
  115. \begin{verbatim}
  116. srv selcode,151 puma.srv slp.srv
  117. srv seasmean slp.srv slp_sm.srv
  118. srv2gra slp_sm.srv
  119. \end{verbatim}
  120. The commands \verb/set vpage/ sets virtual pages 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, the pressure levels as given are used. Otherwise, \verb/GrADS/ defines contour levels depending on the data set.
  121. \begin{verbatim}
  122. # slp_sm.gs
  123. setlevs=1
  124. 'reinit'
  125. 'open slp_sm'
  126. 'enable print print.mf'
  127. 'c'
  128. 'set vpage 0 5.5 4.25 8.5'
  129. 'set gxout contour'
  130. if (setlevs=1)
  131. 'set clevs 990 995 1000 1005 1010 1015 1020'
  132. endif
  133. 'set ccols 1'
  134. 'set grads off'
  135. 'set t 1'
  136. 'd c151/100'
  137. 'draw title SLP [hPa] yr 'ny' DJF'
  138. 'set vpage 5.5 11 4.25 8.5'
  139. 'set gxout contour'
  140. if (setlevs=1)
  141. 'set clevs 990 995 1000 1005 1010 1015 1020'
  142. endif
  143. 'set ccols 1'
  144. 'set grads off'
  145. 'set t 2'
  146. 'd c151/100'
  147. 'draw title yr 'ny' MAM'
  148. 'set vpage 0 5.5 0 4.25'
  149. 'set gxout contour'
  150. if (setlevs=1)
  151. 'set clevs 990 995 1000 1005 1010 1015 1020'
  152. endif
  153. 'set ccols 1'
  154. 'set grads off'
  155. 'set t 3'
  156. 'd c151/100'
  157. 'draw title yr 'ny' JJA'
  158. 'set vpage 5.5 11 0 4.25'
  159. 'set gxout contour'
  160. if (setlevs=1)
  161. 'set clevs 990 995 1000 1005 1010 1015 1020'
  162. endif
  163. 'set ccols 1'
  164. 'set grads off'
  165. 'set t 4'
  166. 'd c151/100'
  167. 'draw title yr 'ny' SON'
  168. 'print'
  169. 'disable print'
  170. '!gxps -c -i print.mf -o slp_sm.ps'
  171. \end{verbatim}