Changeset 310 for palm/trunk/SCRIPTS


Ignore:
Timestamp:
May 1, 2009 5:03:13 PM (15 years ago)
Author:
heinze
Message:

Plots of timeseries appear in the order specified in the variable var.

Location:
palm/trunk/SCRIPTS/NCL
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/NCL/timeseries.ncl

    r250 r310  
    139139
    140140   vNam=getfilevarnames(f_att)
     141   vNam_static=vNam
    141142
    142143   print(" ")
     
    147148   if (dim .EQ. 0) then
    148149      print(" ")
    149       print("There are no data on file")
     150      print("There is no data on file")
    150151      print(" ")
    151152   end if
    152153
    153    t_all = f[:]->time
    154    nt  = dimsizes(t_all)
    155    delta_t=t_all(nt-1)/nt
     154   t_all   = f[:]->time
     155   nt      = dimsizes(t_all)
     156   delta_t = t_all(nt-1)/nt
    156157
    157158   ;****************************************************       
     
    344345   end if
    345346
    346    count_var=0
    347    do varn = dim-1,0,1
     347
     348   if (var .NE. "all") then
     349      vNam_temp = new((/dim/),string)
     350      comma     = 0
     351      var_char  = stringtocharacter(var)
     352      no_char   = dimsizes(var_char)
     353       
     354      do j = 0, no_char-1
     355         if(var_char(j) .eq. ",")
     356            comma = comma + 1
     357         end if
     358      end do
     359
     360      indices = new((/comma/), integer)
     361      comma   = 0
     362       
     363      do j = 0, no_char-1
     364         if(var_char(j) .eq. ",")
     365           indices(comma) = j
     366           comma = comma + 1
     367         end if
     368      end do
     369
     370      do j = 0, comma -2
     371         vNam_temp(j) = charactertostring(var_char(indices(j)+1:indices(j+1)-1))
     372      end do
     373     
     374      delete(vNam)
     375      vNam = new((/comma-1/),string)
     376      do varn = 0, comma - 2
     377         vNam(varn) = vNam_temp(comma - 2 - varn)
     378      end do
     379     
     380      do j = 0, comma-2
     381        count_check = 0
     382        do varn = 0, dim-1
     383           if(vNam(j) .ne. vNam_static(varn))
     384             count_check=count_check+1
     385           end if
     386        end do 
     387   
     388        if(count_check .eq. dim)
     389            print(" ")
     390            print("The variables 'var="+var+"'" )
     391            print("do not exist on your input file;")
     392            print("be sure to have one comma before and after each variable")
     393            print(" ")
     394            exit
     395        end if
     396      end do
     397
     398      dim = comma-1
     399    end if
     400
     401
     402   do varn = dim-1, 0, 1
    348403
    349404      if( isStrSubset (vNam(varn), "time") )
     
    351406      else
    352407         check = True
    353       end if
    354  
    355       if (var .NE. "all") then
    356          check = isStrSubset( var,","+vNam(varn)+"," )
    357       end if
    358    
     408      end if
    359409     
    360410      if(check) then
    361          count_var=count_var+1
    362411
    363412         data_all = f[:]->$vNam(varn)$
    364413         data_att = f_att->$vNam(varn)$
    365414         unit(varn) = data_att@units
    366                
     415 
     416     
    367417         data(varn,:)=data_all(start_time_step:end_time_step)
    368418         
     
    508558      end if
    509559   end do
    510 
    511    if (count_var .EQ. 0) then
    512       print(" ")
    513       print("The variables 'var="+var+"' do not exist on your input file;")
    514       print("be sure to have one comma berfore and after each variable")
    515       print(" ")
    516       exit
     560 
     561  if (isStrSubset(data@long_name," SR " ))then
     562      print(" ")
     563      print("If you have outputs of statistic regions you cannot overlay variables;")
     564      print("'over' is set to 0" )
     565      print(" ")
     566      over = 0
    517567   end if
    518568
    519    do varn = dim-1,0,1
     569   do varn = dim-1, 0, 1
    520570     
    521571      if( isStrSubset (vNam(varn), "time") )
     
    530580 
    531581      if(check) then
    532 
    533         if (isStrSubset(vNam(varn),"_0 " ))then
    534             print(" ")
    535             print("If you have Outputs of statistic regions you cannot overlay variables; 'over' is set to 0")
    536             print(" ")
    537             over = 0
    538          end if
    539 
     582       
    540583        if (over .EQ. 1) then
    541584 
     
    557600               res@xyLineLabelFontHeightF = 0.05
    558601               res@xyLineLabelFontColor   = 237
    559                res@trYMaxF           = minE
    560                res@trYMinF           = maxE
     602               res@trYMaxF           = maxE
     603               res@trYMinF           = minE
    561604               plot_E = gsn_csm_xy(wks_ps,t,data(varn,:),res)
    562605            end if
     
    574617               res@xyLineLabelFontHeightF = 0.05
    575618               res@xyLineLabelFontColor   = 237
    576                res@trYMaxF           = minus
    577                res@trYMinF           = maxus
     619               res@trYMaxF           = maxus
     620               res@trYMinF           = minus
    578621               plot_us = gsn_csm_xy(wks_ps,t,data(varn,:),res)
    579622            end if             
     
    591634               res@xyLineLabelFontHeightF = 0.05
    592635               res@xyLineLabelFontColor   = 237
    593                res@trYMaxF           = minu
    594                res@trYMinF           = maxu
     636               res@trYMaxF           = maxu
     637               res@trYMinF           = minu
    595638               plot_umax = gsn_csm_xy(wks_ps,t,data(varn,:),res)
    596639            end if
     
    615658               res@xyLineLabelFontHeightF = 0.05
    616659               res@xyLineLabelFontColor   = 237
    617                res@trYMaxF           = minz
    618                res@trYMinF           = maxz
     660               res@trYMaxF           = maxz
     661               res@trYMinF           = minz
    619662               plot_z_i_wpt = gsn_csm_xy(wks_ps,t,data(varn,:),res)
    620663            end if
     
    632675               res@xyLineLabelFontHeightF = 0.05
    633676               res@xyLineLabelFontColor   = 237
    634                res@trYMaxF           = minw
    635                res@trYMinF           = maxw
     677               res@trYMaxF           = maxw
     678               res@trYMinF           = minw
    636679               plot_wpptp0 = gsn_csm_xy(wks_ps,t,data(varn,:),res)
    637680            end if
     
    656699               res@xyLineLabelFontHeightF = 0.05
    657700               res@xyLineLabelFontColor   = 237
    658                res@trYMaxF           = minp
    659                res@trYMinF           = maxp
     701               res@trYMaxF           = maxp
     702               res@trYMinF           = minp
    660703               plot_pt_0_ = gsn_csm_xy(wks_ps,t,data(varn,:),res) 
    661704            end if
     
    673716               res@xyLineLabelFontHeightF = 0.05
    674717               res@xyLineLabelFontColor   = 237
    675                res@trYMaxF           = mins
    676                res@trYMinF           = maxs
     718               res@trYMaxF           = maxs
     719               res@trYMinF           = mins
    677720               plot_splptx = gsn_csm_xy(wks_ps,t,data(varn,:),res)   
    678721            end if
     
    695738      end if
    696739   end do
     740
     741
     742   do varn = dim-1, 0, 1
    697743   
    698    do varn = dim-1,0,1
    699  
    700744      if( isStrSubset (vNam(varn), "time") )
    701745         check = False
     
    819863                  overlay(plot_umax,plot_vmax)
    820864                  overlay(plot_umax,plot_wmax)
     865               
    821866                  n=n+1
    822867                  plot_ps(n) = plot_umax
     
    11771222               res@gsnLeftString  = vNam(varn)
    11781223               res@gsnRightString = unit(varn)
    1179                res@trYMaxF        = min(data(varn,:))
    1180                res@trYMinF        = max(data(varn,:))
     1224               res@trYMaxF        = max(data(varn,:))
     1225               res@trYMinF        = min(data(varn,:))
    11811226               if (min(data(varn,:)) .EQ. max(data(varn,:))) then
    11821227                  if (min(data(varn,:)) .EQ. 0)then
    1183                      res@trYMaxF = min(data(varn,:))-0.1
    1184                      res@trYMinF = max(data(varn,:))+0.1
     1228                     res@trYMaxF = max(data(varn,:))-0.1
     1229                     res@trYMinF = min(data(varn,:))+0.1
    11851230                  end if
    11861231                  if (min(data(varn,:)) .LT. 0)then
    1187                      res@trYMaxF = min(data(varn,:))+(min(data(varn,:)))/2
    1188                      res@trYMinF = max(data(varn,:))-(max(data(varn,:)))/2
     1232                     res@trYMaxF = max(data(varn,:))+(min(data(varn,:)))/2
     1233                     res@trYMinF = min(data(varn,:))-(max(data(varn,:)))/2
    11891234                  end if
    11901235                  if (min(data(varn,:)) .GT. 0)then
    1191                      res@trYMaxF = min(data(varn,:))-(min(data(varn,:)))/2
    1192                      res@trYMinF = max(data(varn,:))+(max(data(varn,:)))/2
     1236                     res@trYMaxF = max(data(varn,:))-(min(data(varn,:)))/2
     1237                     res@trYMinF = min(data(varn,:))+(max(data(varn,:)))/2
    11931238                  end if
    11941239               end if
    11951240               plot_ps(n) = gsn_csm_xy(wks_ps,t,data(varn,:),res) 
    11961241            end if
     1242
     1243            ; ***************************************************
     1244            ; transparent legend as placeholder for single plots
     1245            ; ***************************************************
     1246            lgresmono                    = True
     1247            lgMonoDashIndex              = False
     1248            lgresmono@lgMonoLineColor    = True
     1249            lgresmono@lgLabelFont        = "helvetica"   
     1250            lgresmono@lgLabelFontHeightF = .1           
     1251            lgresmono@vpWidthF           = 0.4           
     1252            lgresmono@vpHeightF          = 0.4         
     1253            lgresmono@lgLineColor        = 0
     1254            lgresmono@lgPerimOn          = False
     1255            lbid = gsn_create_legend(wks_ps,1,(/""/),lgresmono)       
     1256
     1257            amres = True
     1258            amres@amParallelPosF   = 0.6                   
     1259            amres@amOrthogonalPosF = -0.2           
     1260            annoid1 = gsn_add_annotation(plot_ps(n),lbid,amres)
    11971261       
    11981262         else
     
    12041268            res@gsnLeftString       = vNam(varn)
    12051269            res@gsnRightString      = unit(varn)
     1270       
    12061271            if (norm_t .NE. 1.)then
    12071272               res@tiXAxisString        = "t ["+unit_t+"]"
     
    12151280            res@tmXBLabelFontHeightF = font_size
    12161281            res@tmYLLabelFontHeightF = font_size
    1217             res@trYMaxF        = min(data(varn,:))
    1218             res@trYMinF        = max(data(varn,:))
     1282            res@trYMaxF        = max(data(varn,:))
     1283            res@trYMinF        = min(data(varn,:))
    12191284            if (min(data(varn,:)) .EQ. max(data(varn,:))) then
    12201285               if (min(data(varn,:)) .EQ. 0)then
    1221                      res@trYMaxF = min(data(varn,:))-0.1
    1222                      res@trYMinF = max(data(varn,:))+0.1
     1286                     res@trYMaxF = max(data(varn,:))-0.1
     1287                     res@trYMinF = min(data(varn,:))+0.1
    12231288                  end if
    12241289                  if (min(data(varn,:)) .LT. 0)then
    1225                      res@trYMaxF = min(data(varn,:))+(min(data(varn,:)))/2
    1226                      res@trYMinF = max(data(varn,:))-(max(data(varn,:)))/2
     1290                     res@trYMaxF = max(data(varn,:))+(min(data(varn,:)))/2
     1291                     res@trYMinF = min(data(varn,:))-(max(data(varn,:)))/2
    12271292                  end if
    12281293                  if (min(data(varn,:)) .GT. 0)then
    1229                      res@trYMaxF = min(data(varn,:))-(min(data(varn,:)))/2
    1230                      res@trYMinF = max(data(varn,:))+(max(data(varn,:)))/2
     1294                     res@trYMaxF = max(data(varn,:))-(min(data(varn,:)))/2
     1295                     res@trYMinF = min(data(varn,:))+(max(data(varn,:)))/2
    12311296                  end if
    12321297            end if
Note: See TracChangeset for help on using the changeset viewer.