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 | vType = getfilevartypes(f_att,vNam) |
---|
206 | |
---|
207 | if ((all(vType .eq. "double"))) then ;distinction if data is double or float |
---|
208 | check_vType = True |
---|
209 | else |
---|
210 | check_vType = False |
---|
211 | end if |
---|
212 | |
---|
213 | print(" ") |
---|
214 | print("Variables in input file:") |
---|
215 | print("- "+ vNam) |
---|
216 | print(" ") |
---|
217 | dim = dimsizes(vNam) |
---|
218 | vDim = getfiledimsizes(f_att) |
---|
219 | |
---|
220 | t_all = f[:]->time |
---|
221 | nt = dimsizes(t_all) |
---|
222 | delta_t=t_all(nt-1)/nt |
---|
223 | |
---|
224 | k_x=f_att->k_x |
---|
225 | dimx=dimsizes(k_x) |
---|
226 | k_y=f_att->k_y |
---|
227 | dimy=dimsizes(k_y) |
---|
228 | |
---|
229 | |
---|
230 | dim_level=dimsizes(height_level) |
---|
231 | |
---|
232 | do i=0,dim-1 |
---|
233 | if (vNam(i) .EQ. "zu_sp")then |
---|
234 | zu=f_att->zu_sp |
---|
235 | if (height_level(0) .EQ. -1)then |
---|
236 | dimz=dimsizes(zu) |
---|
237 | else |
---|
238 | if (dim_level .GT. dimsizes(zu))then |
---|
239 | print(" ") |
---|
240 | print("'height_level' has more elements than available "+\ |
---|
241 | "height levels in input file (= "+dimsizes(zu)+")") |
---|
242 | print(" ") |
---|
243 | exit |
---|
244 | else |
---|
245 | zuh=new(dim_level,double) |
---|
246 | do le=0,dim_level-1 |
---|
247 | if (height_level(le) .GE. dimsizes(zu)) then |
---|
248 | no_levels=dimsizes(zu)-1 |
---|
249 | print(" ") |
---|
250 | print("Element "+le+" of 'height_level' is greater " +\ |
---|
251 | "than the maximum available index in input file "+\ |
---|
252 | "which is "+no_levels+". Note that the first " +\ |
---|
253 | "element has the index 0.") |
---|
254 | print(" ") |
---|
255 | exit |
---|
256 | end if |
---|
257 | zuh(le)=zu(height_level(le)) |
---|
258 | end do |
---|
259 | dimz=dim_level |
---|
260 | end if |
---|
261 | end if |
---|
262 | else |
---|
263 | if (vNam(i) .EQ. "zw_sp")then |
---|
264 | zw=f_att->zw_sp |
---|
265 | if (height_level(0) .EQ. -1)then |
---|
266 | dimz=dimsizes(zw) |
---|
267 | else |
---|
268 | if (dim_level .GT. dimsizes(zw))then |
---|
269 | print(" ") |
---|
270 | print("'height_level' has more elements than available "+\ |
---|
271 | "height levels in input file (= "+dimsizes(zw)+")") |
---|
272 | print(" ") |
---|
273 | exit |
---|
274 | else |
---|
275 | zwh=new(dim_level,double) |
---|
276 | do le=0,dim_level-1 |
---|
277 | if (height_level(le) .GE. dimsizes(zw)) then |
---|
278 | no_levels=dimsizes(zw)-1 |
---|
279 | print(" ") |
---|
280 | print("Element "+le+" of 'height_level' is greater "+\ |
---|
281 | "than the maximum available index in input " +\ |
---|
282 | "file which is "+no_levels+". Note that the " +\ |
---|
283 | "first element has the index 0.") |
---|
284 | print(" ") |
---|
285 | exit |
---|
286 | end if |
---|
287 | zwh(le)=zw(height_level(le)) |
---|
288 | end do |
---|
289 | dimz=dim_level |
---|
290 | end if |
---|
291 | end if |
---|
292 | end if |
---|
293 | end if |
---|
294 | end do |
---|
295 | |
---|
296 | ;**************************************************** |
---|
297 | ; start of time step and different types of mistakes that could be done |
---|
298 | ;**************************************************** |
---|
299 | |
---|
300 | if (start_time_step .EQ. -1.d) then |
---|
301 | start_time_step=t_all(0)/3600 |
---|
302 | else |
---|
303 | if (start_time_step .GT. t_all(nt-1)/3600)then |
---|
304 | print(" ") |
---|
305 | print("'start_time_step' = "+ start_time_step +"h is greater than "+\ |
---|
306 | "last time step = "+ t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") |
---|
307 | print(" ") |
---|
308 | print("Select another 'start_time_step'") |
---|
309 | print(" ") |
---|
310 | exit |
---|
311 | end if |
---|
312 | if (start_time_step .LT. t_all(0)/3600)then |
---|
313 | print(" ") |
---|
314 | print("'start_time_step' = "+ start_time_step +"h is lower than "+\ |
---|
315 | "first time step = "+ t_all(0)+"s = "+t_all(0)/3600+"h") |
---|
316 | exit |
---|
317 | end if |
---|
318 | end if |
---|
319 | |
---|
320 | do i=0,nt-1 |
---|
321 | if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \ |
---|
322 | start_time_step .LT. (t_all(i)+delta_t/2)/3600)then |
---|
323 | st=i |
---|
324 | break |
---|
325 | else |
---|
326 | st=0 |
---|
327 | end if |
---|
328 | end do |
---|
329 | |
---|
330 | ;**************************************************** |
---|
331 | ; end of time step and different types of mistakes that could be done |
---|
332 | ;**************************************************** |
---|
333 | |
---|
334 | if (end_time_step .EQ. -1.d) then |
---|
335 | end_time_step = t_all(nt-1)/3600 |
---|
336 | else |
---|
337 | if (end_time_step .GT. t_all(nt-1)/3600)then |
---|
338 | print(" ") |
---|
339 | print("'end_time_step' = "+ end_time_step +"h is greater than "+\ |
---|
340 | "last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") |
---|
341 | print(" ") |
---|
342 | print("Select another 'end_time_step'") |
---|
343 | print(" ") |
---|
344 | exit |
---|
345 | end if |
---|
346 | if (end_time_step .LT. start_time_step/3600)then |
---|
347 | print(" ") |
---|
348 | print("'end_time_step' = "+ end_time_step +"h is lower than "+\ |
---|
349 | "'start_time_step' = "+start_time_step+"h") |
---|
350 | print(" ") |
---|
351 | print("Select another 'start_time_step' or 'end_time_step'") |
---|
352 | print(" ") |
---|
353 | exit |
---|
354 | end if |
---|
355 | end if |
---|
356 | |
---|
357 | do i=0,nt-1 |
---|
358 | if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \ |
---|
359 | end_time_step .LT. (t_all(i)+delta_t/2)/3600)then |
---|
360 | et=i |
---|
361 | break |
---|
362 | else |
---|
363 | et=0 |
---|
364 | end if |
---|
365 | end do |
---|
366 | |
---|
367 | delete(start_time_step) |
---|
368 | start_time_step=round(st,3) |
---|
369 | delete(end_time_step) |
---|
370 | end_time_step=round(et,3) |
---|
371 | |
---|
372 | print(" ") |
---|
373 | print("Output of time steps from "+t_all(start_time_step)/3600+" h = "+\ |
---|
374 | t_all(start_time_step)+" s => index = "+start_time_step) |
---|
375 | print(" till "+t_all(end_time_step)/3600+" h = "+\ |
---|
376 | t_all(end_time_step)+" s => index = "+end_time_step) |
---|
377 | print(" ") |
---|
378 | |
---|
379 | dimt = end_time_step-start_time_step+1 |
---|
380 | |
---|
381 | ;*************************************************** |
---|
382 | ; set up recourses |
---|
383 | ;*************************************************** |
---|
384 | |
---|
385 | res = True |
---|
386 | res@gsnDraw = False |
---|
387 | res@gsnFrame = False |
---|
388 | res@txFont = "helvetica" |
---|
389 | res@tiMainFont = "helvetica" |
---|
390 | res@tiXAxisFont = "helvetica" |
---|
391 | res@tiYAxisFont = "helvetica" |
---|
392 | res@tmXBLabelFont = "helvetica" |
---|
393 | res@tmYLLabelFont = "helvetica" |
---|
394 | res@lgLabelFont = "helvetica" |
---|
395 | res@tmLabelAutoStride = True |
---|
396 | |
---|
397 | res@lgLabelFontHeightF = font_size_legend |
---|
398 | res@lgTitleFontHeightF = font_size |
---|
399 | res@txFontHeightF = font_size |
---|
400 | res@tiXAxisFontHeightF = font_size |
---|
401 | res@tiYAxisFontHeightF = font_size |
---|
402 | res@tmXBLabelFontHeightF = font_size |
---|
403 | res@tmYLLabelFontHeightF = font_size |
---|
404 | |
---|
405 | res@tmXBMinorPerMajor = 4 |
---|
406 | res@tmYLMinorPerMajor = 4 |
---|
407 | |
---|
408 | if (log_x .EQ. 1) then |
---|
409 | res@trXLog = True |
---|
410 | else |
---|
411 | res@trXLog = False |
---|
412 | end if |
---|
413 | if (log_y .EQ. 1)then |
---|
414 | res@trYLog = True |
---|
415 | else |
---|
416 | res@trYLog = False |
---|
417 | end if |
---|
418 | |
---|
419 | legend_label=new(dimt,string) |
---|
420 | legend_label_zu=new(dimz,double) |
---|
421 | legend_label_zw=new(dimz,double) |
---|
422 | legend_label_z=new(dimz,double) |
---|
423 | do p=start_time_step,end_time_step |
---|
424 | legend_label(p-start_time_step)=sprintf("%6.2f", t_all(p)/3600) |
---|
425 | end do |
---|
426 | if (sort .EQ. "time") |
---|
427 | plot = new(dim*dimz,graphic) |
---|
428 | np=dimt |
---|
429 | res@lgTitleString = "Time (h)" |
---|
430 | else |
---|
431 | plot = new(dim*dimt,graphic) |
---|
432 | np=dimz |
---|
433 | |
---|
434 | do p=0,dimz-1 |
---|
435 | if (height_level(0) .EQ. -1)then |
---|
436 | legend_label_zu(p)=round(zu(p),3) |
---|
437 | legend_label_zw(p)=round(zw(p),3) |
---|
438 | else |
---|
439 | legend_label_zu(p)=round(zuh(p),3) |
---|
440 | legend_label_zw(p)=round(zwh(p),3) |
---|
441 | end if |
---|
442 | end do |
---|
443 | end if |
---|
444 | |
---|
445 | if (black .eq. 0 ) then |
---|
446 | if (np .EQ. 1)then |
---|
447 | color = 237 |
---|
448 | else |
---|
449 | step=round(235/(np-1),3) |
---|
450 | color = ispan(2,237,step) |
---|
451 | end if |
---|
452 | else |
---|
453 | color = 2 |
---|
454 | end if |
---|
455 | if ( dash .eq. 0 ) then |
---|
456 | res@xyMonoDashPattern = True |
---|
457 | end if |
---|
458 | |
---|
459 | if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then |
---|
460 | format_out@wkPaperSize = "A4" |
---|
461 | end if |
---|
462 | if ( format_out .EQ. "png" ) then |
---|
463 | format_out@wkWidth = 1000 |
---|
464 | format_out@wkHeight = 1000 |
---|
465 | end if |
---|
466 | |
---|
467 | wks=gsn_open_wks(format_out,file_out) |
---|
468 | gsn_define_colormap(wks,"rainbow+white") |
---|
469 | |
---|
470 | n=0 |
---|
471 | do varn =dim-1,0,1 |
---|
472 | |
---|
473 | check = True |
---|
474 | |
---|
475 | if ( isStrSubset( vNam(varn), "time") .OR. \ |
---|
476 | isStrSubset( vNam(varn), "zu_sp") .OR. \ |
---|
477 | isStrSubset( vNam(varn), "zw_sp") .OR. \ |
---|
478 | isStrSubset( vNam(varn), "k_x") .OR. \ |
---|
479 | isStrSubset( vNam(varn), "k_y")) then |
---|
480 | check = False |
---|
481 | end if |
---|
482 | |
---|
483 | if (var .NE. "all") then |
---|
484 | check = isStrSubset( var,","+vNam(varn)+"," ) |
---|
485 | end if |
---|
486 | |
---|
487 | if(check) then |
---|
488 | |
---|
489 | temp = f[:]->$vNam(varn)$ |
---|
490 | data = temp(start_time_step:end_time_step,0:dimz-1,:) |
---|
491 | |
---|
492 | temp_att = f_att->$vNam(varn)$ |
---|
493 | a=getvardims(temp_att) |
---|
494 | b=dimsizes(a) |
---|
495 | delete(temp_att) |
---|
496 | |
---|
497 | if (height_level(0) .NE. -1)then |
---|
498 | do te=0,dimz-1 |
---|
499 | data(:,te,:) = temp(start_time_step:end_time_step,\ |
---|
500 | height_level(te),:) |
---|
501 | end do |
---|
502 | end if |
---|
503 | |
---|
504 | data=data/(norm_y*norm_x) |
---|
505 | |
---|
506 | do i=0,b-1 |
---|
507 | if (isStrSubset( a(i),"zu_sp" ))then |
---|
508 | legend_label_z=legend_label_zu |
---|
509 | if (height_level(0) .NE. -1)then |
---|
510 | z=zuh |
---|
511 | else |
---|
512 | z=zu |
---|
513 | end if |
---|
514 | else |
---|
515 | if (isStrSubset( a(i),"zw_sp" ))then |
---|
516 | legend_label_z=legend_label_zw |
---|
517 | if (height_level(0) .NE. -1)then |
---|
518 | z=zwh |
---|
519 | else |
---|
520 | z=zw |
---|
521 | end if |
---|
522 | end if |
---|
523 | end if |
---|
524 | end do |
---|
525 | |
---|
526 | if (check_vType) then |
---|
527 | min_y=new(dimz,double) |
---|
528 | max_y=new(dimz,double) |
---|
529 | else |
---|
530 | min_y=new(dimz,float) |
---|
531 | max_y=new(dimz,float) |
---|
532 | end if |
---|
533 | min_x=new(dimz,double) |
---|
534 | max_x=new(dimz,double) |
---|
535 | |
---|
536 | plot_h = new(dimz,graphic) |
---|
537 | |
---|
538 | if (isStrSubset(vNam(varn),"x"))then |
---|
539 | x_axis = new((/dimz,dimx/),double) |
---|
540 | do q=0,dimz-1 |
---|
541 | x_axis(q,:) = f_att->k_x |
---|
542 | x_axis = x_axis/norm_x |
---|
543 | end do |
---|
544 | if (norm_x .NE. 1.)then |
---|
545 | res@tiXAxisString = "k~B~x~N~ ("+unit_x+")" |
---|
546 | else |
---|
547 | if (norm_height .EQ. 1)then |
---|
548 | res@tiXAxisString = "k~B~x~N~ x z (1" |
---|
549 | else |
---|
550 | res@tiXAxisString = "k~B~x~N~ (1/m)" |
---|
551 | end if |
---|
552 | end if |
---|
553 | dim_r=dimx |
---|
554 | else |
---|
555 | x_axis=new((/dimz,dimy/),double) |
---|
556 | do q=0,dimz-1 |
---|
557 | x_axis(q,:) = f_att->k_y |
---|
558 | x_axis = x_axis/norm_x |
---|
559 | end do |
---|
560 | if (norm_x .NE. 1.)then |
---|
561 | res@tiXAxisString = "k~B~x~N~ ("+unit_x+")" |
---|
562 | else |
---|
563 | if (norm_height .EQ. 1)then |
---|
564 | res@tiXAxisString = "k~B~x~N~ x z (1)" |
---|
565 | else |
---|
566 | res@tiXAxisString = "k~B~x~N~ (1/m)" |
---|
567 | end if |
---|
568 | end if |
---|
569 | dim_r=dimy |
---|
570 | end if |
---|
571 | |
---|
572 | if (sort .EQ. "time") |
---|
573 | res@xyLineColors = color |
---|
574 | res@pmLegendDisplayMode = "Always" |
---|
575 | res@pmLegendSide = "Top" |
---|
576 | res@pmLegendParallelPosF = 1.2 |
---|
577 | res@pmLegendOrthogonalPosF = -1.0 |
---|
578 | res@pmLegendWidthF = 0.12 |
---|
579 | res@pmLegendHeightF = 0.04*\ |
---|
580 | (end_time_step-start_time_step+1) |
---|
581 | do p=dimz-1,0,1 |
---|
582 | if (log_y .EQ. 1)then |
---|
583 | do q=0,dimt-1 |
---|
584 | do r=0,dim_r-1 |
---|
585 | if (data(q,p,r) .EQ. 0)then |
---|
586 | st=p+start_time_step |
---|
587 | print(" ") |
---|
588 | print("'"+vNam(varn)+"("+st+","+q+","+r+")' is "+\ |
---|
589 | "equal 0. Logarithmic scale for y-axis "+\ |
---|
590 | "and height "+z(p)+" cannot be used") |
---|
591 | print(" ") |
---|
592 | res@trYLog = False |
---|
593 | end if |
---|
594 | end do |
---|
595 | end do |
---|
596 | end if |
---|
597 | res@gsnLeftString = vNam(varn) |
---|
598 | res@gsnRightString = "Height = "+z(p)+"m" |
---|
599 | res@tiYAxisString = "("+unit_y+")" |
---|
600 | res@xyExplicitLegendLabels = legend_label |
---|
601 | if (norm_height .EQ. 1)then |
---|
602 | data(:,p,:)=data(:,p,:)*doubletofloat(z(p)) |
---|
603 | x_axis(p,:) = x_axis(p,:)*z(p) |
---|
604 | end if |
---|
605 | res@trXMinF = min(x_axis(p,:)) |
---|
606 | res@trXMaxF = max(x_axis(p,:)) |
---|
607 | plot(n) = gsn_csm_xy(wks,x_axis(p,:),data(:,p,:),res) |
---|
608 | n=n+1 |
---|
609 | end do |
---|
610 | else |
---|
611 | if (sort .EQ. "height") |
---|
612 | do p=0,dimt-1 |
---|
613 | do q=0,dimz-1 |
---|
614 | do r=0,dim_r-1 |
---|
615 | if (data(p,q,r) .EQ. 0)then |
---|
616 | st=p+start_time_step |
---|
617 | print(" ") |
---|
618 | print("'"+vNam(varn)+"("+st+","+q+","+r+")' "+\ |
---|
619 | "is equal 0. Logarithmic scale for y-axis "+\ |
---|
620 | "and time "+legend_label(p)+" h cannot be used") |
---|
621 | print(" ") |
---|
622 | res@trYLog = False |
---|
623 | end if |
---|
624 | end do |
---|
625 | if (norm_height .EQ. 1 .AND. p .EQ. 0)then |
---|
626 | data(p,q,:) = data(p,q,:)*\ |
---|
627 | doubletofloat(legend_label_z(q)) |
---|
628 | x_axis(q,:) = x_axis(q,:)*\ |
---|
629 | doubletofloat(legend_label_z(q)) |
---|
630 | end if |
---|
631 | max_y(q)=max(data(p,q,:)) |
---|
632 | min_y(q)=min(data(p,q,:)) |
---|
633 | min_x(q)=min(x_axis(q,:)) |
---|
634 | max_x(q)=max(x_axis(q,:)) |
---|
635 | end do |
---|
636 | do q=0,dimz-1 |
---|
637 | res@xyLineColor = color(q) |
---|
638 | if (dash .EQ. 1)then |
---|
639 | res@xyDashPattern = q |
---|
640 | end if |
---|
641 | if (q .EQ. 0)then |
---|
642 | res@tiYAxisString = "("+unit_y+")" |
---|
643 | res@gsnLeftString = vNam(varn) |
---|
644 | res@gsnRightString = "Time = "+legend_label(p)+"h" |
---|
645 | res@trXMinF = min(min_x) |
---|
646 | res@trXMaxF = max(max_x) |
---|
647 | res@trYMinF = min(min_y) |
---|
648 | res@trYMaxF = max(max_y) |
---|
649 | |
---|
650 | plot_h(q) = gsn_csm_xy(wks,x_axis(q,:),\ |
---|
651 | data(p,q,:),res) |
---|
652 | |
---|
653 | lgres = True |
---|
654 | if (dash .EQ. 0)then |
---|
655 | lgres@lgMonoDashIndex = True |
---|
656 | else |
---|
657 | lgres@lgDashIndexes = ispan(0,dimz-1,1) |
---|
658 | end if |
---|
659 | if (black .EQ. 1)then |
---|
660 | lgres@lgMonoLineColors = True |
---|
661 | else |
---|
662 | lgres@lgLineColors = color |
---|
663 | end if |
---|
664 | lgres@lgTitleString = "Height (m)" |
---|
665 | lgres@lgLabelFont = "helvetica" |
---|
666 | lgres@lgLabelFontHeightF = font_size_legend*6 |
---|
667 | lgres@lgTitleFontHeightF = font_size |
---|
668 | lgres@vpWidthF = 0.12 |
---|
669 | lgres@vpHeightF = font_size_legend*(dimz+3) |
---|
670 | |
---|
671 | lbid = gsn_create_legend(wks,dimz,legend_label_z,lgres) |
---|
672 | |
---|
673 | amres = True |
---|
674 | amres@amParallelPosF = 0.75 |
---|
675 | amres@amOrthogonalPosF = 0.15 |
---|
676 | annoid1 = gsn_add_annotation(plot_h(q),lbid,amres) |
---|
677 | else |
---|
678 | plot_h(q) = gsn_csm_xy(wks,x_axis(q,:),\ |
---|
679 | data(p,q,:),res) |
---|
680 | overlay(plot_h(0),plot_h(q)) |
---|
681 | end if |
---|
682 | end do |
---|
683 | plot(n)=plot_h(0) |
---|
684 | n=n+1 |
---|
685 | end do |
---|
686 | end if |
---|
687 | end if |
---|
688 | delete(data) |
---|
689 | delete(temp) |
---|
690 | delete(x_axis) |
---|
691 | delete(min_x) |
---|
692 | delete(max_x) |
---|
693 | delete(min_y) |
---|
694 | delete(max_y) |
---|
695 | delete(plot_h) |
---|
696 | end if |
---|
697 | end do |
---|
698 | |
---|
699 | if (n .EQ. 0) then |
---|
700 | print(" ") |
---|
701 | print("The variables 'var="+var+"' do not exist on your input file;") |
---|
702 | print("be sure to have one comma berfore and after each variable") |
---|
703 | print(" ") |
---|
704 | exit |
---|
705 | end if |
---|
706 | |
---|
707 | ; *************************************************** |
---|
708 | ; merge plots onto one page |
---|
709 | ; *************************************************** |
---|
710 | |
---|
711 | resP = True |
---|
712 | resP@txFont = "helvetica" |
---|
713 | resP@txString = f_att@title |
---|
714 | resP@txFuncCode = "~" |
---|
715 | resP@txFontHeightF = 0.015 |
---|
716 | |
---|
717 | no_frames = 0 |
---|
718 | |
---|
719 | if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. \ |
---|
720 | n .gt. no_rows*no_columns) then |
---|
721 | gsn_panel(wks,plot,(/n,1/),resP) |
---|
722 | print(" ") |
---|
723 | print("Outputs to .eps or .epsi have only one frame") |
---|
724 | print(" ") |
---|
725 | else |
---|
726 | do i = 0,n-1, no_rows*no_columns |
---|
727 | if( (i+no_rows*no_columns) .gt. (n-1)) then |
---|
728 | gsn_panel(wks,plot(i:n-1),(/no_rows,no_columns/),resP) |
---|
729 | no_frames = no_frames + 1 |
---|
730 | else |
---|
731 | gsn_panel(wks,plot(i:i+no_rows*no_columns-1),\ |
---|
732 | (/no_rows,no_columns/),resP) |
---|
733 | no_frames = no_frames + 1 |
---|
734 | end if |
---|
735 | end do |
---|
736 | end if |
---|
737 | |
---|
738 | if (format_out .EQ. "png" ) then |
---|
739 | png_output = new((/no_frames/), string) |
---|
740 | j = 0 |
---|
741 | do i=0, no_frames-1 |
---|
742 | j = i + 1 |
---|
743 | if (j .LE. 9) then |
---|
744 | png_output(i) = file_out+".00000"+j+".png" |
---|
745 | end if |
---|
746 | if (j .GT. 9 .AND. j .LE. 99) then |
---|
747 | png_output(i) = file_out+".0000"+j+".png" |
---|
748 | end if |
---|
749 | if (j .GT. 99 .AND. j .LE. 999) then |
---|
750 | png_output(i) = file_out+".000"+j+".png" |
---|
751 | end if |
---|
752 | if (j .GT. 999) then |
---|
753 | png_output(i) = file_out+".00"+j+".png" |
---|
754 | end if |
---|
755 | |
---|
756 | ;using imagemagick's convert for reducing the white |
---|
757 | ;space around the plot |
---|
758 | cmd = "convert -geometry 1000x1000 -density 300 -trim " + \ |
---|
759 | png_output(i) + " " + png_output(i) |
---|
760 | system(cmd) |
---|
761 | end do |
---|
762 | |
---|
763 | print(" ") |
---|
764 | print("Output to: "+ png_output) |
---|
765 | print(" ") |
---|
766 | else |
---|
767 | print(" ") |
---|
768 | print("Output to: " + file_out +"."+ format_out) |
---|
769 | print(" ") |
---|
770 | end if |
---|
771 | |
---|
772 | end |
---|