source: palm/trunk/SCRIPTS/NCL/timeseries.ncl @ 566

Last change on this file since 566 was 566, checked in by heinze, 14 years ago

Formatting of all NCL scripts.
Items of .ncl.config are re-sorted and xyc, xzc and yzc are no parameters any more.
Parameters start_f_1/end_f_1 are renamed to start_f/end_f in profiles.ncl.
Bugfix in cross_sections: enable vector plot if var is set explicitly.
Deletion of NCL user guide because guide is no available online.

File size: 49.6 KB
Line 
1load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"
2load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
4load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
5 
6;***************************************************
7; load .ncl.config or .ncl.config.default
8;***************************************************
9
10function which_script()
11local script
12begin
13   script="timeseries"
14   return(script)
15end
16
17if (isfilepresent("$PALM_BIN/../../.ncl.config")) then
18   loadscript("$PALM_BIN/../../.ncl.config")
19else
20  if (isfilepresent("$PALM_BIN/NCL/.ncl.config.default")) then
21     loadscript( "$PALM_BIN/NCL/.ncl.config.default")
22  else
23      palm_bin_path = getenv("PALM_BIN")
24      print(" ")
25      print("Neither the personal configuration file '.ncl.config' exists in")
26      print("~/palm/current_version")
27      print("nor the default configuration file '.ncl.config.default' "+\
28            "exists in")
29      print(palm_bin_path + "/NCL")
30      print(" ")
31      exit
32   end if
33end if   
34   
35begin
36
37   ;***************************************************
38   ; Retrieving the NCL version used
39   ;***************************************************
40   
41   ncl_version_ch = systemfunc("ncl -V")
42   ncl_version    = stringtofloat(ncl_version_ch)
43
44   ;***************************************************
45   ; Retrieving the double quote character
46   ;***************************************************
47   
48   dq=str_get_dq()
49
50   ;***************************************************
51   ; set up default parameter values and strings
52   ;***************************************************
53   
54   if (file_1 .EQ. "File in") then
55      print(" ")
56      print("Declare input file 'file_1=' in '.ncl.config' or prompt")
57      print(" ")
58      exit
59   else
60      file_in = file_1   
61   end if
62
63   if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND.   \
64       format_out .NE. "eps" .AND. format_out .NE. "ps" .AND.    \
65       format_out .NE. "epsi" .AND. format_out .NE. "ncgm" .AND. \
66       format_out .NE. "png")then
67      print(" ")
68      print("'format_out = "+format_out+"' is invalid and set to'x11'")
69      print(" ")
70      format_out="x11"
71   end if 
72
73   if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then
74      print(" ")
75      print("Output of png files not available")
76      print("png output is avaiable with NCL version 5.2.0 and higher ")
77      print("NCL version used: " + ncl_version_ch)
78      print(" ")
79      exit
80   end if
81
82   if (over .NE. 0 .AND. over .NE. 1) then
83      print(" ")
84      print("'over'= "+over+" is invalid and set to 0")
85      print(" ")
86      over = 0
87   end if 
88   
89   if (norm_t .EQ. 0) then
90      print(" ")
91      print("Normalising with 0 is not allowed, 'norm_t' is set to 1.0")
92      print(" ")
93      norm_t = 1.0
94   end if
95 
96
97   ;***************************************************
98   ; open input file
99   ;***************************************************
100   
101   file_in_1 = False
102   if (isStrSubset(file_in, ".nc"))then
103      start_f = -2
104      end_f = -2
105      file_in_1 = True     
106   end if
107
108   if (start_f .EQ. -1)then
109      print(" ")
110      print("'start_f' must be one of the cyclic numbers (at least 0) of "+\
111            "your input file(s)")
112      print(" ") 
113      exit
114   end if
115   if (end_f .EQ. -1)then
116      print(" ")
117      print("'end_f' must be one of the cyclic numbers (at least 0) of "+\
118            "your input file(s)")
119      print(" ") 
120      exit
121   end if
122
123   files=new(end_f-start_f+1,string)
124
125   if (file_in_1)then
126      if (isfilepresent(file_in))then
127         files(0)=file_in
128      else
129         print(" ")
130         print("1st input file: '"+file_in+"' does not exist")
131         print(" ")
132         exit
133      end if
134   else   
135      if (start_f .EQ. 0)then
136         if (isfilepresent(file_in+".nc"))then
137            files(0)=file_in+".nc"
138            do i=1,end_f
139               if (isfilepresent(file_in+"."+i+".nc"))then   
140                  files(i)=file_in+"."+i+".nc"
141               else
142                  print(" ")
143                  print("Input file: '"+file_in+"."+i+".nc' does not exist")
144                  print(" ")
145                  exit 
146               end if       
147            end do         
148         else
149            print(" ")
150            print("Input file: '"+file_in+".nc' does not exist")
151            print(" ")
152            exit
153         end if
154      else
155         do i=start_f,end_f
156            if (isfilepresent(file_in+"."+i+".nc"))then   
157               files(i-start_f)=file_in+"."+i+".nc"
158            else
159               print(" ")
160               print("Input file: '"+file_in+"."+i+".nc' does not exist")
161               print(" ")
162               exit 
163            end if
164         end do
165      end if
166   end if
167
168   f=addfiles(files,"r")
169   f_att=addfile(files(0),"r")
170   ListSetType(f,"cat")
171
172   vNam=getfilevarnames(f_att)
173   vNam_static=vNam
174
175   print(" ")
176   print("Variables in input file:")
177   print("- "+ vNam)
178   print(" ")
179   dim = dimsizes(vNam)
180   if (dim .EQ. 0) then
181      print(" ")
182      print("There is no data on file")
183      print(" ")
184   end if
185
186   t_all   = f[:]->time
187   nt      = dimsizes(t_all)
188   delta_t = t_all(nt-1)/nt
189
190   ;****************************************************       
191   ; start of time step and different types of mistakes that could be done
192   ;****************************************************
193
194   if (start_time_step .EQ. -1.) then           
195      start_time_step=t_all(0)/3600     
196   else
197      if (start_time_step .GE. t_all(nt-1)/3600)
198         print(" ")
199         print("'start_time_step' = "+ start_time_step +\
200               "h is equal or greater than last time step = " + \
201               t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h")
202         print(" ")
203         print("Select another 'start_time_step'")
204         print(" ")
205         exit
206      end if
207      if (start_time_step .LT. t_all(0)/3600)
208         print(" ")
209         print("'start_time_step' = "+ start_time_step +\
210               "h is lower than first time step = " + t_all(0)+"s = "+\
211               t_all(0)/3600+"h")
212         print(" ")
213         print("Select another 'start_time_step'")
214         print(" ")
215         exit
216      end if
217   end if
218   do i=0,nt-2     
219      if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \
220          start_time_step .LT. (t_all(i)+delta_t/2)/3600)then
221         st=i
222         break
223      end if
224   end do
225   if (start_time_step .GE. t_all(nt-1)-delta_t/2 .AND. \
226       start_time_step .LT. t_all(nt-1)) then
227      st=nt-2   
228   end if
229   if (.not. isvar("st"))then
230      print(" ")
231      print("'start_time_step' = "+ start_time_step +"h is invalid")
232      print(" ")
233      print("Select another 'start_time_step'")
234      print(" ")
235      exit
236   end if
237     
238   ;****************************************************
239   ; end of time step and different types of mistakes that could be done
240   ;****************************************************
241
242   if (end_time_step .EQ. -1.) then             
243      end_time_step = t_all(nt-1)/3600 
244   else
245      if (end_time_step .LE. t_all(0)/3600)
246         print(" ")
247         print("'end_time_step' = "+end_time_step+ \
248              "h is lower or equal than first time step = " + \
249               t_all(0)+"s = "+t_all(0)/3600+"h")
250         print(" ")
251         print("Select another 'end_time_step'")
252         print(" ")
253         exit
254      end if
255      if (end_time_step .GT. t_all(nt-1)/3600)
256         print(" ")
257         print("'end_time_step' = "+ end_time_step +\
258               "h is greater than last time step = " + t_all(nt-1)+"s = "+\
259               t_all(nt-1)/3600+"h")
260         print(" ")
261         print("Select another 'end_time_step'") 
262         print(" ")
263         exit
264      end if
265      if (end_time_step .LE. start_time_step/3600)
266         print(" ")
267         print("'end_time_step' = "+ end_time_step +\
268               "h is equal or lower than 'start_time_step' = "+\
269               start_time_step+"h")
270         print(" ")
271         print("Select another 'start_time_step' or 'end_time_step'")
272         print(" ")
273         exit
274      end if
275   end if
276   do i=0,nt-1     
277      if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \
278          end_time_step .LT. (t_all(i)+delta_t/2)/3600)then
279         et=i
280         break
281      end if
282   end do
283   
284   if (.not. isvar("et"))then
285      print(" ")
286      print("'end_time_step' = "+ end_time_step +"h is invalid")
287      print(" ")
288      print("Select another 'end_time_step'")
289      print(" ")
290      exit
291   end if
292 
293   delete(start_time_step)
294   start_time_step=round(st,3)
295   delete(end_time_step)
296   end_time_step=round(et,3)
297
298   print(" ")
299   print("Output of time steps from "+t_all(start_time_step)/3600+" h = "+\
300         t_all(start_time_step)+" s => index = "+start_time_step)
301   print("                     till "+t_all(end_time_step)/3600+" h = "+\
302         t_all(end_time_step)+" s => index = "+end_time_step)
303   print(" ")
304
305   t = t_all(start_time_step:end_time_step)/norm_t
306 
307   ; ***************************************************
308   ; set up recourses
309   ; ***************************************************
310
311   res                         = True
312   res@gsnDraw                 = False
313   res@gsnFrame                = False
314   res@tmXBMode                = True
315   res@tmYLMode                = True
316   res@txFont                  = "helvetica"
317   res@tiMainFont              = "helvetica"
318   res@tiXAxisFont             = "helvetica"
319   res@tiYAxisFont             = "helvetica"
320   res@tmXBLabelFont           = "helvetica"
321   res@tmYLLabelFont           = "helvetica"
322   res@xyLineColors            = (/237/)
323   res@trXMaxF                 = t_all(start_time_step)
324   res@trXMinF                 = t_all(end_time_step)
325   
326   res@lgLabelFontHeightF     = 0.02
327
328   resP                        = True
329   resP@txFont                 = "helvetica"
330   resP@txString               = f_att@title+" time series "
331   resP@txFuncCode             = "~"
332   resP@txFontHeightF          = 0.015
333
334   res@tmXBMinorPerMajor = 4
335   res@tmYLMinorPerMajor = 4
336
337   res@vpWidthF=4
338
339   txres = True
340
341   ; ***************************************************
342   ; read data and create plots
343   ; ***************************************************
344   
345   if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then
346      format_out@wkPaperSize = "A4"
347   end if
348   if ( format_out .EQ. "png" ) then
349      format_out@wkWidth  = 1000
350      format_out@wkHeight = 1000
351   end if
352
353   wks_ps = gsn_open_wks(format_out,file_out)           
354   gsn_define_colormap(wks_ps,"rainbow+white")
355   plot_ps=new(dim,graphic)
356                                 
357   n=0
358   minE=1.E27
359   maxE=-1.E27
360   minus=1.E27
361   maxus=-1.E27
362   minu=1.E27
363   maxu=-1.E27
364   minz=1.E27
365   maxz=-1.E27
366   minw=1.E27
367   maxw=-1.E27
368   minp=1.E27
369   maxp=-1.E27
370   mins=1.E27
371   maxs=-1.E27
372
373   data   = new((/dim,(end_time_step-start_time_step)+1/),float)
374   unit   = new(dim,string)
375   data_0 = new((end_time_step-start_time_step)+1,float)
376   data_0 = 0.0
377   mini   = new(dim,float)
378   maxi   = new(dim,float)
379   
380   if (over .EQ. 1) then
381      plot_E       = gsn_csm_xy(wks_ps,t,data_0(:),res)
382      plot_Es      = gsn_csm_xy(wks_ps,t,data_0(:),res)
383      plot_us      = gsn_csm_xy(wks_ps,t,data_0(:),res)
384      plot_ws      = gsn_csm_xy(wks_ps,t,data_0(:),res)
385      plot_umax    = gsn_csm_xy(wks_ps,t,data_0(:),res)
386      plot_vmax    = gsn_csm_xy(wks_ps,t,data_0(:),res)
387      plot_wmax    = gsn_csm_xy(wks_ps,t,data_0(:),res)
388      plot_z_i_wpt = gsn_csm_xy(wks_ps,t,data_0(:),res)
389      plot_z_i_pt  = gsn_csm_xy(wks_ps,t,data_0(:),res)
390      plot_wpptp0  = gsn_csm_xy(wks_ps,t,data_0(:),res)
391      plot_wpptp   = gsn_csm_xy(wks_ps,t,data_0(:),res)
392      plot_wpt     = gsn_csm_xy(wks_ps,t,data_0(:),res)
393      plot_pt_0_   = gsn_csm_xy(wks_ps,t,data_0(:),res)
394      plot_pt_zp_  = gsn_csm_xy(wks_ps,t,data_0(:),res)
395   end if
396
397
398   if (var .NE. "all") then
399      vNam_temp = new((/dim/),string)
400      comma     = 0
401      var_char  = stringtocharacter(var)
402      no_char   = dimsizes(var_char)
403       
404      do j = 0, no_char-1
405         if(var_char(j) .eq. ",")
406            comma = comma + 1
407         end if
408      end do
409
410      if(comma .eq. 0 .or. comma .eq. 1)
411          print(" ")
412          print("The variables 'var="+var+"'" )
413          print("do not exist on your input file;")
414          print("be sure to have one comma before and after each variable")
415          print(" ")
416          exit
417      end if
418
419      indices = new((/comma/), integer)
420      comma   = 0
421       
422      do j = 0, no_char-1
423         if(var_char(j) .eq. ",")
424           indices(comma) = j
425           comma = comma + 1
426         end if
427      end do
428
429      do j = 0, comma -2
430         vNam_temp(j) = charactertostring(\
431                                   var_char(indices(j)+1:indices(j+1)-1))
432      end do
433     
434      delete(vNam)
435      vNam = new((/comma-1/),string)
436      do varn = 0, comma - 2
437         vNam(varn) = vNam_temp(comma - 2 - varn)
438      end do
439     
440      do j = 0, comma-2
441        count_check = 0
442        do varn = 0, dim-1
443           if(vNam(j) .ne. vNam_static(varn))
444             count_check=count_check+1
445           end if
446        end do   
447
448        if(count_check .eq. dim)
449            print(" ")
450            print("The variables 'var="+var+"'" )
451            print("do not exist on your input file;")
452            print("be sure to have one comma before and after each variable")
453            print(" ")
454            exit
455        end if
456      end do
457
458      dim = comma-1
459    end if
460
461
462   do varn = dim-1, 0, 1
463
464      if( isStrSubset (vNam(varn), "time") )
465         check = False
466      else
467         check = True
468      end if
469     
470      if(check) then
471
472         data_all = f[:]->$vNam(varn)$
473         data_att = f_att->$vNam(varn)$
474         unit(varn) = data_att@units
475 
476     
477         data(varn,:)=data_all(start_time_step:end_time_step)
478         
479         if (over .EQ. 1) then
480
481            mini(varn) = min(data(varn,:))
482            maxi(varn) = max(data(varn,:))
483           
484            if (vNam(varn) .EQ. "E" .OR. vNam(varn) .EQ. "Es" .OR. \
485                vNam(varn) .EQ. "E*") then
486               if (mini(varn) .EQ. maxi(varn)) then
487                  if (min(data(varn,:)) .EQ. 0)then
488                     mini(varn)= mini(varn)-0.1
489                     maxi(varn)= maxi(varn)+0.1
490                  end if
491                  if (min(data(varn,:)) .LT. 0)then
492                     mini(varn)= mini(varn)-1.+(mini(varn))/2
493                     maxi(varn)= maxi(varn)+1.-(maxi(varn))/2
494                  end if
495                  if (min(data(varn,:)) .GT. 0)then
496                     mini(varn)= mini(varn)-1.-(mini(varn))/2
497                     maxi(varn)= maxi(varn)+1.+(maxi(varn))/2
498                  end if
499               end if
500               minE=min((/minE,mini(varn)/))
501               maxE=max((/maxE,maxi(varn)/))
502            end if
503
504            if (vNam(varn) .EQ. "us" .OR. vNam(varn) .EQ. "ws"\
505                .OR. vNam(varn) .EQ. "u*" .OR. vNam(varn) .EQ. "w*") then
506               if (mini(varn) .EQ. maxi(varn)) then
507                  if (min(data(varn,:)) .EQ. 0)then
508                     mini(varn)= mini(varn)-0.1
509                     maxi(varn)= maxi(varn)+0.1
510                  end if
511                  if (min(data(varn,:)) .LT. 0)then
512                     mini(varn)= mini(varn)-1.+(mini(varn))/2
513                     maxi(varn)= maxi(varn)+1.-(maxi(varn))/2
514                  end if
515                  if (min(data(varn,:)) .GT. 0)then
516                     mini(varn)= mini(varn)-1.-(mini(varn))/2
517                     maxi(varn)= maxi(varn)+1.+(maxi(varn))/2
518                  end if
519               end if
520               minus=min((/minus,mini(varn)/))
521               maxus=max((/maxus,maxi(varn)/))
522            end if
523
524            if (vNam(varn) .EQ. "umax" .OR. vNam(varn) .EQ. "vmax" .OR. \
525                vNam(varn) .EQ. "wmax") then
526               if (mini(varn) .EQ. maxi(varn)) then
527                  if (mini(varn) .EQ. 0)then
528                     mini(varn)= mini(varn)-0.1
529                     maxi(varn)= maxi(varn)+0.1
530                  end if
531                  if (mini(varn) .LT. 0)then
532                     mini(varn)= mini(varn)-1.+(mini(varn))/2
533                     maxi(varn)= maxi(varn)+1.-(maxi(varn))/2
534                  end if
535                  if (mini(varn) .GT. 0)then
536                     mini(varn)= mini(varn)-1.-(mini(varn))/2
537                     maxi(varn)= maxi(varn)+1.+(maxi(varn))/2
538                  end if
539               end if
540               minu=min((/minu,mini(varn)/))
541               maxu=max((/maxu,maxi(varn)/))
542            end if
543
544            if (vNam(varn) .EQ. "z_i_wpt" .OR. vNam(varn) .EQ. "z_i_pt") then
545               if (mini(varn) .EQ. maxi(varn)) then
546                  if (min(data(varn,:)) .EQ. 0)then
547                     mini(varn)= mini(varn)-0.1
548                     maxi(varn)= maxi(varn)+0.1
549                  end if
550                  if (min(data(varn,:)) .LT. 0)then
551                     mini(varn)= mini(varn)-1.+(mini(varn))/2
552                     maxi(varn)= maxi(varn)+1.-(maxi(varn))/2
553                  end if
554                  if (min(data(varn,:)) .GT. 0)then
555                     mini(varn)= mini(varn)-1.-(mini(varn))/2
556                     maxi(varn)= maxi(varn)+1.+(maxi(varn))/2
557                  end if
558               end if
559               minz=min((/minz,mini(varn)/))
560               maxz=max((/maxz,maxi(varn)/))
561            end if
562
563            if (vNam(varn) .EQ. "wpptp0" .OR. vNam(varn) .EQ. "wpptp" .OR. \
564                vNam(varn) .EQ. "wpt" .OR. vNam(varn) .EQ. \
565                "w"+dq+"pt"+dq+"0" .OR. vNam(varn) .EQ. "w"+dq+"pt"+dq ) then
566               if (mini(varn) .EQ. maxi(varn)) then
567                  if (min(data(varn,:)) .EQ. 0)then
568                     mini(varn)= mini(varn)-0.1
569                     maxi(varn)= maxi(varn)+0.1
570                  end if
571                  if (min(data(varn,:)) .LT. 0)then
572                     mini(varn)= mini(varn)-1.+(mini(varn))/2
573                     maxi(varn)= maxi(varn)+1.-(maxi(varn))/2
574                  end if
575                  if (min(data(varn,:)) .GT. 0)then
576                     mini(varn)= mini(varn)-1.-(mini(varn))/2
577                     maxi(varn)= maxi(varn)+1.+(maxi(varn))/2
578                  end if
579               end if
580               minw=min((/minw,mini(varn)/))
581               maxw=max((/maxw,maxi(varn)/))
582            end if
583
584            if (vNam(varn) .EQ. "pt_0_" .OR. vNam(varn) .EQ. "pt_zp_"\
585               .OR. vNam(varn) .EQ. "pt(0)" .OR. vNam(varn) .EQ. "pt(zp)") then
586               if (mini(varn) .EQ. maxi(varn)) then
587                  if (min(data(varn,:)) .EQ. 0)then
588                     mini(varn)= mini(varn)-0.1
589                     maxi(varn)= maxi(varn)+0.1
590                  end if
591                  if (min(data(varn,:)) .LT. 0)then
592                     mini(varn)= mini(varn)-1.+(mini(varn))/2
593                     maxi(varn)= maxi(varn)+1.-(maxi(varn))/2
594                  end if
595                  if (min(data(varn,:)) .GT. 0)then
596                     mini(varn)= mini(varn)-1.-(mini(varn))/2
597                     maxi(varn)= maxi(varn)+1.+(maxi(varn))/2
598                  end if
599               end if
600               minp=min((/minp,mini(varn)/))
601               maxp=max((/maxp,maxi(varn)/))
602            end if
603           
604         end if
605      end if
606   end do
607 
608  if (isStrSubset(data@long_name," SR " ))then
609      print(" ")
610      print("If you have outputs of statistic regions you cannot overlay "+\
611            "variables;")
612      print("'over' is set to 0" )
613      print(" ")
614      over = 0
615   end if
616
617   do varn = dim-1, 0, 1
618     
619      if( isStrSubset (vNam(varn), "time") )
620         check = False
621      else
622         check = True
623      end if     
624   
625      if (var .NE. "all") then
626         check = isStrSubset( var,","+vNam(varn)+"," )
627      end if
628 
629      if(check) then
630       
631        if (over .EQ. 1) then
632 
633            res@gsnLeftString       = "overlayed plot"
634            res@gsnRightString      = unit(varn)
635            if (norm_t .NE. 1.)then
636               res@tiXAxisString        = "t ("+unit_t+")"
637            else
638               res@tiXAxisString        = "t (s)"
639            end if
640            res@tiYAxisString = " "
641            res@tiXAxisFontHeightF   = font_size
642            res@txFontHeightF        = font_size
643            res@tiYAxisFontHeightF   = font_size           
644
645            if (vNam(varn) .EQ. "E")
646               E=0
647               res@xyLineColors     = (/237/)
648               res@xyLineLabelFontHeightF = 0.05
649               res@xyLineLabelFontColor   = 237
650               res@trYMaxF           = maxE
651               res@trYMinF           = minE
652               plot_E = gsn_csm_xy(wks_ps,t,data(varn,:),res)
653            end if
654            if (vNam(varn) .EQ. "Es" .OR. vNam(varn) .EQ. "E*")
655               Es=0
656               res@xyLineColors            = (/144/)
657               res@xyLineLabelFontHeightF = 0.05
658               res@xyLineLabelFontColor   = 144
659               plot_Es = gsn_csm_xy(wks_ps,t,data(varn,:),res)
660            end if
661             
662            if (vNam(varn) .EQ. "us" .OR. vNam(varn) .EQ. "u*")
663               us=0
664               res@xyLineColors            = (/237/)
665               res@xyLineLabelFontHeightF = 0.05
666               res@xyLineLabelFontColor   = 237
667               res@trYMaxF           = maxus
668               res@trYMinF           = minus
669               plot_us = gsn_csm_xy(wks_ps,t,data(varn,:),res)
670            end if             
671            if (vNam(varn) .EQ. "ws" .OR. vNam(varn) .EQ. "w*")
672               ws=0
673               res@xyLineColors            = (/144/)
674               res@xyLineLabelFontHeightF = 0.05
675               res@xyLineLabelFontColor   = 144
676               plot_ws = gsn_csm_xy(wks_ps,t,data(varn,:),res)
677            end if
678             
679            if (vNam(varn) .EQ. "umax")
680               u=0
681               res@xyLineColors            = (/237/)
682               res@xyLineLabelFontHeightF = 0.05
683               res@xyLineLabelFontColor   = 237
684               res@trYMaxF           = maxu
685               res@trYMinF           = minu
686               plot_umax = gsn_csm_xy(wks_ps,t,data(varn,:),res)
687            end if
688            if (vNam(varn) .EQ. "vmax")
689               v=0
690               res@xyLineColors            = (/144/)
691               res@xyLineLabelFontHeightF = 0.05
692               res@xyLineLabelFontColor   = 144
693               plot_vmax = gsn_csm_xy(wks_ps,t,data(varn,:),res)
694            end if
695            if (vNam(varn) .EQ. "wmax")
696               w=0
697               res@xyLineColors            = (/80/)
698               res@xyLineLabelFontHeightF = 0.05
699               res@xyLineLabelFontColor   = 80
700               plot_wmax = gsn_csm_xy(wks_ps,t,data(varn,:),res)
701            end if
702   
703            if (vNam(varn) .EQ. "z_i_wpt")
704               zw=0
705               res@xyLineColors            = (/237/)
706               res@xyLineLabelFontHeightF = 0.05
707               res@xyLineLabelFontColor   = 237
708               res@trYMaxF           = maxz
709               res@trYMinF           = minz
710               plot_z_i_wpt = gsn_csm_xy(wks_ps,t,data(varn,:),res)
711            end if
712            if (vNam(varn) .EQ. "z_i_pt")
713               z=0
714               res@xyLineColors            = (/144/) 
715               res@xyLineLabelFontHeightF = 0.05
716               res@xyLineLabelFontColor   = 144
717               plot_z_i_pt = gsn_csm_xy(wks_ps,t,data(varn,:),res)
718            end if
719
720            if (vNam(varn) .EQ. "wpptp0" .OR. \
721                vNam(varn) .EQ. "w"+dq+"pt"+dq+"0" )
722               w0=0
723               res@xyLineColors            = (/237/)
724               res@xyLineLabelFontHeightF = 0.05
725               res@xyLineLabelFontColor   = 237
726               res@trYMaxF           = maxw
727               res@trYMinF           = minw
728               plot_wpptp0 = gsn_csm_xy(wks_ps,t,data(varn,:),res)
729            end if
730            if (vNam(varn) .EQ. "wpptp" .OR. vNam(varn) .EQ. "w"+dq+"pt"+dq)
731               wp=0
732               res@xyLineColors            = (/144/)
733               res@xyLineLabelFontHeightF = 0.05
734               res@xyLineLabelFontColor   = 144
735               plot_wpptp = gsn_csm_xy(wks_ps,t,data(varn,:),res) 
736            end if
737            if (vNam(varn) .EQ. "wpt")
738               wt=0
739               res@xyLineColors            = (/80/)
740               res@xyLineLabelFontHeightF = 0.05
741               res@xyLineLabelFontColor   = 80
742               plot_wpt = gsn_csm_xy(wks_ps,t,data(varn,:),res)
743            end if
744
745            if (vNam(varn) .EQ. "pt_0_" .OR. vNam(varn) .EQ. "pt(0)")
746               p=0
747               res@xyLineColors            = (/237/)
748               res@xyLineLabelFontHeightF = 0.05
749               res@xyLineLabelFontColor   = 237
750               res@trYMaxF           = maxp
751               res@trYMinF           = minp
752               plot_pt_0_ = gsn_csm_xy(wks_ps,t,data(varn,:),res) 
753            end if
754            if (vNam(varn) .EQ. "pt_zp_" .OR. vNam(varn) .EQ. "pt(zp)")
755               pz=0
756               res@xyLineColors            = (/144/)
757               res@xyLineLabelFontHeightF = 0.05
758               res@xyLineLabelFontColor   = 144
759               plot_pt_zp_ = gsn_csm_xy(wks_ps,t,data(varn,:),res)
760            end if
761
762         end if
763      end if
764   end do
765
766
767   do varn = dim-1, 0, 1
768   
769      if( isStrSubset (vNam(varn), "time") )
770         check = False
771      else
772         check = True
773      end if   
774 
775      if (var.NE. "all") then
776         check = isStrSubset( var,","+vNam(varn)+"," )
777      end if
778   
779      if(check) then
780       
781         if (over .EQ. 1) then       
782       
783            if (vNam(varn) .EQ. "E" .AND. Es .NE. 1) then
784               E=1   
785               overlay(plot_E,plot_Es)
786               n=n+1
787               plot_ps(n) = plot_E   
788
789               ; ***************************************************
790               ; legend for overlaid plot
791               ; ***************************************************
792     
793               lgres                    = True
794               lgMonoDashIndex          = False
795               lgres@lgLabelFont        = "helvetica"   
796               lgres@lgLabelFontHeightF = .1           
797               lgres@vpWidthF           = 0.4           
798               lgres@vpHeightF          = 0.4         
799               lgres@lgDashIndexes      = (/0,0,0/)
800               lgres@lgLineColors       = (/237,144,80/)
801               lbid = gsn_create_legend(wks_ps,2,(/"E","E*"/),lgres)       
802
803               amres = True
804               amres@amParallelPosF   = 0.6                 
805               amres@amOrthogonalPosF = -0.2           
806               annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)           
807            end if
808            if ((vNam(varn) .EQ. "Es" .OR. vNam(varn) .EQ. "E*") .AND. \
809                E .NE. 1) then
810               Es=1
811               overlay(plot_E,plot_Es)
812               n=n+1
813               plot_ps(n) = plot_E 
814
815               ; ***************************************************
816               ; legend for overlaid plot
817               ; ***************************************************
818     
819               lgres                    = True
820               lgMonoDashIndex          = False
821               lgres@lgLabelFont        = "helvetica"   
822               lgres@lgLabelFontHeightF = .1           
823               lgres@vpWidthF           = 0.4           
824               lgres@vpHeightF          = 0.4         
825               lgres@lgDashIndexes      = (/0,0,0/)
826               lgres@lgLineColors       = (/237,144,80/)
827               lbid = gsn_create_legend(wks_ps,2,(/"E","E*"/),lgres)       
828
829               amres = True
830               amres@amParallelPosF   = 0.6                 
831               amres@amOrthogonalPosF = -0.2           
832               annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)         
833            end if
834
835            if ((vNam(varn) .EQ. "us" .OR. vNam(varn) .EQ. "u*") .AND. \
836                 ws .NE. 1) then
837               us=1
838               overlay(plot_us,plot_ws)
839               n=n+1
840               plot_ps(n) = plot_us
841
842               ; ***************************************************
843               ; legend for overlaid plot
844               ; ***************************************************
845     
846               lgres                    = True
847               lgMonoDashIndex          = False
848               lgres@lgLabelFont        = "helvetica"   
849               lgres@lgLabelFontHeightF = .1           
850               lgres@vpWidthF           = 0.4           
851               lgres@vpHeightF          = 0.4         
852               lgres@lgDashIndexes      = (/0,0,0/)
853               lgres@lgLineColors       = (/237,144,80/)
854               lbid = gsn_create_legend(wks_ps,2,(/"u*","w*"/),lgres)       
855
856               amres = True
857               amres@amParallelPosF   = 0.6                 
858               amres@amOrthogonalPosF = -0.2           
859               annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
860            end if
861            if ((vNam(varn) .EQ. "ws" .OR. vNam(varn) .EQ. "w*") .AND. \
862                 us .NE. 1) then
863               ws=1
864               overlay(plot_us,plot_ws)
865               n=n+1
866               plot_ps(n) = plot_us
867
868               ; ***************************************************
869               ; legend for overlaid  plot
870               ; ***************************************************
871     
872               lgres                    = True
873               lgMonoDashIndex          = False
874               lgres@lgLabelFont        = "helvetica"   
875               lgres@lgLabelFontHeightF = .1           
876               lgres@vpWidthF           = 0.4           
877               lgres@vpHeightF          = 0.4         
878               lgres@lgDashIndexes      = (/0,0,0/)
879               lgres@lgLineColors       = (/237,144,80/)
880               lbid = gsn_create_legend(wks_ps,2,(/"u*","w*"/),lgres)       
881
882               amres = True
883               amres@amParallelPosF   = 0.6                 
884               amres@amOrthogonalPosF = -0.2           
885               annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
886            end if
887         
888            if (vNam(varn) .EQ. "umax" .AND. v .NE. 1)
889               if (w .NE. 1) then
890                  u=1         
891                  overlay(plot_umax,plot_vmax)
892                  overlay(plot_umax,plot_wmax)
893               
894                  n=n+1
895                  plot_ps(n) = plot_umax
896
897                  ; ***************************************************
898                  ; legend for overlaid plot
899                  ; ***************************************************
900     
901                  lgres                    = True
902                  lgMonoDashIndex          = False
903                  lgres@lgLabelFont        = "helvetica"   
904                  lgres@lgLabelFontHeightF = .1           
905                  lgres@vpWidthF           = 0.4           
906                  lgres@vpHeightF          = 0.4         
907                  lgres@lgDashIndexes      = (/0,0,0/)
908                  lgres@lgLineColors       = (/237,144,80/)
909                  lbid = gsn_create_legend(\
910                                  wks_ps,3,(/"umax","vmax","wmax"/),lgres)
911
912                  amres = True
913                  amres@amParallelPosF   = 0.6             
914                  amres@amOrthogonalPosF = -0.2           
915                  annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
916               end if
917            end if
918            if (vNam(varn) .EQ. "vmax" .AND. u .NE. 1)
919               if (w .NE. 1) then
920                  v=1 
921                  overlay(plot_umax,plot_vmax)
922                  overlay(plot_umax,plot_wmax)
923                  n=n+1
924                  plot_ps(n) = plot_umax
925
926                  ; ***************************************************
927                  ; legend for overlaid plot
928                  ; ***************************************************
929     
930                  lgres                    = True
931                  lgMonoDashIndex          = False
932                  lgres@lgLabelFont        = "helvetica"   
933                  lgres@lgLabelFontHeightF = .1         
934                  lgres@vpWidthF           = 0.4           
935                  lgres@vpHeightF          = 0.4         
936                  lgres@lgDashIndexes      = (/0,0,0/)
937                  lgres@lgLineColors       = (/237,144,80/)
938                  lbid = gsn_create_legend(\
939                                      wks_ps,3,(/"umax","vmax","wmax"/),lgres)
940                  amres = True
941                  amres@amParallelPosF   = 0.6             
942                  amres@amOrthogonalPosF = -0.2           
943                  annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
944               end if
945            end if
946            if (vNam(varn) .EQ. "wmax" .AND. v .NE. 1)
947               if(u .NE. 1) then 
948                  w=1       
949                  overlay(plot_umax,plot_vmax)
950                  overlay(plot_umax,plot_wmax)
951                  n=n+1
952                  plot_ps(n) = plot_umax
953
954                  ; ***************************************************
955                  ; legend for overlaid plot
956                  ; ***************************************************
957     
958                  lgres                    = True
959                  lgMonoDashIndex          = False
960                  lgres@lgLabelFont        = "helvetica"   
961                  lgres@lgLabelFontHeightF = .1           
962                  lgres@vpWidthF           = 0.4           
963                  lgres@vpHeightF          = 0.4         
964                  lgres@lgDashIndexes      = (/0,0,0/)
965                  lgres@lgLineColors       = (/237,144,80/)
966                  lbid = gsn_create_legend(\
967                                       wks_ps,3,(/"umax","vmax","wmax"/),lgres)
968                  amres = True
969                  amres@amParallelPosF   = 0.6             
970                  amres@amOrthogonalPosF = -0.2           
971                  annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
972               end if
973            end if
974           
975            if (vNam(varn) .EQ. "z_i_wpt" .AND. z .NE. 1) then
976               zw=1       
977               overlay(plot_z_i_wpt,plot_z_i_pt)
978               n=n+1
979               plot_ps(n) = plot_z_i_wpt
980       
981               ; ***************************************************
982               ; legend for overlaid plot
983               ; ***************************************************
984     
985               lgres                    = True
986               lgMonoDashIndex          = False
987               lgres@lgLabelFont        = "helvetica"   
988               lgres@lgLabelFontHeightF = .1           
989               lgres@vpWidthF           = 0.4           
990               lgres@vpHeightF          = 0.4         
991               lgres@lgDashIndexes      = (/0,0,0/)
992               lgres@lgLineColors       = (/237,144,80/)
993               lbid = gsn_create_legend(wks_ps,2,(/"z_i_wpt","z_i_pt"/),lgres)
994
995               amres = True
996               amres@amParallelPosF   = 0.6                 
997               amres@amOrthogonalPosF = -0.2           
998               annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)         
999            end if
1000            if (vNam(varn) .EQ. "z_i_pt" .AND. zw .NE. 1) then
1001               z=1     
1002               overlay(plot_z_i_wpt,plot_z_i_pt)
1003               n=n+1
1004               plot_ps(n) = plot_z_i_wpt
1005
1006               ; ***************************************************
1007               ; legend for overlaid plot
1008               ; ***************************************************
1009     
1010               lgres                    = True
1011               lgMonoDashIndex          = False
1012               lgres@lgLabelFont        = "helvetica"   
1013               lgres@lgLabelFontHeightF = .1           
1014               lgres@vpWidthF           = 0.4           
1015               lgres@vpHeightF          = 0.4         
1016               lgres@lgDashIndexes      = (/0,0,0/)
1017               lgres@lgLineColors       = (/237,144,80/)
1018               lbid = gsn_create_legend(wks_ps,2,(/"z_i_wpt","z_i_pt"/),lgres)
1019
1020               amres = True
1021               amres@amParallelPosF   = 0.6                 
1022               amres@amOrthogonalPosF = -0.2           
1023               annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)           
1024            end if   
1025         
1026            if ((vNam(varn) .EQ. "wpptp0" .OR. vNam(varn) .EQ. "w"+dq+"pt"+dq+"0") .AND. wp .NE. 1)
1027               if (wt .NE. 1) then
1028                  w0=1
1029                  overlay(plot_wpptp0,plot_wpptp)
1030                  overlay(plot_wpptp0,plot_wpt)
1031                  n=n+1
1032                  plot_ps(n) = plot_wpptp0
1033
1034                  ; ***************************************************
1035                  ; legend for overlaid plot
1036                  ; ***************************************************
1037     
1038                  lgres                    = True
1039                  lgMonoDashIndex          = False
1040                  lgres@lgLabelFont        = "helvetica"   
1041                  lgres@lgLabelFontHeightF = .1           
1042                  lgres@vpWidthF           = 0.4           
1043                  lgres@vpHeightF          = 0.4         
1044                  lgres@lgDashIndexes      = (/0,0,0/)
1045                  lgres@lgLineColors       = (/237,144,80/)
1046                  lbid = gsn_create_legend(\
1047                                    wks_ps,3,(/"wpptp0","wpptp","wpt"/),lgres)
1048                  amres = True
1049                  amres@amParallelPosF   = 0.6             
1050                  amres@amOrthogonalPosF = -0.2           
1051                  annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
1052               end if           
1053            end if
1054            if ((vNam(varn) .EQ. "wpptp" .OR. \
1055                 vNam(varn) .EQ. "w"+dq+"pt"+dq) .AND. w0 .NE. 1)
1056               if (wt .NE. 1) then
1057                 wp=1
1058                 overlay(plot_wpptp0,plot_wpptp)
1059                 overlay(plot_wpptp0,plot_wpt)
1060                 n=n+1
1061                 plot_ps(n) = plot_wpptp0
1062                 
1063                 ; ***************************************************
1064                  ; legend for overlaid plot
1065                  ; ***************************************************
1066     
1067                  lgres                    = True
1068                  lgMonoDashIndex          = False
1069                  lgres@lgLabelFont        = "helvetica"   
1070                  lgres@lgLabelFontHeightF = .1           
1071                  lgres@vpWidthF           = 0.4           
1072                  lgres@vpHeightF          = 0.4         
1073                  lgres@lgDashIndexes      = (/0,0,0/)
1074                  lgres@lgLineColors       = (/237,144,80/)
1075                  lbid = gsn_create_legend(\
1076                                     wks_ps,3,(/"wpptp0","wpptp","wpt"/),lgres)
1077
1078                  amres = True
1079                  amres@amParallelPosF   = 0.6             
1080                  amres@amOrthogonalPosF = -0.2           
1081                  annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres) 
1082               end if           
1083            end if
1084            if (vNam(varn) .EQ. "wpt" .AND. wp .NE. 1)
1085               if (w0 .NE. 1) then
1086                  wt=1
1087                  overlay(plot_wpptp0,plot_wpptp)
1088                  overlay(plot_wpptp0,plot_wpt)
1089                  n=n+1
1090                  plot_ps(n) = plot_wpptp0
1091
1092                  ; ***************************************************
1093                  ; legend for overlaid plot
1094                  ; ***************************************************
1095     
1096                  lgres                    = True
1097                  lgMonoDashIndex          = False
1098                  lgres@lgLabelFont        = "helvetica"   
1099                  lgres@lgLabelFontHeightF = .1           
1100                  lgres@vpWidthF           = 0.4           
1101                  lgres@vpHeightF          = 0.4         
1102                  lgres@lgDashIndexes      = (/0,0,0/)
1103                  lgres@lgLineColors       = (/237,144,80/)
1104                  lbid = gsn_create_legend(\
1105                                  wks_ps,3,(/"wpptp0","wpptp","wpt"/),lgres)
1106                  amres = True
1107                  amres@amParallelPosF   = 0.6             
1108                  amres@amOrthogonalPosF = -0.2           
1109                  annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
1110               end if
1111            end if
1112
1113            if ((vNam(varn) .EQ. "pt_0_" .OR. vNam(varn) .EQ. "pt(0)") .AND. \
1114                pz .NE. 1) then
1115               p=1     
1116               overlay(plot_pt_0_,plot_pt_zp_)
1117               n=n+1
1118               plot_ps(n) = plot_pt_0_ 
1119     
1120               ; ***************************************************
1121               ; legend for overlaid plot
1122               ; ***************************************************
1123     
1124               lgres                    = True
1125               lgMonoDashIndex          = False
1126               lgres@lgLabelFont        = "helvetica"   
1127               lgres@lgLabelFontHeightF = .1           
1128               lgres@vpWidthF           = 0.4           
1129               lgres@vpHeightF          = 0.4         
1130               lgres@lgDashIndexes      = (/0,0,0/)
1131               lgres@lgLineColors       = (/237,144,80/)
1132               lbid = gsn_create_legend(wks_ps,2,(/"pt_0_","pt_zp_"/),lgres)
1133
1134               amres = True
1135               amres@amParallelPosF   = 0.6                 
1136               amres@amOrthogonalPosF = -0.2           
1137               annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
1138            end if
1139            if ((vNam(varn) .EQ. "pt_zp_" .OR. vNam(varn) .EQ. "pt(zp)") .AND.\
1140                 p .NE. 1) then
1141               pz=1       
1142               overlay(plot_pt_0_,plot_pt_zp_)
1143               n=n+1
1144               plot_ps(n) = plot_pt_0_   
1145
1146               ; ***************************************************
1147               ; legend for overlaid plot
1148               ; ***************************************************
1149     
1150               lgres                    = True
1151               lgMonoDashIndex          = False
1152               lgres@lgLabelFont        = "helvetica"   
1153               lgres@lgLabelFontHeightF = .1           
1154               lgres@vpWidthF           = 0.4           
1155               lgres@vpHeightF          = 0.4         
1156               lgres@lgDashIndexes      = (/0,0,0/)
1157               lgres@lgLineColors       = (/237,144,80/)
1158               lbid = gsn_create_legend(wks_ps,2,(/"pt_0_","pt_zp_"/),lgres)
1159
1160               amres = True
1161               amres@amParallelPosF   = 0.6                 
1162               amres@amOrthogonalPosF = -0.2           
1163               annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
1164            end if
1165
1166            if(vNam(varn) .NE. "pt_zp_" .AND. vNam(varn) .NE. "pt(zp)" .AND. \
1167               vNam(varn) .NE. "pt_0_" .AND. vNam(varn) .NE. "pt(0)" .AND.   \
1168               vNam(varn) .NE. "wpt" .AND. vNam(varn) .NE. "wpptp" .AND.     \
1169               vNam(varn) .NE. "w"+dq+"pt"+dq .AND.                          \
1170               vNam(varn) .NE. "wpptp0" .AND.                                \
1171               vNam(varn) .NE. "w"+dq+"pt"+dq+"0" .AND.                      \
1172               vNam(varn) .NE. "z_i_pt" .AND.                                \
1173               vNam(varn) .NE. "z_i_wpt" .AND. vNam(varn) .NE. "wmax" .AND.  \
1174               vNam(varn) .NE. "vmax" .AND. vNam(varn) .NE. "umax" .AND.     \
1175               vNam(varn) .NE. "ws" .AND. vNam(varn) .NE. "w*" .AND.         \
1176               vNam(varn) .NE. "us" .AND. vNam(varn) .NE. "u*" .AND.         \
1177               vNam(varn) .NE. "Es" .AND. vNam(varn) .NE. "E*" .AND.         \
1178               vNam(varn) .NE. "E") then
1179
1180               n=n+1
1181               res@xyLineColors   = (/237/)
1182               res@xyLabelMode    = False
1183               res@gsnLeftString  = vNam(varn)
1184               res@gsnRightString = unit(varn)
1185               res@trYMaxF        = max(data(varn,:))
1186               res@trYMinF        = min(data(varn,:))
1187               if (min(data(varn,:)) .EQ. max(data(varn,:))) then
1188                  if (min(data(varn,:)) .EQ. 0)then
1189                     res@trYMaxF = max(data(varn,:))-0.1
1190                     res@trYMinF = min(data(varn,:))+0.1
1191                  end if
1192                  if (min(data(varn,:)) .LT. 0)then
1193                     res@trYMaxF = max(data(varn,:))+(min(data(varn,:)))/2
1194                     res@trYMinF = min(data(varn,:))-(max(data(varn,:)))/2
1195                  end if
1196                  if (min(data(varn,:)) .GT. 0)then
1197                     res@trYMaxF = max(data(varn,:))-(min(data(varn,:)))/2
1198                     res@trYMinF = min(data(varn,:))+(max(data(varn,:)))/2
1199                  end if
1200               end if
1201               plot_ps(n) = gsn_csm_xy(wks_ps,t,data(varn,:),res) 
1202            end if
1203
1204            ; ***************************************************
1205            ; transparent legend as placeholder for single plots
1206            ; ***************************************************
1207            lgresmono                    = True
1208            lgMonoDashIndex              = False
1209            lgresmono@lgMonoLineColor    = True
1210            lgresmono@lgLabelFont        = "helvetica"   
1211            lgresmono@lgLabelFontHeightF = .1           
1212            lgresmono@vpWidthF           = 0.4           
1213            lgresmono@vpHeightF          = 0.4         
1214            lgresmono@lgLineColor        = 0
1215            lgresmono@lgPerimOn          = False
1216            lbid = gsn_create_legend(wks_ps,1,(/""/),lgresmono)       
1217
1218            amres = True
1219            amres@amParallelPosF   = 0.6                   
1220            amres@amOrthogonalPosF = -0.2           
1221            annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
1222       
1223         else
1224           
1225            print("plot of " + vNam(varn))
1226           
1227            n=n+1
1228            res@xyLineColors            = (/237/)
1229            res@gsnLeftString       = vNam(varn)
1230            res@gsnRightString      = unit(varn)
1231       
1232            if (norm_t .NE. 1.)then
1233               res@tiXAxisString        = "t ("+unit_t+")"
1234            else
1235               res@tiXAxisString        = "t (s)"
1236            end if
1237            res@tiYAxisString = " "
1238            res@tiXAxisFontHeightF   = font_size
1239            res@txFontHeightF        = font_size
1240            res@tiYAxisFontHeightF   = font_size
1241            res@tmXBLabelFontHeightF = font_size
1242            res@tmYLLabelFontHeightF = font_size
1243            res@trYMaxF        = max(data(varn,:))
1244            res@trYMinF        = min(data(varn,:))
1245            if (min(data(varn,:)) .EQ. max(data(varn,:))) then
1246               if (min(data(varn,:)) .EQ. 0)then
1247                     res@trYMaxF = max(data(varn,:))-0.1
1248                     res@trYMinF = min(data(varn,:))+0.1
1249                  end if
1250                  if (min(data(varn,:)) .LT. 0)then
1251                     res@trYMaxF = max(data(varn,:))+(min(data(varn,:)))/2
1252                     res@trYMinF = min(data(varn,:))-(max(data(varn,:)))/2
1253                  end if
1254                  if (min(data(varn,:)) .GT. 0)then
1255                     res@trYMaxF = max(data(varn,:))-(min(data(varn,:)))/2
1256                     res@trYMinF = min(data(varn,:))+(max(data(varn,:)))/2
1257                  end if
1258            end if
1259            plot_ps(n) = gsn_csm_xy(wks_ps,t,data(varn,:),res)
1260           
1261         end if     
1262      end if
1263   end do
1264 
1265   ; ***************************************************
1266   ; merge plots onto one page
1267   ; ***************************************************
1268
1269   no_frames = 0
1270 
1271   if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. \
1272        n .gt. no_rows*no_columns) then
1273      gsn_panel(wks_ps,plot_ps(1:n),(/n,1/),resP)
1274      print(" ")
1275      print("Outputs to .eps or .epsi have only one frame")
1276      print(" ")
1277   else
1278      do np = 1,n,no_rows*no_columns   
1279         if ( np + no_rows*no_columns .gt. n) then   
1280            gsn_panel(wks_ps, plot_ps(np:n),(/no_rows,no_columns/),resP)
1281            no_frames = no_frames + 1           
1282         else
1283            gsn_panel(wks_ps, plot_ps(np:np+no_rows*no_columns-1),\
1284                                                   (/no_rows,no_columns/),resP)
1285            no_frames = no_frames + 1
1286         end if
1287      end do
1288   end if
1289
1290   if (format_out .EQ. "png" ) then
1291     png_output = new((/no_frames/), string)
1292     j = 0
1293     do i=0, no_frames-1
1294       j = i + 1
1295       if (j .LE. 9) then
1296         png_output(i) = file_out+".00000"+j+".png"
1297       end if
1298       if (j .GT. 9 .AND. j .LE. 99) then
1299         png_output(i) = file_out+".0000"+j+".png"
1300       end if
1301       if (j .GT. 99 .AND. j .LE. 999) then
1302         png_output(i) = file_out+".000"+j+".png"
1303       end if
1304       if (j .GT. 999) then
1305         png_output(i) = file_out+".00"+j+".png"
1306       end if
1307
1308       ;using imagemagick's convert for reducing the white
1309       ;space around the plot
1310       cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
1311              png_output(i) + " " + png_output(i)
1312       system(cmd)
1313     end do
1314
1315     print(" ")
1316     print("Output to: "+ png_output)
1317     print(" ")
1318   else
1319     print(" ")
1320     print("Output to: " + file_out +"."+ format_out)
1321     print(" ")
1322   end if
1323 
1324 
1325end
Note: See TracBrowser for help on using the repository browser.