doc/app/idl: plot_ts_palm_output.pro

File plot_ts_palm_output.pro, 11.4 KB (added by herbort, 13 years ago)
Line 
1;#######################################################################
2;# Program language: IDL (Interactive Data Language), file-ending .pro #
3;#                                                                     #
4;# This program creates png- or ps-images from netCDF-files generated  #
5;# by PALM. The images show timeseries of an available variable.       #
6;#                                                                     #
7;# Remarks:                                                            #
8;#   * Program reads netCDF files ending with *_ts.nc (PALM timeseries)#
9;#   * The input-parameters, that the program requires, have to be     #
10;#     entered in the following section "ENTER PARAMETERS".            #
11;#   * The program creates a .png or .ps image in the current directory#
12;#                                                                     #
13;#                                                   coder: F. Herbort #
14;#######################################################################
15;                                                                      #
16; ENTER PARAMETERS:                                                    #
17; =================                                                    #
18;                                                                      #
19; Host-Identifier:                                                     #
20hostid = 'lcsgih'   ;                                                  #
21;                                                                      #
22; Name of run:                                                         #
23name_of_run = 'example_cbl'   ; sub-folder of                          #
24;                               ~/palm/current_version/JOBS            #
25; Number for restart-files:                                            #
26resnum = ' '   ; (blank if no restart-file is considered)              #
27;                                                                      #
28; Path to netCDF-file:                                                 #
29netcdf_path = '/home/herbort/palm/current_version/JOBS/'+name_of_run+'/OUTPUT/' ;#
30;                                                                      #
31; Chosing desired variables (0 = no, 1 = yes):                         #
32tke_yn = 1   ; TKE                                                     #
33umax_yn = 1  ; maximum of u-wind component                             #
34vmax_yn = 1  ; maximum of v-wind component                             #
35wmax_yn = 1  ; maximum of w-wind component                             #
36ustern_yn = 1   ; u*                                                   #
37wstern_yn = 1   ; w*                                                   #
38;                                                                      #
39; kind of image (.png or .ps):                                         #
40png_yn = 1   ;                                                         #
41ps_yn = 0    ;                                                         #
42;#######################################################################
43
44PRINT, ' '
45PRINT, '==========================================================='
46PRINT, 'Program creates images from netCDF-files generated by PALM.'
47PRINT, 'The images show timeseries of different variables.         '
48PRINT, '                                               [F. Herbort]'
49PRINT, '==========================================================='
50PRINT, ' '
51
52;=======================================================================
53; Constants and parameters:
54; -------------------------
55
56kind_data = 'ts'
57
58plotfile1 = 'E_'+name_of_run+'_idl_ts'
59plotfile2 = 'umax_'+name_of_run+'_idl_ts'
60plotfile3 = 'vmax_'+name_of_run+'_idl_ts'
61plotfile4 = 'wmax_'+name_of_run+'_idl_ts'
62plotfile5 = 'us_'+name_of_run+'_idl_ts'
63plotfile6 = 'ws_'+name_of_run+'_idl_ts'
64
65;=======================================================================
66; Checking existence of file:
67; ---------------------------
68
69IF resnum EQ ' ' THEN datafile = hostid+'_'+name_of_run+'_'+kind_data+'.nc'
70IF resnum NE ' ' THEN datafile = hostid+'_'+name_of_run+'_'+kind_data+'.'+resnum+'.nc'
71input = netcdf_path+datafile
72
73fileyn = FILE_TEST(input)
74
75; Checking, wether filename is without hostid at the beginning of filename:
76IF fileyn EQ 0L THEN BEGIN
77IF resnum EQ ' ' THEN datafile = name_of_run+'_'+kind_data+'.nc'
78IF resnum NE ' ' THEN datafile = name_of_run+'_'+kind_data+'.'+resnum+'.nc'
79input = netcdf_path+datafile
80fileyn = FILE_TEST(input)
81ENDIF
82
83IF fileyn EQ 0L THEN BEGIN
84PRINT, 'netCDF-file does not exist!'
85PRINT, 'Program aborted'
86PRINT, ' '
87GOTO, abort_flag
88ENDIF
89
90;=======================================================================
91; Reading the profile data from netCDF-file:
92; ------------------------------------------
93
94nid = NCDF_OPEN(input)
95
96NCDF_VARGET, nid, 'time', time
97IF tke_yn NE 0 THEN NCDF_VARGET, nid, 'E', tke
98IF umax_yn NE 0 THEN NCDF_VARGET, nid, 'umax', umax
99IF vmax_yn NE 0 THEN NCDF_VARGET, nid, 'vmax', vmax
100IF wmax_yn NE 0 THEN NCDF_VARGET, nid, 'wmax', wmax
101IF ustern_yn NE 0 THEN NCDF_VARGET, nid, 'u*', ustern
102IF wstern_yn NE 0 THEN NCDF_VARGET, nid, 'w*', wstern
103
104NCDF_CLOSE, nid
105
106PRINT, 'timeseries data read in'
107PRINT, ' '
108
109;=======================================================================
110; Plotting the data:
111; ------------------
112
113SET_PLOT, 'Z'
114DEVICE, Z_BUFFERING = 0, SET_RESOLUTION=[1200,900]
115SET_COLORS=256
116
117LOADCT, 0
118TVLCT, R,G,B, /GET
119
120!P.CHARSIZE = 2.3
121!P.CHARTHICK = 2.3
122!X.THICK = 3.0
123!Y.THICK = 3.0
124!X.TICKLEN = 0.025
125!Y.TICKLEN = 0.01
126
127black = 0
128white = 255
129!P.BACKGROUND = white
130
131plot_window = [0.12,0.10,0.96,0.99]
132
133; .ps-preferences, if desired:
134IF ps_yn NE 0 THEN BEGIN
135SET_PLOT, 'PS'
136PRINT, 'Postscript-Format (.ps) selected'
137PRINT, ''
138;Farbeinstellungen, Format etc.:
139;DEVICE, /COLOR, BITS = 8, ENCAPSULATED = 1, /ISOLATIN1, /PORTRAIT
140;DEVICE, FILENAME = plotpath+plotfile+'.eps'
141DEVICE, /COLOR, BITS = 8, ENCAPSULATED = 0, /ISOLATIN1, /LANDSCAPE
142;DEVICE, SCALE_FACTOR = 1.0, XOFFSET = 1.0, YOFFSET = 1.0
143!P.CHARSIZE = 1.5
144!P.CHARTHICK = 1.5
145;plot_window = [0.095,0.225,0.97,0.99]
146ENDIF
147
148; Determining time ranges of the plot (x-axis):
149IF MAX(time) LE 18000.0 THEN BEGIN
150x_min = FLOOR(MIN(time)/1800.0)*1800.0
151x_max = CEIL(MAX(time)/1800.0)*1800.0
152x_inter = 1800.0
153x_minor = 6
154ENDIF
155IF MAX(time) GT 18000.0 THEN BEGIN
156x_min = FLOOR(MIN(time)/3600.0)*3600.0
157x_max = CEIL(MAX(time)/3600.0)*3600.0
158x_inter = 3600.0
159x_minor = 6
160ENDIF
161
162IF tke_yn NE 0 THEN BEGIN   ; tke
163
164IF ps_yn NE 0 THEN DEVICE, FILENAME = plotfile1+'.ps'
165
166; Determining y-axis ranges:
167y_min = 0.0
168IF MAX(tke) LE 1.0 THEN BEGIN
169y_max = CEIL(MAX(tke)/0.1)*0.1
170y_inter = 0.1
171y_minor = 2
172ENDIF
173IF MAX(tke) GT 1.0 THEN BEGIN
174y_max = CEIL(MAX(tke)/0.5)*0.5
175y_inter = 0.5
176y_minor = 5
177ENDIF
178
179; Plotting:
180PLOT, time, tke, COLOR = black, XRANGE = [x_min,x_max], YRANGE = [y_min,y_max], $
181XMINOR = x_minor, YMINOR = y_minor, XTITLE = 'time [s]', YTITLE = 'TKE [m!U2!N/s!U2!N]', $
182XTICKINTERVAL = x_inter, YTICKINTERVAL = y_inter, POSITION = plot_window, $
183XSTYLE = 1, YSTYLE = 1, LINESTYLE = 0, XTICKFORMAT = '(I5)', YTICKFORMAT = '(F4.1)'
184
185IF png_yn NE 0 THEN BEGIN
186DATA = TVRD()
187WRITE_PNG, plotfile1+'.png', DATA, r, g, b
188PRINT, 'png-image of timeseries of "E" created'
189;PRINT, ' '
190ENDIF
191
192DEVICE, /CLOSE
193ENDIF
194
195IF umax_yn NE 0 THEN BEGIN   ; umax
196
197IF ps_yn NE 0 THEN DEVICE, FILENAME = plotfile2+'.ps'
198
199; Determining y-axis ranges:
200IF MAX([MAX(umax),ABS(MIN(umax))]) LE 10.0 THEN BEGIN
201y_max = CEIL(MAX([MAX(umax),ABS(MIN(umax))])/1.0)*1.0
202;y_min = -y_max
203y_inter = 1.0
204y_minor = 2
205ENDIF
206IF MAX([MAX(umax),ABS(MIN(umax))]) GT 10.0 THEN BEGIN
207y_max = CEIL(MAX([MAX(umax),ABS(MIN(umax))])/2.0)*2.0
208;y_min = -y_max
209y_inter = 2.0
210y_minor = 4
211ENDIF
212y_min = -y_max
213
214; Plotting:
215PLOT, time, umax, COLOR = black, XRANGE = [x_min,x_max], YRANGE = [y_min,y_max], $
216XMINOR = x_minor, YMINOR = y_minor, XTITLE = 'time [s]', YTITLE = 'max. of u-wind [m/s]', $
217XTICKINTERVAL = x_inter, YTICKINTERVAL = y_inter, POSITION = plot_window, $
218XSTYLE = 1, YSTYLE = 1, LINESTYLE = 0, XTICKFORMAT = '(I5)', YTICKFORMAT = '(F5.1)'
219
220PLOTS, [x_min,x_max], [0.0,0.0], COLOR = black, LINESTYLE = 2
221
222IF png_yn NE 0 THEN BEGIN
223DATA = TVRD()
224WRITE_PNG, plotfile2+'.png', DATA, r, g, b
225PRINT, 'png-image of timeseries of "umax" created'
226;PRINT, ' '
227ENDIF
228
229DEVICE, /CLOSE
230ENDIF
231
232IF vmax_yn NE 0 THEN BEGIN   ; vmax
233
234IF ps_yn NE 0 THEN DEVICE, FILENAME = plotfile3+'.ps'
235
236; Determining y-axis ranges:
237IF MAX([MAX(vmax),ABS(MIN(vmax))]) LE 10.0 THEN BEGIN
238y_max = CEIL(MAX([MAX(vmax),ABS(MIN(vmax))])/1.0)*1.0
239;y_min = -y_max
240y_inter = 1.0
241y_minor = 2
242ENDIF
243IF MAX([MAX(vmax),ABS(MIN(vmax))]) GT 10.0 THEN BEGIN
244y_max = CEIL(MAX([MAX(vmax),ABS(MIN(vmax))])/2.0)*2.0
245;y_min = -y_max
246y_inter = 2.0
247y_minor = 4
248ENDIF
249y_min = -y_max
250
251; Plotting:
252PLOT, time, vmax, COLOR = black, XRANGE = [x_min,x_max], YRANGE = [y_min,y_max], $
253XMINOR = x_minor, YMINOR = y_minor, XTITLE = 'time [s]', YTITLE = 'max. of v-wind [m/s]', $
254XTICKINTERVAL = x_inter, YTICKINTERVAL = y_inter, POSITION = plot_window, $
255XSTYLE = 1, YSTYLE = 1, LINESTYLE = 0, XTICKFORMAT = '(I5)', YTICKFORMAT = '(F5.1)'
256
257PLOTS, [x_min,x_max], [0.0,0.0], COLOR = black, LINESTYLE = 2
258
259IF png_yn NE 0 THEN BEGIN
260DATA = TVRD()
261WRITE_PNG, plotfile3+'.png', DATA, r, g, b
262PRINT, 'png-image of timeseries of "vmax" created'
263;PRINT, ' '
264ENDIF
265
266DEVICE, /CLOSE
267ENDIF
268
269IF wmax_yn NE 0 THEN BEGIN   ; wmax
270
271IF ps_yn NE 0 THEN DEVICE, FILENAME = plotfile4+'.ps'
272
273; Determining y-axis ranges:
274y_min = FLOOR(MIN(wmax)/1.0)*1.0
275y_max = CEIL(MAX(wmax)/1.0)*1.0
276y_inter = 1.0
277y_minor = 2
278
279; Plotting:
280PLOT, time, wmax, COLOR = black, XRANGE = [x_min,x_max], YRANGE = [y_min,y_max], $
281XMINOR = x_minor, YMINOR = y_minor, XTITLE = 'time [s]', YTITLE = 'max. of w-wind [m/s]', $
282XTICKINTERVAL = x_inter, YTICKINTERVAL = y_inter, POSITION = plot_window, $
283XSTYLE = 1, YSTYLE = 1, LINESTYLE = 0, XTICKFORMAT = '(I5)', YTICKFORMAT = '(F5.1)'
284
285PLOTS, [x_min,x_max], [0.0,0.0], COLOR = black, LINESTYLE = 2
286
287IF png_yn NE 0 THEN BEGIN
288DATA = TVRD()
289WRITE_PNG, plotfile4+'.png', DATA, r, g, b
290PRINT, 'png-image of timeseries of "wmax" created'
291;PRINT, ' '
292ENDIF
293
294DEVICE, /CLOSE
295ENDIF
296
297IF ustern_yn NE 0 THEN BEGIN   ; u*
298
299IF ps_yn NE 0 THEN DEVICE, FILENAME = plotfile5+'.ps'
300
301; Determining y-axis ranges:
302y_min = FLOOR(MIN(ustern)/0.1)*0.1
303y_max = CEIL(MAX(ustern)/0.1)*0.1
304y_inter = 0.1
305y_minor = 2
306
307; Plotting:
308PLOT, time, ustern, COLOR = black, XRANGE = [x_min,x_max], YRANGE = [y_min,y_max], $
309XMINOR = x_minor, YMINOR = y_minor, XTITLE = 'time [s]', YTITLE = 'u* [m/s]', $
310XTICKINTERVAL = x_inter, YTICKINTERVAL = y_inter, POSITION = plot_window, $
311XSTYLE = 1, YSTYLE = 1, LINESTYLE = 0, XTICKFORMAT = '(I5)', YTICKFORMAT = '(F3.1)'
312
313IF png_yn NE 0 THEN BEGIN
314DATA = TVRD()
315WRITE_PNG, plotfile5+'.png', DATA, r, g, b
316PRINT, 'png-image of timeseries of "u*" created'
317;PRINT, ' '
318ENDIF
319
320DEVICE, /CLOSE
321ENDIF
322
323IF wstern_yn NE 0 THEN BEGIN   ; w*
324
325IF ps_yn NE 0 THEN DEVICE, FILENAME = plotfile6+'.ps'
326
327; Determining y-axis ranges:
328y_min = FLOOR(MIN(wstern)/0.5)*0.5
329y_max = CEIL(MAX(wstern)/0.5)*0.5
330y_inter = 0.5
331y_minor = 5
332
333; Plotting:
334PLOT, time, wstern, COLOR = black, XRANGE = [x_min,x_max], YRANGE = [y_min,y_max], $
335XMINOR = x_minor, YMINOR = y_minor, XTITLE = 'time [s]', YTITLE = 'w* [m/s]', $
336XTICKINTERVAL = x_inter, YTICKINTERVAL = y_inter, POSITION = plot_window, $
337XSTYLE = 1, YSTYLE = 1, LINESTYLE = 0, XTICKFORMAT = '(I5)', YTICKFORMAT = '(F3.1)'
338
339IF png_yn NE 0 THEN BEGIN
340DATA = TVRD()
341WRITE_PNG, plotfile6+'.png', DATA, r, g, b
342PRINT, 'png-image of timeseries of "w*" created'
343;PRINT, ' '
344ENDIF
345
346DEVICE, /CLOSE
347ENDIF
348
349PRINT, ' '
350PRINT, 'Program finished'
351abort_flag:
352PRINT, ' '
353
354
355END