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 xz cross sections of an available variable.# |
---|
6 | ;# # |
---|
7 | ;# Remarks: # |
---|
8 | ;# * Program reads netCDF files ending with *_xz.nc (PALM xz slices) # |
---|
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: # |
---|
20 | hostid = 'lcsgih' ; # |
---|
21 | ; # |
---|
22 | ; Name of run: # |
---|
23 | name_of_run = 'example_cbl' ; sub-folder of # |
---|
24 | ; ~/palm/current_version/JOBS # |
---|
25 | ; Number for restart-files: # |
---|
26 | resnum = ' ' ; (blank if no restart-file is considered) # |
---|
27 | ; # |
---|
28 | ; Path to netCDF-file: # |
---|
29 | netcdf_path = '/home/herbort/palm/current_version/JOBS/'+name_of_run+'/OUTPUT/' ;# |
---|
30 | ; # |
---|
31 | ; Point of time [s]: # |
---|
32 | t_point = 3604 ; # |
---|
33 | ; # |
---|
34 | ; Chosing desired variables (0 = no, 1 = yes): # |
---|
35 | pt_yn = 1 ; potential temperature # |
---|
36 | w_yn = 1 ; vertical wind velocity # |
---|
37 | ; # |
---|
38 | ; time-averaged data? (0 = no, 1 = yes): # |
---|
39 | av_yn = 0 ; # |
---|
40 | ; # |
---|
41 | ; isotropic x- and z-axis? (0 = no, 1 = yes): # |
---|
42 | iso_yn = 0 ; # |
---|
43 | ; # |
---|
44 | ; kind of image (.png or .ps): # |
---|
45 | png_yn = 1 ; # |
---|
46 | ps_yn = 0 ; # |
---|
47 | ;####################################################################### |
---|
48 | |
---|
49 | PRINT, ' ' |
---|
50 | PRINT, '===========================================================' |
---|
51 | PRINT, 'Program creates images from netCDF-files generated by PALM.' |
---|
52 | PRINT, 'The images show xz cross sections of different variables. ' |
---|
53 | PRINT, ' [F. Herbort]' |
---|
54 | PRINT, '===========================================================' |
---|
55 | PRINT, ' ' |
---|
56 | |
---|
57 | ;======================================================================= |
---|
58 | ; Constants and parameters: |
---|
59 | ; ------------------------- |
---|
60 | |
---|
61 | IF av_yn EQ 0 THEN kind_data = 'xz' |
---|
62 | IF av_yn NE 0 THEN kind_data = 'xz_av' |
---|
63 | |
---|
64 | ;======================================================================= |
---|
65 | ; Checking existence of file: |
---|
66 | ; --------------------------- |
---|
67 | |
---|
68 | IF resnum EQ ' ' THEN datafile = hostid+'_'+name_of_run+'_'+kind_data+'.nc' |
---|
69 | IF resnum NE ' ' THEN datafile = hostid+'_'+name_of_run+'_'+kind_data+'.'+resnum+'.nc' |
---|
70 | input = netcdf_path+datafile |
---|
71 | |
---|
72 | fileyn = FILE_TEST(input) |
---|
73 | |
---|
74 | ; Checking, wether filename is without hostid at the beginning of filename: |
---|
75 | IF fileyn EQ 0L THEN BEGIN |
---|
76 | IF resnum EQ ' ' THEN datafile = name_of_run+'_'+kind_data+'.nc' |
---|
77 | IF resnum NE ' ' THEN datafile = name_of_run+'_'+kind_data+'.'+resnum+'.nc' |
---|
78 | input = netcdf_path+datafile |
---|
79 | fileyn = FILE_TEST(input) |
---|
80 | ENDIF |
---|
81 | |
---|
82 | IF fileyn EQ 0L THEN BEGIN |
---|
83 | PRINT, 'netCDF-file does not exist!' |
---|
84 | PRINT, 'Program aborted' |
---|
85 | PRINT, ' ' |
---|
86 | GOTO, abort_flag |
---|
87 | ENDIF |
---|
88 | |
---|
89 | ;======================================================================= |
---|
90 | ; Reading the profile data from netCDF-file: |
---|
91 | ; ------------------------------------------ |
---|
92 | |
---|
93 | nid = NCDF_OPEN(input) |
---|
94 | |
---|
95 | NCDF_VARGET, nid, 'time', time |
---|
96 | NCDF_VARGET, nid, 'x', x_vals |
---|
97 | NCDF_VARGET, nid, 'zu', zu_vals |
---|
98 | NCDF_VARGET, nid, 'zw', zw_vals |
---|
99 | NCDF_VARGET, nid, 'y_xz', y_xz |
---|
100 | IF pt_yn NE 0 THEN NCDF_VARGET, nid, 'pt_xz', pt |
---|
101 | IF w_yn NE 0 THEN NCDF_VARGET, nid, 'w_xz', w |
---|
102 | |
---|
103 | NCDF_CLOSE, nid |
---|
104 | |
---|
105 | PRINT, 'xz data read in' |
---|
106 | PRINT, ' ' |
---|
107 | |
---|
108 | ; Determing horizontal and vertical dimensions: |
---|
109 | res = SIZE(x_vals, /DIMENSION) |
---|
110 | nx = res(0) |
---|
111 | res = SIZE(zu_vals, /DIMENSION) |
---|
112 | nz = res(0) |
---|
113 | res = SIZE(y_xz, /DIMENSION) |
---|
114 | nsl = res(0) |
---|
115 | |
---|
116 | ;======================================================================= |
---|
117 | ; Finding the time point: |
---|
118 | ; ----------------------- |
---|
119 | |
---|
120 | tt = WHERE(ROUND(time) EQ FIX(t_point)) |
---|
121 | |
---|
122 | IF tt(0) EQ -1 THEN tt = WHERE(FIX(t_point) - 1 EQ ROUND(time)) |
---|
123 | IF tt(0) EQ -1 THEN tt = WHERE(FIX(t_point) + 1 EQ ROUND(time)) |
---|
124 | IF tt(0) EQ -1 THEN tt = WHERE(FIX(t_point) - 2 EQ ROUND(time)) |
---|
125 | IF tt(0) EQ -1 THEN tt = WHERE(FIX(t_point) + 2 EQ ROUND(time)) |
---|
126 | |
---|
127 | IF tt(0) EQ -1 THEN BEGIN |
---|
128 | PRINT, 'Desired time point not possible!' |
---|
129 | PRINT, 'Program aborted' |
---|
130 | PRINT, ' ' |
---|
131 | GOTO, abort_flag |
---|
132 | ENDIF |
---|
133 | |
---|
134 | tt = tt(0) |
---|
135 | |
---|
136 | time_sec = STRING(time(tt), FORMAT = '(I5.5)') |
---|
137 | |
---|
138 | ;======================================================================= |
---|
139 | ; Choosing the xz-slice: |
---|
140 | ; ---------------------- |
---|
141 | |
---|
142 | IF nsl GT 1 THEN BEGIN |
---|
143 | PRINT, nsl, ' xz-slices exist:', FORMAT = '(I2,A17)' |
---|
144 | PRINT, '-------------------' |
---|
145 | FOR aa = 0, nsl - 1 DO BEGIN |
---|
146 | PRINT, aa+1, ' ', y_xz(aa), ' m', FORMAT = '(I2,A1,F7.1,A2)' |
---|
147 | ENDFOR |
---|
148 | PRINT, ' ' |
---|
149 | slice_flag: |
---|
150 | PRINT, 'Choose a slice (type 1 for slice 1, 2 for slice 2, ...):' |
---|
151 | READ, sl |
---|
152 | IF (sl GT nsl) OR (sl LT 1) THEN BEGIN |
---|
153 | PRINT, 'Type a number between 1 and ', nsl, FORMAT = '(A28,I2)' |
---|
154 | GOTO, slice_flag |
---|
155 | ENDIF |
---|
156 | PRINT, ' ' |
---|
157 | sl = FIX(sl) - 1 |
---|
158 | slice_txt = STRING(y_xz(sl), FORMAT = '(I5.5)') |
---|
159 | slice_txt = slice_txt+'m' |
---|
160 | IF y_xz(sl) EQ -1.0 THEN slice_txt = 'yav' |
---|
161 | ENDIF |
---|
162 | |
---|
163 | IF nsl LE 1 THEN BEGIN |
---|
164 | sl = 0 |
---|
165 | slice_txt = STRING(y_xz, FORMAT = '(I5.5)') |
---|
166 | ENDIF |
---|
167 | |
---|
168 | ;======================================================================= |
---|
169 | ; Plotting the data: |
---|
170 | ; ------------------ |
---|
171 | |
---|
172 | SET_PLOT, 'Z' |
---|
173 | DEVICE, Z_BUFFERING = 0, SET_RESOLUTION=[1200,900] |
---|
174 | SET_COLORS=256 |
---|
175 | |
---|
176 | LOADCT, 0 |
---|
177 | TVLCT, R,G,B, /GET |
---|
178 | |
---|
179 | !P.CHARSIZE = 2.3 |
---|
180 | !P.CHARTHICK = 2.3 |
---|
181 | !X.THICK = 3.0 |
---|
182 | !Y.THICK = 3.0 |
---|
183 | !X.TICKLEN = 0.025 |
---|
184 | !Y.TICKLEN = 0.01 |
---|
185 | |
---|
186 | black = 0 |
---|
187 | white = 255 |
---|
188 | !P.BACKGROUND = white |
---|
189 | |
---|
190 | plot_window = [0.12,0.10,0.96,0.99] |
---|
191 | |
---|
192 | ; .ps-preferences, if desired: |
---|
193 | IF ps_yn NE 0 THEN BEGIN |
---|
194 | SET_PLOT, 'PS' |
---|
195 | PRINT, 'Postscript-Format (.ps) selected' |
---|
196 | PRINT, '' |
---|
197 | ;Farbeinstellungen, Format etc.: |
---|
198 | ;DEVICE, /COLOR, BITS = 8, ENCAPSULATED = 1, /ISOLATIN1, /PORTRAIT |
---|
199 | ;DEVICE, FILENAME = plotpath+plotfile+'.eps' |
---|
200 | DEVICE, /COLOR, BITS = 8, ENCAPSULATED = 0, /ISOLATIN1, /LANDSCAPE |
---|
201 | ;DEVICE, SCALE_FACTOR = 1.0, XOFFSET = 1.0, YOFFSET = 1.0 |
---|
202 | !P.CHARSIZE = 1.5 |
---|
203 | !P.CHARTHICK = 1.5 |
---|
204 | ;plot_window = [0.095,0.225,0.97,0.99] |
---|
205 | c_char_size = 1.1 |
---|
206 | c_char_thick = 1.0 |
---|
207 | ENDIF |
---|
208 | |
---|
209 | ; Determining x- and z-ranges of the plot: |
---|
210 | x_min = FLOOR(MIN(x_vals)/100.0)*100.0 |
---|
211 | x_max = FLOOR(MAX(x_vals)/100.0)*100.0 |
---|
212 | IF x_max LE 5000.0 THEN BEGIN |
---|
213 | x_inter = 500.0 |
---|
214 | x_minor = 5 |
---|
215 | ENDIF |
---|
216 | IF x_max GT 5000.0 THEN BEGIN |
---|
217 | x_inter = 1000.0 |
---|
218 | x_minor = 2 |
---|
219 | ENDIF |
---|
220 | IF x_max GT 10000.0 THEN BEGIN |
---|
221 | x_inter = 5000.0 |
---|
222 | x_minor = 5 |
---|
223 | ENDIF |
---|
224 | |
---|
225 | z_min = FLOOR(MIN(zu_vals)/100.0)*100.0 |
---|
226 | z_max = FLOOR(MAX(zu_vals)/100.0)*100.0 |
---|
227 | z_inter = 500.0 |
---|
228 | z_minor = 5 |
---|
229 | |
---|
230 | IF pt_yn NE 0 THEN BEGIN ; pt |
---|
231 | |
---|
232 | IF av_yn EQ 0 THEN plotfile = 'pt_'+slice_txt+'_'+time_sec+'s_'+name_of_run+'_idl_xz' |
---|
233 | IF av_yn NE 0 THEN plotfile = 'pt_av_'+slice_txt+'_'+time_sec+'s_'+name_of_run+'_idl_xz' |
---|
234 | |
---|
235 | IF ps_yn NE 0 THEN DEVICE, FILENAME = plotfile+'.ps' |
---|
236 | |
---|
237 | c_levs = FINDGEN(101)*1.0 + 240.0 ; Contours every 1 K |
---|
238 | c_labs = INTARR(101) |
---|
239 | c_labs(*) = 1 |
---|
240 | pt_xz = FLTARR(nx,nz) |
---|
241 | pt_xz(*,*) = pt(*,sl,*,tt) |
---|
242 | IF iso_yn NE 0 THEN iso_yn = 1 |
---|
243 | IF png_yn NE 0 THEN BEGIN |
---|
244 | c_char_size = 1.5 |
---|
245 | c_char_thick = 1.0 |
---|
246 | ENDIF |
---|
247 | |
---|
248 | ; Plotting: |
---|
249 | CONTOUR, pt_xz, x_vals, zu_vals, COLOR = black, XRANGE = [x_min,x_max], YRANGE = [z_min,z_max], $ |
---|
250 | XMINOR = x_minor, YMINOR = z_minor, XTITLE = 'x [m]', YTITLE = 'altitude [m]', $ |
---|
251 | XTICKINTERVAL = x_inter, YTICKINTERVAL = z_inter, POSITION = plot_window, $ |
---|
252 | XSTYLE = 1, YSTYLE = 1, XTICKFORMAT = '(I5)', YTICKFORMAT = '(I4)', LEVELS = c_levs, C_LABELS = c_labs, $ |
---|
253 | C_CHARSIZE = c_char_size, C_CHARTHICK = c_char_thick, ISOTROPIC = iso_yn |
---|
254 | |
---|
255 | IF png_yn NE 0 THEN BEGIN |
---|
256 | DATA = TVRD() |
---|
257 | WRITE_PNG, plotfile+'.png', DATA, r, g, b |
---|
258 | PRINT, 'png-image of xz cross section of "pt" created' |
---|
259 | ;PRINT, ' ' |
---|
260 | ENDIF |
---|
261 | |
---|
262 | DEVICE, /CLOSE |
---|
263 | ENDIF |
---|
264 | |
---|
265 | IF w_yn NE 0 THEN BEGIN ; w |
---|
266 | |
---|
267 | IF av_yn EQ 0 THEN plotfile = 'w_'+slice_txt+'_'+time_sec+'s_'+name_of_run+'_idl_xz' |
---|
268 | IF av_yn NE 0 THEN plotfile = 'w_av_'+slice_txt+'_'+time_sec+'s_'+name_of_run+'_idl_xz' |
---|
269 | |
---|
270 | IF ps_yn NE 0 THEN DEVICE, FILENAME = plotfile+'.ps' |
---|
271 | |
---|
272 | c_levs_m = FINDGEN(60)*0.2 - 12.0 ; Contours every 0.2 m/s |
---|
273 | c_levs_p = FINDGEN(60)*0.2 + 0.2 |
---|
274 | c_levs = [c_levs_m,c_levs_p] |
---|
275 | c_labs = INTARR(120) |
---|
276 | c_labs(*) = 1 |
---|
277 | c_lines = INTARR(120) |
---|
278 | c_lines(0:59) = 1 |
---|
279 | c_lines(60:119) = 0 |
---|
280 | w_xz = FLTARR(nx,nz) |
---|
281 | w_xz(*,*) = w(*,sl,*,tt) |
---|
282 | IF iso_yn NE 0 THEN iso_yn = 1 |
---|
283 | IF png_yn NE 0 THEN BEGIN |
---|
284 | c_char_size = 1.5 |
---|
285 | c_char_thick = 1.0 |
---|
286 | ENDIF |
---|
287 | |
---|
288 | ; Plotting: |
---|
289 | CONTOUR, w_xz, x_vals, zu_vals, COLOR = black, XRANGE = [x_min,x_max], YRANGE = [z_min,z_max], $ |
---|
290 | XMINOR = x_minor, YMINOR = z_minor, XTITLE = 'x [m]', YTITLE = 'altitude [m]', $ |
---|
291 | XTICKINTERVAL = x_inter, YTICKINTERVAL = z_inter, POSITION = plot_window, $ |
---|
292 | XSTYLE = 1, YSTYLE = 1, XTICKFORMAT = '(I5)', YTICKFORMAT = '(I4)', LEVELS = c_levs, C_LABELS = c_labs, $ |
---|
293 | C_CHARSIZE = c_char_size, C_CHARTHICK = c_char_thick, C_LINESTYLE = c_lines, ISOTROPIC = iso_yn |
---|
294 | |
---|
295 | IF png_yn NE 0 THEN BEGIN |
---|
296 | DATA = TVRD() |
---|
297 | WRITE_PNG, plotfile+'.png', DATA, r, g, b |
---|
298 | PRINT, 'png-image of xz cross section of "w" created' |
---|
299 | ;PRINT, ' ' |
---|
300 | ENDIF |
---|
301 | |
---|
302 | DEVICE, /CLOSE |
---|
303 | ENDIF |
---|
304 | |
---|
305 | PRINT, ' ' |
---|
306 | PRINT, 'Program finished' |
---|
307 | abort_flag: |
---|
308 | PRINT, ' ' |
---|
309 | |
---|
310 | |
---|
311 | END |
---|