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 | print(" ") |
---|
206 | print("Variables in input file:") |
---|
207 | print("- "+ vNam) |
---|
208 | print(" ") |
---|
209 | dim = dimsizes(vNam) |
---|
210 | vDim = getfiledimsizes(f_att) |
---|
211 | |
---|
212 | t_all = f[:]->time |
---|
213 | nt = dimsizes(t_all) |
---|
214 | delta_t=t_all(nt-1)/nt |
---|
215 | |
---|
216 | k_x=f_att->k_x |
---|
217 | dimx=dimsizes(k_x) |
---|
218 | k_y=f_att->k_y |
---|
219 | dimy=dimsizes(k_y) |
---|
220 | |
---|
221 | |
---|
222 | dim_level=dimsizes(height_level) |
---|
223 | |
---|
224 | do i=0,dim-1 |
---|
225 | if (vNam(i) .EQ. "zu_sp")then |
---|
226 | zu=f_att->zu_sp |
---|
227 | if (height_level(0) .EQ. -1)then |
---|
228 | dimz=dimsizes(zu) |
---|
229 | else |
---|
230 | if (dim_level .GT. dimsizes(zu))then |
---|
231 | print(" ") |
---|
232 | print("'height_level' has more elements than available "+\ |
---|
233 | "height levels in input file (= "+dimsizes(zu)+")") |
---|
234 | print(" ") |
---|
235 | exit |
---|
236 | else |
---|
237 | zuh=new(dim_level,double) |
---|
238 | do le=0,dim_level-1 |
---|
239 | if (height_level(le) .GE. dimsizes(zu)) then |
---|
240 | no_levels=dimsizes(zu)-1 |
---|
241 | print(" ") |
---|
242 | print("Element "+le+" of 'height_level' is greater " +\ |
---|
243 | "than the maximum available index in input file "+\ |
---|
244 | "which is "+no_levels+". Note that the first " +\ |
---|
245 | "element has the index 0.") |
---|
246 | print(" ") |
---|
247 | exit |
---|
248 | end if |
---|
249 | zuh(le)=zu(height_level(le)) |
---|
250 | end do |
---|
251 | dimz=dim_level |
---|
252 | end if |
---|
253 | end if |
---|
254 | else |
---|
255 | if (vNam(i) .EQ. "zw_sp")then |
---|
256 | zw=f_att->zw_sp |
---|
257 | if (height_level(0) .EQ. -1)then |
---|
258 | dimz=dimsizes(zw) |
---|
259 | else |
---|
260 | if (dim_level .GT. dimsizes(zw))then |
---|
261 | print(" ") |
---|
262 | print("'height_level' has more elements than available "+\ |
---|
263 | "height levels in input file (= "+dimsizes(zw)+")") |
---|
264 | print(" ") |
---|
265 | exit |
---|
266 | else |
---|
267 | zwh=new(dim_level,double) |
---|
268 | do le=0,dim_level-1 |
---|
269 | if (height_level(le) .GE. dimsizes(zw)) then |
---|
270 | no_levels=dimsizes(zw)-1 |
---|
271 | print(" ") |
---|
272 | print("Element "+le+" of 'height_level' is greater "+\ |
---|
273 | "than the maximum available index in input " +\ |
---|
274 | "file which is "+no_levels+". Note that the " +\ |
---|
275 | "first element has the index 0.") |
---|
276 | print(" ") |
---|
277 | exit |
---|
278 | end if |
---|
279 | zwh(le)=zw(height_level(le)) |
---|
280 | end do |
---|
281 | dimz=dim_level |
---|
282 | end if |
---|
283 | end if |
---|
284 | end if |
---|
285 | end if |
---|
286 | end do |
---|
287 | |
---|
288 | ;**************************************************** |
---|
289 | ; start of time step and different types of mistakes that could be done |
---|
290 | ;**************************************************** |
---|
291 | |
---|
292 | if (start_time_step .EQ. -1.d) then |
---|
293 | start_time_step=t_all(0)/3600 |
---|
294 | else |
---|
295 | if (start_time_step .GT. t_all(nt-1)/3600)then |
---|
296 | print(" ") |
---|
297 | print("'start_time_step' = "+ start_time_step +"h is greater than "+\ |
---|
298 | "last time step = "+ t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") |
---|
299 | print(" ") |
---|
300 | print("Select another 'start_time_step'") |
---|
301 | print(" ") |
---|
302 | exit |
---|
303 | end if |
---|
304 | if (start_time_step .LT. t_all(0)/3600)then |
---|
305 | print(" ") |
---|
306 | print("'start_time_step' = "+ start_time_step +"h is lower than "+\ |
---|
307 | "first time step = "+ t_all(0)+"s = "+t_all(0)/3600+"h") |
---|
308 | exit |
---|
309 | end if |
---|
310 | end if |
---|
311 | |
---|
312 | do i=0,nt-1 |
---|
313 | if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \ |
---|
314 | start_time_step .LT. (t_all(i)+delta_t/2)/3600)then |
---|
315 | st=i |
---|
316 | break |
---|
317 | end if |
---|
318 | end do |
---|
319 | |
---|
320 | if (.not. isvar("st"))then |
---|
321 | print(" ") |
---|
322 | print("'start_time_step' = "+ start_time_step +"h is invalid") |
---|
323 | print(" ") |
---|
324 | print("Select another 'start_time_step'") |
---|
325 | print(" ") |
---|
326 | exit |
---|
327 | end if |
---|
328 | |
---|
329 | ;**************************************************** |
---|
330 | ; end of time step and different types of mistakes that could be done |
---|
331 | ;**************************************************** |
---|
332 | |
---|
333 | if (end_time_step .EQ. -1.d) then |
---|
334 | end_time_step = t_all(nt-1)/3600 |
---|
335 | else |
---|
336 | if (end_time_step .GT. t_all(nt-1)/3600)then |
---|
337 | print(" ") |
---|
338 | print("'end_time_step' = "+ end_time_step +"h is greater than "+\ |
---|
339 | "last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h") |
---|
340 | print(" ") |
---|
341 | print("Select another 'end_time_step'") |
---|
342 | print(" ") |
---|
343 | exit |
---|
344 | end if |
---|
345 | if (end_time_step .LT. start_time_step/3600)then |
---|
346 | print(" ") |
---|
347 | print("'end_time_step' = "+ end_time_step +"h is lower than "+\ |
---|
348 | "'start_time_step' = "+start_time_step+"h") |
---|
349 | print(" ") |
---|
350 | print("Select another 'start_time_step' or 'end_time_step'") |
---|
351 | print(" ") |
---|
352 | exit |
---|
353 | end if |
---|
354 | end if |
---|
355 | |
---|
356 | do i=0,nt-1 |
---|
357 | if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \ |
---|
358 | end_time_step .LT. (t_all(i)+delta_t/2)/3600)then |
---|
359 | et=i |
---|
360 | break |
---|
361 | end if |
---|
362 | end do |
---|
363 | |
---|
364 | if (.not. isvar("et"))then |
---|
365 | print(" ") |
---|
366 | print("'end_time_step' = "+ end_time_step +"h is invalid") |
---|
367 | print(" ") |
---|
368 | print("Select another 'end_time_step'") |
---|
369 | print(" ") |
---|
370 | exit |
---|
371 | end if |
---|
372 | |
---|
373 | delete(start_time_step) |
---|
374 | start_time_step=round(st,3) |
---|
375 | delete(end_time_step) |
---|
376 | end_time_step=round(et,3) |
---|
377 | |
---|
378 | print(" ") |
---|
379 | print("Output of time steps from "+t_all(start_time_step)/3600+" h = "+\ |
---|
380 | t_all(start_time_step)+" s => index = "+start_time_step) |
---|
381 | print(" till "+t_all(end_time_step)/3600+" h = "+\ |
---|
382 | t_all(end_time_step)+" s => index = "+end_time_step) |
---|
383 | print(" ") |
---|
384 | |
---|
385 | dimt = end_time_step-start_time_step+1 |
---|
386 | |
---|
387 | ;*************************************************** |
---|
388 | ; set up recourses |
---|
389 | ;*************************************************** |
---|
390 | |
---|
391 | res = True |
---|
392 | res@gsnDraw = False |
---|
393 | res@gsnFrame = False |
---|
394 | res@txFont = "helvetica" |
---|
395 | res@tiMainFont = "helvetica" |
---|
396 | res@tiXAxisFont = "helvetica" |
---|
397 | res@tiYAxisFont = "helvetica" |
---|
398 | res@tmXBLabelFont = "helvetica" |
---|
399 | res@tmYLLabelFont = "helvetica" |
---|
400 | res@lgLabelFont = "helvetica" |
---|
401 | res@tmLabelAutoStride = True |
---|
402 | |
---|
403 | res@lgLabelFontHeightF = font_size_legend |
---|
404 | res@lgTitleFontHeightF = font_size |
---|
405 | res@txFontHeightF = font_size |
---|
406 | res@tiXAxisFontHeightF = font_size |
---|
407 | res@tiYAxisFontHeightF = font_size |
---|
408 | res@tmXBLabelFontHeightF = font_size |
---|
409 | res@tmYLLabelFontHeightF = font_size |
---|
410 | |
---|
411 | res@tmXBMinorPerMajor = 4 |
---|
412 | res@tmYLMinorPerMajor = 4 |
---|
413 | |
---|
414 | if (log_x .EQ. 1) then |
---|
415 | res@trXLog = True |
---|
416 | else |
---|
417 | res@trXLog = False |
---|
418 | end if |
---|
419 | if (log_y .EQ. 1)then |
---|
420 | res@trYLog = True |
---|
421 | else |
---|
422 | res@trYLog = False |
---|
423 | end if |
---|
424 | |
---|
425 | legend_label=new(dimt,string) |
---|
426 | legend_label_zu=new(dimz,double) |
---|
427 | legend_label_zw=new(dimz,double) |
---|
428 | legend_label_z=new(dimz,double) |
---|
429 | do p=start_time_step,end_time_step |
---|
430 | legend_label(p-start_time_step)=sprintf("%6.2f", t_all(p)/3600) |
---|
431 | end do |
---|
432 | if (sort .EQ. "time") |
---|
433 | plot = new(dim*dimz,graphic) |
---|
434 | np=dimt |
---|
435 | res@lgTitleString = "Time (h)" |
---|
436 | else |
---|
437 | plot = new(dim*dimt,graphic) |
---|
438 | np=dimz |
---|
439 | |
---|
440 | do p=0,dimz-1 |
---|
441 | if (height_level(0) .EQ. -1)then |
---|
442 | legend_label_zu(p)=round(zu(p),3) |
---|
443 | legend_label_zw(p)=round(zw(p),3) |
---|
444 | else |
---|
445 | legend_label_zu(p)=round(zuh(p),3) |
---|
446 | legend_label_zw(p)=round(zwh(p),3) |
---|
447 | end if |
---|
448 | end do |
---|
449 | end if |
---|
450 | |
---|
451 | if (black .eq. 0 ) then |
---|
452 | if (np .EQ. 1)then |
---|
453 | color = 237 |
---|
454 | else |
---|
455 | step=round(235/(np-1),3) |
---|
456 | color = ispan(2,237,step) |
---|
457 | end if |
---|
458 | else |
---|
459 | color = 2 |
---|
460 | end if |
---|
461 | if ( dash .eq. 0 ) then |
---|
462 | res@xyMonoDashPattern = True |
---|
463 | end if |
---|
464 | |
---|
465 | if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then |
---|
466 | format_out@wkPaperSize = "A4" |
---|
467 | end if |
---|
468 | if ( format_out .EQ. "png" ) then |
---|
469 | format_out@wkWidth = 1000 |
---|
470 | format_out@wkHeight = 1000 |
---|
471 | end if |
---|
472 | |
---|
473 | wks=gsn_open_wks(format_out,file_out) |
---|
474 | gsn_define_colormap(wks,"rainbow+white") |
---|
475 | |
---|
476 | n=0 |
---|
477 | do varn =dim-1,0,1 |
---|
478 | |
---|
479 | check = True |
---|
480 | |
---|
481 | if ( isStrSubset( vNam(varn), "time") .OR. \ |
---|
482 | isStrSubset( vNam(varn), "zu_sp") .OR. \ |
---|
483 | isStrSubset( vNam(varn), "zw_sp") .OR. \ |
---|
484 | isStrSubset( vNam(varn), "k_x") .OR. \ |
---|
485 | isStrSubset( vNam(varn), "k_y")) then |
---|
486 | check = False |
---|
487 | end if |
---|
488 | |
---|
489 | if (var .NE. "all") then |
---|
490 | check = isStrSubset( var,","+vNam(varn)+"," ) |
---|
491 | end if |
---|
492 | |
---|
493 | if(check) then |
---|
494 | |
---|
495 | temp = f[:]->$vNam(varn)$ |
---|
496 | data = temp(start_time_step:end_time_step,0:dimz-1,:) |
---|
497 | |
---|
498 | temp_att = f_att->$vNam(varn)$ |
---|
499 | a=getvardims(temp_att) |
---|
500 | b=dimsizes(a) |
---|
501 | delete(temp_att) |
---|
502 | |
---|
503 | if (height_level(0) .NE. -1)then |
---|
504 | do te=0,dimz-1 |
---|
505 | data(:,te,:) = temp(start_time_step:end_time_step,\ |
---|
506 | height_level(te),:) |
---|
507 | end do |
---|
508 | end if |
---|
509 | |
---|
510 | data=data/(norm_y*norm_x) |
---|
511 | |
---|
512 | do i=0,b-1 |
---|
513 | if (isStrSubset( a(i),"zu_sp" ))then |
---|
514 | legend_label_z=legend_label_zu |
---|
515 | if (height_level(0) .NE. -1)then |
---|
516 | z=zuh |
---|
517 | else |
---|
518 | z=zu |
---|
519 | end if |
---|
520 | else |
---|
521 | if (isStrSubset( a(i),"zw_sp" ))then |
---|
522 | legend_label_z=legend_label_zw |
---|
523 | if (height_level(0) .NE. -1)then |
---|
524 | z=zwh |
---|
525 | else |
---|
526 | z=zw |
---|
527 | end if |
---|
528 | end if |
---|
529 | end if |
---|
530 | end do |
---|
531 | |
---|
532 | min_x=new(dimz,double) |
---|
533 | max_x=new(dimz,double) |
---|
534 | min_y=new(dimz,float) |
---|
535 | max_y=new(dimz,float) |
---|
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 |
---|