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

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

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

File size: 23.1 KB
RevLine 
[176]1load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
2load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
4
[190]5;***************************************************
[418]6; load .ncl.config or .ncl.config.default
[190]7;***************************************************
[194]8
9function which_script()
10local script
11begin
12   script="spectra"
13   return(script)
14end
[190]15   
[418]16if (isfilepresent("$PALM_BIN/../../.ncl.config")) then
17   loadscript("$PALM_BIN/../../.ncl.config")
[190]18else
[418]19  if (isfilepresent("$PALM_BIN/NCL/.ncl.config.default")) then
20     loadscript( "$PALM_BIN/NCL/.ncl.config.default")
[190]21  else
[418]22      palm_bin_path = getenv("PALM_BIN")
[190]23      print(" ")
[418]24      print("Neither the personal configuration file '.ncl.config' exists in")
25      print("~/palm/current_version")
[566]26      print("nor the default configuration file '.ncl.config.default' "+\
27            "exists in")
[418]28      print(palm_bin_path + "/NCL")
[190]29      print(" ")
30      exit
[176]31   end if
[418]32end if   
[218]33
[190]34begin
[176]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   ;***************************************************
52 
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
[176]58   else
59      file_in = file_1   
60   end if
61
[566]62   if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND.   \
63       format_out .NE. "eps" .AND. format_out .NE. "ps" .AND.    \
64       format_out .NE. "epsi" .AND. format_out .NE. "ncgm" .AND. \
65       format_out .NE. "png")then
[190]66      print(" ")
67      print("'format_out = "+format_out+"' is invalid and set to'x11'")
68      print(" ")
69      format_out="x11"
70   end if
[532]71
72   if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then
73      print(" ")
74      print("Output of png files not available")
75      print("png output is avaiable with NCL version 5.2.0 and higher ")
76      print("NCL version used: " + ncl_version_ch)
77      print(" ")
78      exit
79   end if
[190]80   
[218]81   if (log_x .NE. 0 .AND. log_x .NE. 1)then
[190]82      print(" ")
[218]83      print("'log_x'= "+log_x+" is invalid and set to 1")
[190]84      print(" ")
[218]85      log_x = 1
[190]86   end if 
87   
[218]88   if (log_y .NE. 0 .AND. log_y .NE. 1)then
[190]89      print(" ")
[218]90      print("'log_y'= "+log_y+" is invalid and set to 1")
[190]91      print(" ")
[218]92      log_y = 1
[190]93   end if   
94 
[218]95   if (norm_y .EQ. 0.) then
[190]96      print(" ")
[218]97      print("Normalising with 0 is not allowed, 'norm_y' is set to 1.0")
[190]98      print(" ")
[218]99      norm_y = 1.0
[176]100   end if
[218]101   if (norm_x .EQ. 0.) then
[190]102      print(" ")
[218]103      print("Normalising with 0 is not allowed, 'norm_x' is set to 1.0")
[190]104      print(" ")
[218]105      norm_x= 1.0
[176]106   end if
[190]107   
108   if (sort .NE. "height" .AND. sort .NE. "time") then 
109      print(" ")
110      print("'sort'= "+sort+" is invalid and set to 'height'")
111      print(" ")
112      sort = "height" 
[176]113   end if
[190]114   
115   if (black .NE. 0 .AND. black .NE. 1)then
116      print(" ")
117      print("'black'= "+black+" is invalid and set to 0")
118      print(" ")
[176]119      black = 0
120   end if
[190]121 
122   if (dash .NE. 0 .AND. dash .NE. 1)then
123      print(" ")
124      print("'dash'= "+dash+" is invalid and set to 0")
125      print(" ")
[176]126      dash = 0
127   end if
128
[190]129   ;***************************************************
130   ; open input file
131   ;***************************************************
[218]132   
133   file_in_1 = False
134   if (isStrSubset(file_in, ".nc"))then
135      start_f = -2
136      end_f = -2
137      file_in_1 = True     
138   end if
[176]139
[218]140   if (start_f .EQ. -1)then
141      print(" ")
[566]142      print("'start_f' must be one of the cyclic numbers (at least 0) of "+\
143            "your input file(s)")
[218]144      print(" ") 
145      exit
146   end if
147   if (end_f .EQ. -1)then
148      print(" ")
[566]149      print("'end_f' must be one of the cyclic numbers (at least 0) of "+\
150            "your input file(s)")
[218]151      print(" ") 
152      exit
153   end if
154
155   files=new(end_f-start_f+1,string)
[176]156   
[218]157   if (file_in_1)then
158      if (isfilepresent(file_in))then
159         files(0)=file_in
160      else
161         print(" ")
162         print("1st input file: '"+file_in+"' does not exist")
163         print(" ")
164         exit
165      end if
166   else   
167      if (start_f .EQ. 0)then
168         if (isfilepresent(file_in+".nc"))then
169            files(0)=file_in+".nc"
170            do i=1,end_f
171               if (isfilepresent(file_in+"."+i+".nc"))then   
172                  files(i)=file_in+"."+i+".nc"
173               else
174                  print(" ")
175                  print("Input file: '"+file_in+"."+i+".nc' does not exist")
176                  print(" ")
177                  exit 
178               end if       
179            end do         
180         else
181            print(" ")
182            print("Input file: '"+file_in+".nc' does not exist")
183            print(" ")
184            exit
185         end if
186      else
187         do i=start_f,end_f
188            if (isfilepresent(file_in+"."+i+".nc"))then   
189               files(i-start_f)=file_in+"."+i+".nc"
190            else
191               print(" ")
192               print("Input file: '"+file_in+"."+i+".nc' does not exist")
193               print(" ")
194               exit 
195            end if
196         end do
197      end if
198   end if
199
200   f=addfiles(files,"r")
201   f_att=addfile(files(0),"r")
202   ListSetType(f,"cat")
203   
204   vNam = getfilevarnames(f_att)
[176]205   print(" ")
[190]206   print("Variables in input file:")
207   print("- "+ vNam)
[176]208   print(" ")
209   dim = dimsizes(vNam)
[218]210   vDim = getfiledimsizes(f_att)
[176]211 
[218]212   t_all = f[:]->time
[176]213   nt    = dimsizes(t_all)
214   delta_t=t_all(nt-1)/nt
215   
[218]216   k_x=f_att->k_x
[190]217   dimx=dimsizes(k_x)
[218]218   k_y=f_att->k_y
[190]219   dimy=dimsizes(k_y)
220   
221   
222   dim_level=dimsizes(height_level)
223
[176]224   do i=0,dim-1
225      if (vNam(i) .EQ. "zu_sp")then
[218]226         zu=f_att->zu_sp         
[190]227         if (height_level(0) .EQ. -1)then
228            dimz=dimsizes(zu)
229         else
230            if (dim_level .GT. dimsizes(zu))then
231               print(" ")
[566]232               print("'height_level' has more elements than available "+\
233                     "height levels in input file (= "+dimsizes(zu)+")")
[190]234               print(" ")
235               exit
236            else
237               zuh=new(dim_level,double)
238               do le=0,dim_level-1
[566]239                  if (height_level(le) .GE. dimsizes(zu)) then
240                     no_levels=dimsizes(zu)-1
241                     print(" ")
242                     print("Element "+le+" of 'height_level' is greater "  +\
243                          "than the maximum available index in input file "+\
244                          "which is "+no_levels+". Note that the first "   +\
245                          "element has the index 0.")
246                     print(" ")
247                     exit
248                  end if
[190]249                  zuh(le)=zu(height_level(le))
250               end do
251               dimz=dim_level
252            end if   
253         end if 
[176]254      else
255         if (vNam(i) .EQ. "zw_sp")then
[218]256            zw=f_att->zw_sp
[190]257            if (height_level(0) .EQ. -1)then             
258               dimz=dimsizes(zw)
259            else
260               if (dim_level .GT. dimsizes(zw))then
261                  print(" ")
[566]262                  print("'height_level' has more elements than available "+\
263                        "height levels in input file (= "+dimsizes(zw)+")")
[190]264                  print(" ")
265                  exit
266               else
267                  zwh=new(dim_level,double)
268                  do le=0,dim_level-1
[566]269                     if (height_level(le) .GE. dimsizes(zw)) then
270                        no_levels=dimsizes(zw)-1
271                        print(" ")
272                        print("Element "+le+" of 'height_level' is greater "+\
273                              "than the maximum available index in input "  +\
274                              "file which is "+no_levels+". Note that the " +\
275                              "first element has the index 0.")
276                        print(" ")
277                        exit
278                     end if
[190]279                     zwh(le)=zw(height_level(le))
280                  end do
281                  dimz=dim_level
282               end if   
283            end if
[176]284         end if
285      end if
286   end do
[190]287
288   ;****************************************************       
[176]289   ; start of time step and different types of mistakes that could be done
[190]290   ;****************************************************
[176]291   
[190]292   if (start_time_step .EQ. -1.d) then         
[176]293      start_time_step=t_all(0)/3600
[190]294   else
[176]295      if (start_time_step .GT. t_all(nt-1)/3600)then
296         print(" ")
[566]297         print("'start_time_step' = "+ start_time_step +"h is greater than "+\
298               "last time step = "+ t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h")
[176]299         print(" ")
[218]300         print("Select another 'start_time_step'")
[176]301         print(" ")
302         exit
303      end if
304      if (start_time_step .LT. t_all(0)/3600)then
305         print(" ")
[566]306         print("'start_time_step' = "+ start_time_step +"h is lower than "+\
307               "first time step = "+ t_all(0)+"s = "+t_all(0)/3600+"h")       
[176]308         exit
309      end if
310   end if
311
312   do i=0,nt-1     
[566]313      if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \
314          start_time_step .LT. (t_all(i)+delta_t/2)/3600)then
[176]315         st=i
316         break
317      end if
318   end do
319   
[190]320   if (.not. isvar("st"))then
321      print(" ")
322      print("'start_time_step' = "+ start_time_step +"h is invalid")
323      print(" ")
[218]324      print("Select another 'start_time_step'")
[190]325      print(" ")
326      exit
327   end if
328   
329   ;****************************************************
[176]330   ; end of time step and different types of mistakes that could be done
[190]331   ;****************************************************
[176]332
[190]333   if (end_time_step .EQ. -1.d) then           
[176]334      end_time_step = t_all(nt-1)/3600
335   else
336      if (end_time_step .GT. t_all(nt-1)/3600)then
337         print(" ")
[566]338         print("'end_time_step' = "+ end_time_step +"h is greater than "+\
339               "last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h")
[176]340         print(" ")
[218]341         print("Select another 'end_time_step'") 
[176]342         print(" ")
343         exit
344      end if
345      if (end_time_step .LT. start_time_step/3600)then
346         print(" ")
[566]347         print("'end_time_step' = "+ end_time_step +"h is lower than "+\
348               "'start_time_step' = "+start_time_step+"h")
[176]349         print(" ")
[218]350         print("Select another 'start_time_step' or 'end_time_step'")
[176]351         print(" ")
352         exit
353      end if
354   end if
355
356   do i=0,nt-1     
[566]357      if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \
358          end_time_step .LT. (t_all(i)+delta_t/2)/3600)then
[176]359         et=i
360         break
361      end if
362   end do
[190]363   
364   if (.not. isvar("et"))then
365      print(" ")
366      print("'end_time_step' = "+ end_time_step +"h is invalid")
367      print(" ")
[218]368      print("Select another 'end_time_step'")
[190]369      print(" ")
370      exit
371   end if
[176]372
373   delete(start_time_step)
374   start_time_step=round(st,3)
375   delete(end_time_step)
376   end_time_step=round(et,3)
377
378   print(" ")
[566]379   print("Output of time steps from "+t_all(start_time_step)/3600+" h = "+\
380         t_all(start_time_step)+" s => index = "+start_time_step)
381   print("                     till "+t_all(end_time_step)/3600+" h = "+\
382         t_all(end_time_step)+" s => index = "+end_time_step)
[176]383   print(" ")
384
385   dimt = end_time_step-start_time_step+1
386 
[190]387   ;***************************************************
[176]388   ; set up recourses
[190]389   ;***************************************************
[176]390     
391   res = True
392   res@gsnDraw                 = False
393   res@gsnFrame                = False
394   res@txFont                  = "helvetica"
395   res@tiMainFont              = "helvetica"
396   res@tiXAxisFont             = "helvetica"
397   res@tiYAxisFont             = "helvetica"
398   res@tmXBLabelFont           = "helvetica"
399   res@tmYLLabelFont           = "helvetica"
400   res@lgLabelFont             = "helvetica"
401   res@tmLabelAutoStride       = True
402   
[218]403   res@lgLabelFontHeightF     = font_size_legend
404   res@lgTitleFontHeightF     = font_size
405   res@txFontHeightF      = font_size
406   res@tiXAxisFontHeightF = font_size
407   res@tiYAxisFontHeightF = font_size
408   res@tmXBLabelFontHeightF = font_size
409   res@tmYLLabelFontHeightF = font_size
410   
411   res@tmXBMinorPerMajor = 4
412   res@tmYLMinorPerMajor = 4
413   
414   if (log_x .EQ. 1) then
[176]415      res@trXLog = True
[190]416   else
417      res@trXLog = False
418   end if
[218]419   if (log_y .EQ. 1)then
[176]420      res@trYLog = True
[190]421   else 
[178]422      res@trYLog = False
[176]423   end if
424
[566]425   legend_label=new(dimt,string)
[176]426   legend_label_zu=new(dimz,double)
427   legend_label_zw=new(dimz,double)
428   legend_label_z=new(dimz,double)
429   do p=start_time_step,end_time_step
[566]430      legend_label(p-start_time_step)=sprintf("%6.2f", t_all(p)/3600)
[176]431   end do 
432   if (sort .EQ. "time")
433      plot  = new(dim*dimz,graphic)
434      np=dimt
[534]435      res@lgTitleString = "Time (h)"
[176]436   else
437      plot  = new(dim*dimt,graphic)
438      np=dimz
[218]439     
[176]440      do p=0,dimz-1
[190]441         if (height_level(0) .EQ. -1)then
442            legend_label_zu(p)=round(zu(p),3)
443            legend_label_zw(p)=round(zw(p),3)
444         else
445            legend_label_zu(p)=round(zuh(p),3)
446            legend_label_zw(p)=round(zwh(p),3)
447         end if
[176]448      end do
449   end if
[194]450
451   if (black .eq. 0 ) then
452      if (np .EQ. 1)then
[218]453         color = 237
[194]454      else   
455         step=round(235/(np-1),3)
[218]456         color = ispan(2,237,step)
[194]457      end if
[324]458   else
459      color = 2
[176]460   end if
461   if ( dash .eq. 0 ) then
[190]462      res@xyMonoDashPattern = True
[176]463   end if
464
[532]465   if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then
466      format_out@wkPaperSize = "A4"
467   end if
468   if ( format_out .EQ. "png" ) then
469      format_out@wkWidth  = 1000
470      format_out@wkHeight = 1000
471   end if
472
[176]473   wks=gsn_open_wks(format_out,file_out)
474   gsn_define_colormap(wks,"rainbow+white")
475
476   n=0
477   do varn =dim-1,0,1
[178]478     
[176]479      check = True
480
[566]481      if ( isStrSubset( vNam(varn), "time") .OR.  \
482           isStrSubset( vNam(varn), "zu_sp") .OR. \
483           isStrSubset( vNam(varn), "zw_sp") .OR. \
484           isStrSubset( vNam(varn), "k_x") .OR.   \
485           isStrSubset( vNam(varn), "k_y")) then
[176]486            check = False
487      end if
488
[190]489      if (var .NE. "all") then
[176]490         check = isStrSubset( var,","+vNam(varn)+"," )
491      end if
492
[190]493      if(check) then
[218]494
495         temp = f[:]->$vNam(varn)$
[566]496         data = temp(start_time_step:end_time_step,0:dimz-1,:)
[218]497
498         temp_att = f_att->$vNam(varn)$
499         a=getvardims(temp_att)
[190]500         b=dimsizes(a)
[534]501         delete(temp_att)
[176]502
[190]503         if (height_level(0) .NE. -1)then
504            do te=0,dimz-1
[566]505               data(:,te,:) = temp(start_time_step:end_time_step,\
506                                                    height_level(te),:)       
[190]507            end do
508         end if
509
[566]510         data=data/(norm_y*norm_x)
[190]511           
[176]512         do i=0,b-1           
513            if (isStrSubset( a(i),"zu_sp" ))then
514               legend_label_z=legend_label_zu
[190]515               if (height_level(0) .NE. -1)then
516                  z=zuh
517               else
518                  z=zu
519               end if
[176]520            else
521               if (isStrSubset( a(i),"zw_sp" ))then
[190]522                  legend_label_z=legend_label_zw
523                  if (height_level(0) .NE. -1)then
524                     z=zwh
525                  else
526                     z=zw
527                  end if   
[176]528               end if
529            end if
530         end do 
[218]531         
532         min_x=new(dimz,double)
533         max_x=new(dimz,double)
534         min_y=new(dimz,float)
535         max_y=new(dimz,float)
536         plot_h  = new(dimz,graphic)
537         
[176]538         if (isStrSubset(vNam(varn),"x"))then
[218]539            x_axis = new((/dimz,dimx/),double)
540            do q=0,dimz-1
541               x_axis(q,:) = f_att->k_x
542               x_axis = x_axis/norm_x
543            end do
544            if (norm_x .NE. 1.)then
[534]545               res@tiXAxisString = "k~B~x~N~ ("+unit_x+")"
[190]546            else
[218]547               if (norm_height .EQ. 1)then
[534]548                  res@tiXAxisString = "k~B~x~N~ x z (1"
[218]549               else
[534]550                  res@tiXAxisString = "k~B~x~N~ (1/m)"
[218]551               end if
[190]552            end if
[218]553            dim_r=dimx
[176]554         else
[218]555            x_axis=new((/dimz,dimy/),double)
556            do q=0,dimz-1
557               x_axis(q,:) = f_att->k_y
558               x_axis = x_axis/norm_x
559            end do
560            if (norm_x .NE. 1.)then
[534]561               res@tiXAxisString = "k~B~x~N~ ("+unit_x+")"
[190]562            else
[218]563               if (norm_height .EQ. 1)then
[534]564                  res@tiXAxisString = "k~B~x~N~ x z (1)"
[218]565               else
[534]566                  res@tiXAxisString = "k~B~x~N~ (1/m)"
[218]567               end if
[190]568            end if
[218]569            dim_r=dimy
[176]570         end if
571       
572         if (sort .EQ. "time")
[218]573            res@xyLineColors = color
574            res@pmLegendDisplayMode     = "Always"
575            res@pmLegendSide            = "Top"
576            res@pmLegendParallelPosF    = 1.2
577            res@pmLegendOrthogonalPosF  = -1.0
578            res@pmLegendWidthF          = 0.12
[566]579            res@pmLegendHeightF         = 0.04*\
580                                          (end_time_step-start_time_step+1)
[190]581            do p=dimz-1,0,1
[218]582               if (log_y .EQ. 1)then 
[190]583                  do q=0,dimt-1
[218]584                     do r=0,dim_r-1
585                        if (data(q,p,r) .EQ. 0)then
[190]586                           st=p+start_time_step
587                           print(" ")
[566]588                           print("'"+vNam(varn)+"("+st+","+q+","+r+")' is "+\
589                                 "equal 0. Logarithmic scale for y-axis "+\
590                                 "and height "+z(p)+" cannot be used")
[190]591                           print(" ")
592                           res@trYLog = False
593                        end if
594                     end do
[176]595                  end do
[190]596               end if
[176]597               res@gsnLeftString      = vNam(varn)
[218]598               res@gsnRightString     = "Height = "+z(p)+"m"               
[534]599               res@tiYAxisString      = "("+unit_y+")"           
[218]600               res@xyExplicitLegendLabels  = legend_label             
601               if (norm_height .EQ. 1)then
602                  data(:,p,:)=data(:,p,:)*doubletofloat(z(p))
603                  x_axis(p,:) = x_axis(p,:)*z(p)
604               end if
605               res@trXMinF = min(x_axis(p,:))
606               res@trXMaxF = max(x_axis(p,:))
607               plot(n)  = gsn_csm_xy(wks,x_axis(p,:),data(:,p,:),res)
[176]608               n=n+1
609            end do
610         else
[190]611            if (sort .EQ. "height")
612               do p=0,dimt-1           
[176]613                  do q=0,dimz-1
[218]614                     do r=0,dim_r-1
615                        if (data(p,q,r) .EQ. 0)then
[176]616                           st=p+start_time_step
617                           print(" ")
[566]618                           print("'"+vNam(varn)+"("+st+","+q+","+r+")' "+\
619                                 "is equal 0. Logarithmic scale for y-axis "+\
620                                 "and time "+legend_label(p)+" h cannot be used")
[176]621                           print(" ")
622                           res@trYLog = False
623                        end if
624                     end do
[218]625                     if (norm_height .EQ. 1 .AND. p .EQ. 0)then
[566]626                        data(p,q,:) = data(p,q,:)*\
627                                           doubletofloat(legend_label_z(q))
628                        x_axis(q,:) = x_axis(q,:)*\
629                                           doubletofloat(legend_label_z(q))
[218]630                     end if
631                     max_y(q)=max(data(p,q,:))
632                     min_y(q)=min(data(p,q,:))
633                     min_x(q)=min(x_axis(q,:))
[566]634                     max_x(q)=max(x_axis(q,:))
[218]635                  end do
636                  do q=0,dimz-1
637                     res@xyLineColor = color(q)
638                     if (dash .EQ. 1)then
639                        res@xyDashPattern = q
640                     end if
641                     if (q .EQ. 0)then
[566]642                        res@tiYAxisString      = "("+unit_y+")"
[218]643                        res@gsnLeftString      = vNam(varn)
644                        res@gsnRightString     = "Time = "+legend_label(p)+"h"
645                        res@trXMinF = min(min_x)
646                        res@trXMaxF = max(max_x)
647                        res@trYMinF = min(min_y)
648                        res@trYMaxF = max(max_y)
649                       
[566]650                        plot_h(q)  = gsn_csm_xy(wks,x_axis(q,:),\
651                                                         data(p,q,:),res)
[218]652                       
653                        lgres = True
654                        if (dash .EQ. 0)then
655                           lgres@lgMonoDashIndex = True
656                        else
657                           lgres@lgDashIndexes   = ispan(0,dimz-1,1)
658                        end if
659                        if (black .EQ. 1)then
660                           lgres@lgMonoLineColors = True
661                        else
662                           lgres@lgLineColors = color
663                        end if
[566]664                        lgres@lgTitleString      = "Height (m)" 
[218]665                        lgres@lgLabelFont        = "helvetica"
[566]666                        lgres@lgLabelFontHeightF = font_size_legend*6
667                        lgres@lgTitleFontHeightF = font_size     
[218]668                        lgres@vpWidthF           = 0.12           
[566]669                        lgres@vpHeightF          = font_size_legend*(dimz+3)
[218]670 
[566]671                        lbid = gsn_create_legend(wks,dimz,legend_label_z,lgres)
[218]672
673                        amres = True
674                        amres@amParallelPosF   = 0.75               
675                        amres@amOrthogonalPosF = 0.15           
676                        annoid1 = gsn_add_annotation(plot_h(q),lbid,amres)
677                     else
[566]678                        plot_h(q)  = gsn_csm_xy(wks,x_axis(q,:),\
679                                                        data(p,q,:),res)
[218]680                        overlay(plot_h(0),plot_h(q))
681                     end if
682                  end do             
683                  plot(n)=plot_h(0)
684                  n=n+1
[176]685               end do
686            end if
[190]687         end if
[218]688         delete(data)
689         delete(temp)
[178]690         delete(x_axis)
[218]691         delete(min_x)
692         delete(max_x)
693         delete(min_y)
694         delete(max_y)
695         delete(plot_h)
[176]696      end if
697   end do
698
699   if (n .EQ. 0) then
700      print(" ")
[190]701      print("The variables 'var="+var+"' do not exist on your input file;")
702      print("be sure to have one comma berfore and after each variable")
[176]703      print(" ")
704      exit
705   end if
706 
707   ; ***************************************************
708   ; merge plots onto one page
709   ; ***************************************************
710
711   resP                        = True
712   resP@txFont                 = "helvetica"
[218]713   resP@txString               = f_att@title
[176]714   resP@txFuncCode             = "~"
[218]715   resP@txFontHeightF          = 0.015
[176]716
[534]717   no_frames = 0
718
[566]719   if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. \
720                                          n .gt. no_rows*no_columns) then
[183]721      gsn_panel(wks,plot,(/n,1/),resP)
[250]722      print(" ")
723      print("Outputs to .eps or .epsi have only one frame")
724      print(" ")
[176]725   else   
[218]726      do i = 0,n-1, no_rows*no_columns
727         if( (i+no_rows*no_columns) .gt. (n-1)) then
728            gsn_panel(wks,plot(i:n-1),(/no_rows,no_columns/),resP)
[534]729            no_frames = no_frames + 1
[176]730         else
[566]731            gsn_panel(wks,plot(i:i+no_rows*no_columns-1),\
732                                           (/no_rows,no_columns/),resP)
[534]733            no_frames = no_frames + 1   
[176]734         end if
735      end do
736   end if
737
[532]738   if (format_out .EQ. "png" ) then
739     png_output = new((/no_frames/), string)
740     j = 0
741     do i=0, no_frames-1
742       j = i + 1
743       if (j .LE. 9) then
744         png_output(i) = file_out+".00000"+j+".png"
745       end if
746       if (j .GT. 9 .AND. j .LE. 99) then
747         png_output(i) = file_out+".0000"+j+".png"
748       end if
749       if (j .GT. 99 .AND. j .LE. 999) then
750         png_output(i) = file_out+".000"+j+".png"
751       end if
752       if (j .GT. 999) then
753         png_output(i) = file_out+".00"+j+".png"
754       end if
755
756       ;using imagemagick's convert for reducing the white
757       ;space around the plot
758       cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
759              png_output(i) + " " + png_output(i)
760       system(cmd)
761     end do
762
763     print(" ")
764     print("Output to: "+ png_output)
765     print(" ")
766   else
767     print(" ")
768     print("Output to: " + file_out +"."+ format_out)
769     print(" ")
770   end if
[176]771   
[190]772end
Note: See TracBrowser for help on using the repository browser.