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

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