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

Last change on this file since 1046 was 983, checked in by hoffmann, 12 years ago

Bugfix in netcdf.f90 and improvements in palmplot.

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