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

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

Bugfix in spectra.ncl concerning output in png and small changes in layout

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