1 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" |
---|
2 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" |
---|
3 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" |
---|
4 | |
---|
5 | ;*************************************************** |
---|
6 | ; load .ncl.config or .ncl.config.default |
---|
7 | ;*************************************************** |
---|
8 | |
---|
9 | function which_script() |
---|
10 | local script |
---|
11 | begin |
---|
12 | script="spectra" |
---|
13 | return(script) |
---|
14 | end |
---|
15 | |
---|
16 | if (isfilepresent("$PALM_BIN/../../.ncl.config")) then |
---|
17 | loadscript("$PALM_BIN/../../.ncl.config") |
---|
18 | else |
---|
19 | if (isfilepresent("$PALM_BIN/NCL/.ncl.config.default")) then |
---|
20 | loadscript( "$PALM_BIN/NCL/.ncl.config.default") |
---|
21 | else |
---|
22 | palm_bin_path = getenv("PALM_BIN") |
---|
23 | print(" ") |
---|
24 | print("Neither the personal configuration file '.ncl.config' exists in") |
---|
25 | print("~/palm/current_version") |
---|
26 | print("nor the default configuration file '.ncl.config.default' "+\ |
---|
27 | "exists in") |
---|
28 | print(palm_bin_path + "/NCL") |
---|
29 | print(" ") |
---|
30 | exit |
---|
31 | end if |
---|
32 | end if |
---|
33 | |
---|
34 | begin |
---|
35 | |
---|
36 | ;*************************************************** |
---|
37 | ; Retrieving the NCL version used |
---|
38 | ;*************************************************** |
---|
39 | |
---|
40 | ncl_version_ch = systemfunc("ncl -V") |
---|
41 | ncl_version = stringtofloat(ncl_version_ch) |
---|
42 | |
---|
43 | ;*************************************************** |
---|
44 | ; Retrieving the double quote character |
---|
45 | ;*************************************************** |
---|
46 | |
---|
47 | dq=str_get_dq() |
---|
48 | |
---|
49 | ;*************************************************** |
---|
50 | ; set up default parameter values and strings |
---|
51 | ;*************************************************** |
---|
52 | |
---|
53 | if (file_1 .EQ. "File in") then |
---|
54 | print(" ") |
---|
55 | print("Declare input file 'file_1=' in '.ncl.config' or prompt") |
---|
56 | print(" ") |
---|
57 | exit |
---|
58 | else |
---|
59 | file_in = file_1 |
---|
60 | end if |
---|
61 | |
---|
62 | if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND. \ |
---|
63 | format_out .NE. "eps" .AND. format_out .NE. "ps" .AND. \ |
---|
64 | format_out .NE. "epsi" .AND. format_out .NE. "ncgm" .AND. \ |
---|
65 | format_out .NE. "png")then |
---|
66 | print(" ") |
---|
67 | print("'format_out = "+format_out+"' is invalid and set to'x11'") |
---|
68 | print(" ") |
---|
69 | format_out="x11" |
---|
70 | end if |
---|
71 | |
---|
72 | if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then |
---|
73 | print(" ") |
---|
74 | print("Output of png files not available") |
---|
75 | print("png output is avaiable with NCL version 5.2.0 and higher ") |
---|
76 | print("NCL version used: " + ncl_version_ch) |
---|
77 | print(" ") |
---|
78 | exit |
---|
79 | end if |
---|
80 | |
---|
81 | if (log_x .NE. 0 .AND. log_x .NE. 1)then |
---|
82 | print(" ") |
---|
83 | print("'log_x'= "+log_x+" is invalid and set to 1") |
---|
84 | print(" ") |
---|
85 | log_x = 1 |
---|
86 | end if |
---|
87 | |
---|
88 | if (log_y .NE. 0 .AND. log_y .NE. 1)then |
---|
89 | print(" ") |
---|
90 | print("'log_y'= "+log_y+" is invalid and set to 1") |
---|
91 | print(" ") |
---|
92 | log_y = 1 |
---|
93 | end if |
---|
94 | |
---|
95 | if (norm_y .EQ. 0.) then |
---|
96 | print(" ") |
---|
97 | print("Normalising with 0 is not allowed, 'norm_y' is set to 1.0") |
---|
98 | print(" ") |
---|
99 | norm_y = 1.0 |
---|
100 | end if |
---|
101 | if (norm_x .EQ. 0.) then |
---|
102 | print(" ") |
---|
103 | print("Normalising with 0 is not allowed, 'norm_x' is set to 1.0") |
---|
104 | print(" ") |
---|
105 | norm_x= 1.0 |
---|
106 | end if |
---|
107 | |
---|
108 | if (sort .NE. "height" .AND. sort .NE. "time") then |
---|
109 | print(" ") |
---|
110 | print("'sort'= "+sort+" is invalid and set to 'height'") |
---|
111 | print(" ") |
---|
112 | sort = "height" |
---|
113 | end if |
---|
114 | |
---|
115 | if (black .NE. 0 .AND. black .NE. 1)then |
---|
116 | print(" ") |
---|
117 | print("'black'= "+black+" is invalid and set to 0") |
---|
118 | print(" ") |
---|
119 | black = 0 |
---|
120 | end if |
---|
121 | |
---|
122 | if (dash .NE. 0 .AND. dash .NE. 1)then |
---|
123 | print(" ") |
---|
124 | print("'dash'= "+dash+" is invalid and set to 0") |
---|
125 | print(" ") |
---|
126 | dash = 0 |
---|
127 | end if |
---|
128 | |
---|
129 | ;*************************************************** |
---|
130 | ; open input file |
---|
131 | ;*************************************************** |
---|
132 | |
---|
133 | file_in_1 = False |
---|
134 | if (isStrSubset(file_in, ".nc"))then |
---|
135 | start_f = -2 |
---|
136 | end_f = -2 |
---|
137 | file_in_1 = True |
---|
138 | end if |
---|
139 | |
---|
140 | if (start_f .EQ. -1)then |
---|
141 | print(" ") |
---|
142 | print("'start_f' must be one of the cyclic numbers (at least 0) of "+\ |
---|
143 | "your input file(s)") |
---|
144 | print(" ") |
---|
145 | exit |
---|
146 | end if |
---|
147 | if (end_f .EQ. -1)then |
---|
148 | print(" ") |
---|
149 | print("'end_f' must be one of the cyclic numbers (at least 0) of "+\ |
---|
150 | "your input file(s)") |
---|
151 | print(" ") |
---|
152 | exit |
---|
153 | end if |
---|
154 | |
---|
155 | files=new(end_f-start_f+1,string) |
---|
156 | |
---|
157 | if (file_in_1)then |
---|
158 | if (isfilepresent(file_in))then |
---|
159 | files(0)=file_in |
---|
160 | else |
---|
161 | print(" ") |
---|
162 | print("1st input file: '"+file_in+"' does not exist") |
---|
163 | print(" ") |
---|
164 | exit |
---|
165 | end if |
---|
166 | else |
---|
167 | if (start_f .EQ. 0)then |
---|
168 | if (isfilepresent(file_in+".nc"))then |
---|
169 | files(0)=file_in+".nc" |
---|
170 | do i=1,end_f |
---|
171 | if (isfilepresent(file_in+"."+i+".nc"))then |
---|
172 | files(i)=file_in+"."+i+".nc" |
---|
173 | else |
---|
174 | print(" ") |
---|
175 | print("Input file: '"+file_in+"."+i+".nc' does not exist") |
---|
176 | print(" ") |
---|
177 | exit |
---|
178 | end if |
---|
179 | end do |
---|
180 | else |
---|
181 | print(" ") |
---|
182 | print("Input file: '"+file_in+".nc' does not exist") |
---|
183 | print(" ") |
---|
184 | exit |
---|
185 | end if |
---|
186 | else |
---|
187 | do i=start_f,end_f |
---|
188 | if (isfilepresent(file_in+"."+i+".nc"))then |
---|
189 | files(i-start_f)=file_in+"."+i+".nc" |
---|
190 | else |
---|
191 | print(" ") |
---|
192 | print("Input file: '"+file_in+"."+i+".nc' does not exist") |
---|
193 | print(" ") |
---|
194 | exit |
---|
195 | end if |
---|
196 | end do |
---|
197 | end if |
---|
198 | end if |
---|
199 | |
---|
200 | f=addfiles(files,"r") |
---|
201 | f_att=addfile(files(0),"r") |
---|
202 | ListSetType(f,"cat") |
---|
203 | |
---|
204 | vNam = getfilevarnames(f_att) |
---|
205 | if( ncl_version .GE. 6.1 ) then |
---|
206 | vNam = vNam(::-1) |
---|
207 | end if |
---|
208 | vType = getfilevartypes(f_att,vNam) |
---|
209 | |
---|
210 | if ((all(vType .eq. "double"))) then ;distinction if data is double or float |
---|
211 | check_vType = True |
---|
212 | else |
---|
213 | check_vType = False |
---|
214 | end if |
---|
215 | |
---|
216 | print(" ") |
---|
217 | print("Variables in input file:") |
---|
218 | print("- "+ vNam) |
---|
219 | print(" ") |
---|
220 | dim = dimsizes(vNam) |
---|
221 | vDim = getfiledimsizes(f_att) |
---|
222 | |
---|
223 | t_all = f[:]->time |
---|
224 | nt = dimsizes(t_all) |
---|
225 | |
---|
226 | if (nt .EQ. 1)then |
---|
227 | delta_t=t_all(nt-1)/nt |
---|
228 | else |
---|
229 | delta_t_array = new(nt-1,double) |
---|
230 | |
---|
231 | do i=0,nt-2 |
---|
232 | delta_t_array(i) = t_all(i+1)-t_all(i) |
---|
233 | end do |
---|
234 | |
---|
235 | delta_t = min(delta_t_array) |
---|
236 | delete(delta_t_array) |
---|
237 | end if |
---|
238 | |
---|
239 | k_x=f_att->k_x |
---|
240 | dimx=dimsizes(k_x) |
---|
241 | k_y=f_att->k_y |
---|
242 | dimy=dimsizes(k_y) |
---|
243 | |
---|
244 | |
---|
245 | dim_level=dimsizes(height_level) |
---|
246 | |
---|
247 | do i=0,dim-1 |
---|
248 | if (vNam(i) .EQ. "zu_sp")then |
---|
249 | zu=f_att->zu_sp |
---|
250 | if (height_level(0) .EQ. -1)then |
---|
251 | dimz=dimsizes(zu) |
---|
252 | else |
---|
253 | if (dim_level .GT. dimsizes(zu))then |
---|
254 | print(" ") |
---|
255 | print("'height_level' has more elements than available "+\ |
---|
256 | "height levels in input file (= "+dimsizes(zu)+")") |
---|
257 | print(" ") |
---|
258 | exit |
---|
259 | else |
---|
260 | zuh=new(dim_level,double) |
---|
261 | do le=0,dim_level-1 |
---|
262 | if (height_level(le) .GE. dimsizes(zu)) then |
---|
263 | no_levels=dimsizes(zu)-1 |
---|
264 | print(" ") |
---|
265 | print("Element "+le+" of 'height_level' is greater " +\ |
---|
266 | "than the maximum available index in input file "+\ |
---|
267 | "which is "+no_levels+". Note that the first " +\ |
---|
268 | "element has the index 0.") |
---|
269 | print(" ") |
---|
270 | exit |
---|
271 | end if |
---|
272 | zuh(le)=zu(height_level(le)) |
---|
273 | end do |
---|
274 | dimz=dim_level |
---|
275 | end if |
---|
276 | end if |
---|
277 | else |
---|
278 | if (vNam(i) .EQ. "zw_sp")then |
---|
279 | zw=f_att->zw_sp |
---|
280 | if (height_level(0) .EQ. -1)then |
---|
281 | dimz=dimsizes(zw) |
---|
282 | else |
---|
283 | if (dim_level .GT. dimsizes(zw))then |
---|
284 | print(" ") |
---|
285 | print("'height_level' has more elements than available "+\ |
---|
286 | "height levels in input file (= "+dimsizes(zw)+")") |
---|
287 | print(" ") |
---|
288 | exit |
---|
289 | else |
---|
290 | zwh=new(dim_level,double) |
---|
291 | do le=0,dim_level-1 |
---|
292 | if (height_level(le) .GE. dimsizes(zw)) then |
---|
293 | no_levels=dimsizes(zw)-1 |
---|
294 | print(" ") |
---|
295 | print("Element "+le+" of 'height_level' is greater "+\ |
---|
296 | "than the maximum available index in input " +\ |
---|
297 | "file which is "+no_levels+". Note that the " +\ |
---|
298 | "first element has the index 0.") |
---|
299 | print(" ") |
---|
300 | exit |
---|
301 | end if |
---|
302 | zwh(le)=zw(height_level(le)) |
---|
303 | end do |
---|
304 | dimz=dim_level |
---|
305 | end if |
---|
306 | end if |
---|
307 | end if |
---|
308 | end if |
---|
309 | end do |
---|
310 | |
---|
311 | ;**************************************************** |
---|
312 | ; start of time step and different types of mistakes that could be done |
---|
313 | ;**************************************************** |
---|
314 | |
---|
315 | if (start_time_step .EQ. -1.d) then |
---|
316 | start_time_step=t_all(0)/3600 |
---|
317 | else |
---|
318 | if (start_time_step .GT. t_all(nt-1)/3600)then |
---|
319 | print(" ") |
---|
320 | print("'start_time_step' = "+ start_time_step +"h is greater than "+\ |
---|
321 | "last time step = "+ t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") |
---|
322 | print(" ") |
---|
323 | print("Select another 'start_time_step'") |
---|
324 | print(" ") |
---|
325 | exit |
---|
326 | end if |
---|
327 | if (start_time_step .LT. t_all(0)/3600)then |
---|
328 | print(" ") |
---|
329 | print("'start_time_step' = "+ start_time_step +"h is lower than "+\ |
---|
330 | "first time step = "+ t_all(0)+"s = "+t_all(0)/3600+"h") |
---|
331 | exit |
---|
332 | end if |
---|
333 | end if |
---|
334 | |
---|
335 | do i=0,nt-1 |
---|
336 | if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \ |
---|
337 | start_time_step .LT. (t_all(i)+delta_t/2)/3600)then |
---|
338 | st=i |
---|
339 | break |
---|
340 | else |
---|
341 | st=0 |
---|
342 | end if |
---|
343 | end do |
---|
344 | |
---|
345 | ;**************************************************** |
---|
346 | ; end of time step and different types of mistakes that could be done |
---|
347 | ;**************************************************** |
---|
348 | |
---|
349 | if (end_time_step .EQ. -1.d) then |
---|
350 | end_time_step = t_all(nt-1)/3600 |
---|
351 | else |
---|
352 | if (end_time_step .GT. t_all(nt-1)/3600)then |
---|
353 | print(" ") |
---|
354 | print("'end_time_step' = "+ end_time_step +"h is greater than "+\ |
---|
355 | "last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") |
---|
356 | print(" ") |
---|
357 | print("Select another 'end_time_step'") |
---|
358 | print(" ") |
---|
359 | exit |
---|
360 | end if |
---|
361 | if (end_time_step .LT. start_time_step/3600)then |
---|
362 | print(" ") |
---|
363 | print("'end_time_step' = "+ end_time_step +"h is lower than "+\ |
---|
364 | "'start_time_step' = "+start_time_step+"h") |
---|
365 | print(" ") |
---|
366 | print("Select another 'start_time_step' or 'end_time_step'") |
---|
367 | print(" ") |
---|
368 | exit |
---|
369 | end if |
---|
370 | end if |
---|
371 | |
---|
372 | do i=0,nt-1 |
---|
373 | if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \ |
---|
374 | end_time_step .LT. (t_all(i)+delta_t/2)/3600)then |
---|
375 | et=i |
---|
376 | break |
---|
377 | else |
---|
378 | et=0 |
---|
379 | end if |
---|
380 | end do |
---|
381 | |
---|
382 | delete(start_time_step) |
---|
383 | start_time_step=round(st,3) |
---|
384 | delete(end_time_step) |
---|
385 | end_time_step=round(et,3) |
---|
386 | |
---|
387 | print(" ") |
---|
388 | print("Output of time steps from "+t_all(start_time_step)/3600+" h = "+\ |
---|
389 | t_all(start_time_step)+" s => index = "+start_time_step) |
---|
390 | print(" till "+t_all(end_time_step)/3600+" h = "+\ |
---|
391 | t_all(end_time_step)+" s => index = "+end_time_step) |
---|
392 | print(" ") |
---|
393 | |
---|
394 | dimt = end_time_step-start_time_step+1 |
---|
395 | |
---|
396 | ;*************************************************** |
---|
397 | ; set up recourses |
---|
398 | ;*************************************************** |
---|
399 | |
---|
400 | res = True |
---|
401 | res@gsnDraw = False |
---|
402 | res@gsnFrame = False |
---|
403 | res@txFont = "helvetica" |
---|
404 | res@tiMainFont = "helvetica" |
---|
405 | res@tiXAxisFont = "helvetica" |
---|
406 | res@tiYAxisFont = "helvetica" |
---|
407 | res@tmXBLabelFont = "helvetica" |
---|
408 | res@tmYLLabelFont = "helvetica" |
---|
409 | res@lgLabelFont = "helvetica" |
---|
410 | res@tmLabelAutoStride = True |
---|
411 | |
---|
412 | res@lgLabelFontHeightF = font_size_legend |
---|
413 | res@lgTitleFontHeightF = font_size |
---|
414 | res@txFontHeightF = font_size |
---|
415 | res@tiXAxisFontHeightF = font_size |
---|
416 | res@tiYAxisFontHeightF = font_size |
---|
417 | res@tmXBLabelFontHeightF = font_size |
---|
418 | res@tmYLLabelFontHeightF = font_size |
---|
419 | |
---|
420 | res@tmXBMinorPerMajor = 4 |
---|
421 | res@tmYLMinorPerMajor = 4 |
---|
422 | |
---|
423 | if (log_x .EQ. 1) then |
---|
424 | res@trXLog = True |
---|
425 | else |
---|
426 | res@trXLog = False |
---|
427 | end if |
---|
428 | if (log_y .EQ. 1)then |
---|
429 | res@trYLog = True |
---|
430 | else |
---|
431 | res@trYLog = False |
---|
432 | end if |
---|
433 | |
---|
434 | legend_label=new(dimt,string) |
---|
435 | legend_label_zu=new(dimz,double) |
---|
436 | legend_label_zw=new(dimz,double) |
---|
437 | legend_label_z=new(dimz,double) |
---|
438 | do p=start_time_step,end_time_step |
---|
439 | legend_label(p-start_time_step)=sprintf("%6.2f", t_all(p)/3600) |
---|
440 | end do |
---|
441 | if (sort .EQ. "time") |
---|
442 | plot = new(dim*dimz,graphic) |
---|
443 | np=dimt |
---|
444 | res@lgTitleString = "Time (h)" |
---|
445 | else |
---|
446 | plot = new(dim*dimt,graphic) |
---|
447 | np=dimz |
---|
448 | |
---|
449 | do p=0,dimz-1 |
---|
450 | if (height_level(0) .EQ. -1)then |
---|
451 | legend_label_zu(p)=round(zu(p),3) |
---|
452 | legend_label_zw(p)=round(zw(p),3) |
---|
453 | else |
---|
454 | legend_label_zu(p)=round(zuh(p),3) |
---|
455 | legend_label_zw(p)=round(zwh(p),3) |
---|
456 | end if |
---|
457 | end do |
---|
458 | end if |
---|
459 | |
---|
460 | if (black .eq. 0 ) then |
---|
461 | if (np .EQ. 1)then |
---|
462 | color = 237 |
---|
463 | else |
---|
464 | step=round(235/(np-1),3) |
---|
465 | color = ispan(2,237,step) |
---|
466 | end if |
---|
467 | else |
---|
468 | color = 2 |
---|
469 | end if |
---|
470 | if ( dash .eq. 0 ) then |
---|
471 | res@xyMonoDashPattern = True |
---|
472 | end if |
---|
473 | |
---|
474 | if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then |
---|
475 | format_out@wkPaperSize = "A4" |
---|
476 | end if |
---|
477 | if ( format_out .EQ. "png" ) then |
---|
478 | format_out@wkWidth = 1000 |
---|
479 | format_out@wkHeight = 1000 |
---|
480 | end if |
---|
481 | |
---|
482 | wks=gsn_open_wks(format_out,file_out) |
---|
483 | gsn_define_colormap(wks,"rainbow+white") |
---|
484 | |
---|
485 | n=0 |
---|
486 | do varn =dim-1,0,1 |
---|
487 | |
---|
488 | check = True |
---|
489 | |
---|
490 | if ( isStrSubset( vNam(varn), "time") .OR. \ |
---|
491 | isStrSubset( vNam(varn), "zu_sp") .OR. \ |
---|
492 | isStrSubset( vNam(varn), "zw_sp") .OR. \ |
---|
493 | isStrSubset( vNam(varn), "k_x") .OR. \ |
---|
494 | isStrSubset( vNam(varn), "k_y")) then |
---|
495 | check = False |
---|
496 | end if |
---|
497 | |
---|
498 | if (var .NE. "all") then |
---|
499 | check = isStrSubset( var,","+vNam(varn)+"," ) |
---|
500 | end if |
---|
501 | |
---|
502 | if(check) then |
---|
503 | |
---|
504 | temp = f[:]->$vNam(varn)$ |
---|
505 | data = temp(start_time_step:end_time_step,0:dimz-1,:) |
---|
506 | |
---|
507 | temp_att = f_att->$vNam(varn)$ |
---|
508 | a=getvardims(temp_att) |
---|
509 | b=dimsizes(a) |
---|
510 | delete(temp_att) |
---|
511 | |
---|
512 | if (height_level(0) .NE. -1)then |
---|
513 | do te=0,dimz-1 |
---|
514 | data(:,te,:) = temp(start_time_step:end_time_step,\ |
---|
515 | height_level(te),:) |
---|
516 | end do |
---|
517 | end if |
---|
518 | |
---|
519 | data=data/(norm_y*norm_x) |
---|
520 | |
---|
521 | do i=0,b-1 |
---|
522 | if (isStrSubset( a(i),"zu_sp" ))then |
---|
523 | legend_label_z=legend_label_zu |
---|
524 | if (height_level(0) .NE. -1)then |
---|
525 | z=zuh |
---|
526 | else |
---|
527 | z=zu |
---|
528 | end if |
---|
529 | else |
---|
530 | if (isStrSubset( a(i),"zw_sp" ))then |
---|
531 | legend_label_z=legend_label_zw |
---|
532 | if (height_level(0) .NE. -1)then |
---|
533 | z=zwh |
---|
534 | else |
---|
535 | z=zw |
---|
536 | end if |
---|
537 | end if |
---|
538 | end if |
---|
539 | end do |
---|
540 | |
---|
541 | if (check_vType) then |
---|
542 | min_y=new(dimz,double) |
---|
543 | max_y=new(dimz,double) |
---|
544 | else |
---|
545 | min_y=new(dimz,float) |
---|
546 | max_y=new(dimz,float) |
---|
547 | end if |
---|
548 | min_x=new(dimz,double) |
---|
549 | max_x=new(dimz,double) |
---|
550 | |
---|
551 | plot_h = new(dimz,graphic) |
---|
552 | |
---|
553 | if (isStrSubset(vNam(varn),"x"))then |
---|
554 | x_axis = new((/dimz,dimx/),double) |
---|
555 | do q=0,dimz-1 |
---|
556 | x_axis(q,:) = f_att->k_x |
---|
557 | x_axis = x_axis/norm_x |
---|
558 | end do |
---|
559 | if (norm_x .NE. 1.)then |
---|
560 | res@tiXAxisString = "k~B~x~N~ ("+unit_x+")" |
---|
561 | else |
---|
562 | if (norm_height .EQ. 1)then |
---|
563 | res@tiXAxisString = "k~B~x~N~ x z (1" |
---|
564 | else |
---|
565 | res@tiXAxisString = "k~B~x~N~ (1/m)" |
---|
566 | end if |
---|
567 | end if |
---|
568 | dim_r=dimx |
---|
569 | else |
---|
570 | x_axis=new((/dimz,dimy/),double) |
---|
571 | do q=0,dimz-1 |
---|
572 | x_axis(q,:) = f_att->k_y |
---|
573 | x_axis = x_axis/norm_x |
---|
574 | end do |
---|
575 | if (norm_x .NE. 1.)then |
---|
576 | res@tiXAxisString = "k~B~x~N~ ("+unit_x+")" |
---|
577 | else |
---|
578 | if (norm_height .EQ. 1)then |
---|
579 | res@tiXAxisString = "k~B~x~N~ x z (1)" |
---|
580 | else |
---|
581 | res@tiXAxisString = "k~B~x~N~ (1/m)" |
---|
582 | end if |
---|
583 | end if |
---|
584 | dim_r=dimy |
---|
585 | end if |
---|
586 | |
---|
587 | if (sort .EQ. "time") |
---|
588 | res@xyLineColors = color |
---|
589 | res@pmLegendDisplayMode = "Always" |
---|
590 | res@pmLegendSide = "Top" |
---|
591 | res@pmLegendParallelPosF = 1.2 |
---|
592 | res@pmLegendOrthogonalPosF = -1.0 |
---|
593 | res@pmLegendWidthF = 0.12 |
---|
594 | res@pmLegendHeightF = 0.04*\ |
---|
595 | (end_time_step-start_time_step+1) |
---|
596 | do p=dimz-1,0,1 |
---|
597 | if (log_y .EQ. 1)then |
---|
598 | do q=0,dimt-1 |
---|
599 | do r=0,dim_r-1 |
---|
600 | if (data(q,p,r) .EQ. 0)then |
---|
601 | st=p+start_time_step |
---|
602 | print(" ") |
---|
603 | print("'"+vNam(varn)+"("+st+","+q+","+r+")' is "+\ |
---|
604 | "equal 0. Logarithmic scale for y-axis "+\ |
---|
605 | "and height "+z(p)+" cannot be used") |
---|
606 | print(" ") |
---|
607 | res@trYLog = False |
---|
608 | end if |
---|
609 | end do |
---|
610 | end do |
---|
611 | end if |
---|
612 | res@gsnLeftString = vNam(varn) |
---|
613 | res@gsnRightString = "Height = "+z(p)+"m" |
---|
614 | res@tiYAxisString = "("+unit_y+")" |
---|
615 | res@xyExplicitLegendLabels = legend_label |
---|
616 | if (norm_height .EQ. 1)then |
---|
617 | data(:,p,:)=data(:,p,:)*doubletofloat(z(p)) |
---|
618 | x_axis(p,:) = x_axis(p,:)*z(p) |
---|
619 | end if |
---|
620 | res@trXMinF = min(x_axis(p,:)) |
---|
621 | res@trXMaxF = max(x_axis(p,:)) |
---|
622 | plot(n) = gsn_csm_xy(wks,x_axis(p,:),data(:,p,:),res) |
---|
623 | n=n+1 |
---|
624 | end do |
---|
625 | else |
---|
626 | if (sort .EQ. "height") |
---|
627 | do p=0,dimt-1 |
---|
628 | do q=0,dimz-1 |
---|
629 | do r=0,dim_r-1 |
---|
630 | if (data(p,q,r) .EQ. 0)then |
---|
631 | st=p+start_time_step |
---|
632 | print(" ") |
---|
633 | print("'"+vNam(varn)+"("+st+","+q+","+r+")' "+\ |
---|
634 | "is equal 0. Logarithmic scale for y-axis "+\ |
---|
635 | "and time "+legend_label(p)+" h cannot be used") |
---|
636 | print(" ") |
---|
637 | res@trYLog = False |
---|
638 | end if |
---|
639 | end do |
---|
640 | if (norm_height .EQ. 1 .AND. p .EQ. 0)then |
---|
641 | data(p,q,:) = data(p,q,:)*\ |
---|
642 | doubletofloat(legend_label_z(q)) |
---|
643 | x_axis(q,:) = x_axis(q,:)*\ |
---|
644 | doubletofloat(legend_label_z(q)) |
---|
645 | end if |
---|
646 | max_y(q)=max(data(p,q,:)) |
---|
647 | min_y(q)=min(data(p,q,:)) |
---|
648 | min_x(q)=min(x_axis(q,:)) |
---|
649 | max_x(q)=max(x_axis(q,:)) |
---|
650 | end do |
---|
651 | do q=0,dimz-1 |
---|
652 | res@xyLineColor = color(q) |
---|
653 | if (dash .EQ. 1)then |
---|
654 | res@xyDashPattern = q |
---|
655 | end if |
---|
656 | if (q .EQ. 0)then |
---|
657 | res@tiYAxisString = "("+unit_y+")" |
---|
658 | res@gsnLeftString = vNam(varn) |
---|
659 | res@gsnRightString = "Time = "+legend_label(p)+"h" |
---|
660 | res@trXMinF = min(min_x) |
---|
661 | res@trXMaxF = max(max_x) |
---|
662 | res@trYMinF = min(min_y) |
---|
663 | res@trYMaxF = max(max_y) |
---|
664 | |
---|
665 | plot_h(q) = gsn_csm_xy(wks,x_axis(q,:),\ |
---|
666 | data(p,q,:),res) |
---|
667 | |
---|
668 | lgres = True |
---|
669 | if (dash .EQ. 0)then |
---|
670 | lgres@lgMonoDashIndex = True |
---|
671 | else |
---|
672 | lgres@lgDashIndexes = ispan(0,dimz-1,1) |
---|
673 | end if |
---|
674 | if (black .EQ. 1)then |
---|
675 | lgres@lgMonoLineColors = True |
---|
676 | else |
---|
677 | lgres@lgLineColors = color |
---|
678 | end if |
---|
679 | lgres@lgTitleString = "Height (m)" |
---|
680 | lgres@lgLabelFont = "helvetica" |
---|
681 | lgres@lgLabelFontHeightF = font_size_legend*6 |
---|
682 | lgres@lgTitleFontHeightF = font_size |
---|
683 | lgres@vpWidthF = 0.12 |
---|
684 | lgres@vpHeightF = font_size_legend*(dimz+3) |
---|
685 | |
---|
686 | lbid = gsn_create_legend(wks,dimz,legend_label_z,lgres) |
---|
687 | |
---|
688 | amres = True |
---|
689 | amres@amParallelPosF = 0.75 |
---|
690 | amres@amOrthogonalPosF = 0.15 |
---|
691 | annoid1 = gsn_add_annotation(plot_h(q),lbid,amres) |
---|
692 | else |
---|
693 | plot_h(q) = gsn_csm_xy(wks,x_axis(q,:),\ |
---|
694 | data(p,q,:),res) |
---|
695 | overlay(plot_h(0),plot_h(q)) |
---|
696 | end if |
---|
697 | end do |
---|
698 | plot(n)=plot_h(0) |
---|
699 | n=n+1 |
---|
700 | end do |
---|
701 | end if |
---|
702 | end if |
---|
703 | delete(data) |
---|
704 | delete(temp) |
---|
705 | delete(x_axis) |
---|
706 | delete(min_x) |
---|
707 | delete(max_x) |
---|
708 | delete(min_y) |
---|
709 | delete(max_y) |
---|
710 | delete(plot_h) |
---|
711 | end if |
---|
712 | end do |
---|
713 | |
---|
714 | if (n .EQ. 0) then |
---|
715 | print(" ") |
---|
716 | print("The variables 'var="+var+"' do not exist on your input file;") |
---|
717 | print("be sure to have one comma berfore and after each variable") |
---|
718 | print(" ") |
---|
719 | exit |
---|
720 | end if |
---|
721 | |
---|
722 | ; *************************************************** |
---|
723 | ; merge plots onto one page |
---|
724 | ; *************************************************** |
---|
725 | |
---|
726 | resP = True |
---|
727 | resP@gsnMaximize = True |
---|
728 | resP@gsnPanelXWhiteSpacePercent = 4.0 |
---|
729 | resP@gsnPanelYWhiteSpacePercent = 4.0 |
---|
730 | resP@txFont = "helvetica" |
---|
731 | resP@txString = f_att@title |
---|
732 | resP@txFuncCode = "~" |
---|
733 | resP@txFontHeightF = 0.0105 |
---|
734 | |
---|
735 | no_frames = 0 |
---|
736 | |
---|
737 | if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. \ |
---|
738 | n .gt. no_rows*no_columns) then |
---|
739 | gsn_panel(wks,plot,(/n,1/),resP) |
---|
740 | print(" ") |
---|
741 | print("Outputs to .eps or .epsi have only one frame") |
---|
742 | print(" ") |
---|
743 | else |
---|
744 | do i = 0,n-1, no_rows*no_columns |
---|
745 | if( (i+no_rows*no_columns) .gt. (n-1)) then |
---|
746 | gsn_panel(wks,plot(i:n-1),(/no_rows,no_columns/),resP) |
---|
747 | no_frames = no_frames + 1 |
---|
748 | else |
---|
749 | gsn_panel(wks,plot(i:i+no_rows*no_columns-1),\ |
---|
750 | (/no_rows,no_columns/),resP) |
---|
751 | no_frames = no_frames + 1 |
---|
752 | end if |
---|
753 | end do |
---|
754 | end if |
---|
755 | |
---|
756 | if (format_out .EQ. "png" ) then |
---|
757 | png_output = new((/no_frames/), string) |
---|
758 | j = 0 |
---|
759 | |
---|
760 | if (no_frames .eq. 1) then |
---|
761 | if (ncl_version .GE. 6 ) then |
---|
762 | png_output(0) = file_out+".png" |
---|
763 | else |
---|
764 | png_output(0) = file_out+".00000"+1+".png" |
---|
765 | end if |
---|
766 | ;using imagemagick's convert for reducing the white |
---|
767 | ;space around the plot |
---|
768 | cmd = "convert -geometry 1000x1000 -density 300 -trim " + \ |
---|
769 | png_output(0) + " " + png_output(0) |
---|
770 | system(cmd) |
---|
771 | else |
---|
772 | |
---|
773 | do i=0, no_frames-1 |
---|
774 | j = i + 1 |
---|
775 | if (j .LE. 9) then |
---|
776 | png_output(i) = file_out+".00000"+j+".png" |
---|
777 | end if |
---|
778 | if (j .GT. 9 .AND. j .LE. 99) then |
---|
779 | png_output(i) = file_out+".0000"+j+".png" |
---|
780 | end if |
---|
781 | if (j .GT. 99 .AND. j .LE. 999) then |
---|
782 | png_output(i) = file_out+".000"+j+".png" |
---|
783 | end if |
---|
784 | if (j .GT. 999) then |
---|
785 | png_output(i) = file_out+".00"+j+".png" |
---|
786 | end if |
---|
787 | |
---|
788 | ;using imagemagick's convert for reducing the white |
---|
789 | ;space around the plot |
---|
790 | cmd = "convert -geometry 1000x1000 -density 300 -trim " + \ |
---|
791 | png_output(i) + " " + png_output(i) |
---|
792 | system(cmd) |
---|
793 | end do |
---|
794 | end if |
---|
795 | |
---|
796 | print(" ") |
---|
797 | print("Output to: "+ png_output) |
---|
798 | print(" ") |
---|
799 | else |
---|
800 | print(" ") |
---|
801 | print("Output to: " + file_out +"."+ format_out) |
---|
802 | print(" ") |
---|
803 | end if |
---|
804 | |
---|
805 | end |
---|