Ignore:
Timestamp:
Dec 10, 2008 9:14:34 AM (15 years ago)
Author:
letzel
Message:
  • User can check user parameters and deduce further quantities in user_check_parameters
  • Topography definition according to new user parameter topography_grid_convention (init_grid, modules, user_header, user_init_grid, user_parin)
  • New subdirectory trunk/EXAMPLES with two examples highlighting the topography_grid_convention
File:
1 edited

Legend:

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

    r194 r218  
    3333   ; set up default parameter values and strings
    3434   ;***************************************************
    35  
     35   
    3636   if (file_1 .EQ. "File in") then
    3737      print(" ")
    38       print("Please provide 1st input file 'file_1=' in 'ncl_preferences.ncl'")
     38      print("Declare input file 'file_1=' in 'ncl_preferences.ncl' or prompt")
    3939      print(" ")
    4040      exit
     
    4242      file_in = file_1   
    4343   end if
    44    if (.not. isfilepresent(file_in)) then
    45       print(" ")
    46       print("1st input file: '"+file_in+"' does not exist")
    47       print(" ")
    48       exit
    49    end if
    5044
    5145   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
     
    6155      print(" ")
    6256      over = 0
    63    end if   
     57   end if 
     58   
     59   if (norm_t .EQ. 0) then
     60      print(" ")
     61      print("Normalising with 0 is not allowed, 'norm_t' is set to 1.0")
     62      print(" ")
     63      norm_t = 1.0
     64   end if
    6465 
    6566
     
    6768   ; open input file
    6869   ;***************************************************
    69 
    70    f  = addfile(file_in , "r" )
    71 
    72    vNam  = getfilevarnames(f)
     70   
     71   file_in_1 = False
     72   if (isStrSubset(file_in, ".nc"))then
     73      start_f = -2
     74      end_f = -2
     75      file_in_1 = True     
     76   end if
     77
     78   if (start_f .EQ. -1)then
     79      print(" ")
     80      print("'start_f' must be one of the cyclic numbers (at least 0) of your input file(s)")
     81      print(" ") 
     82      exit
     83   end if
     84   if (end_f .EQ. -1)then
     85      print(" ")
     86      print("'end_f' must be one of the cyclic numbers (at least 0) of your input file(s)")
     87      print(" ") 
     88      exit
     89   end if
     90
     91   files=new(end_f-start_f+1,string)
     92
     93   if (file_in_1)then
     94      if (isfilepresent(file_in))then
     95         files(0)=file_in
     96      else
     97         print(" ")
     98         print("1st input file: '"+file_in+"' does not exist")
     99         print(" ")
     100         exit
     101      end if
     102   else   
     103      if (start_f .EQ. 0)then
     104         if (isfilepresent(file_in+".nc"))then
     105            files(0)=file_in+".nc"
     106            do i=1,end_f
     107               if (isfilepresent(file_in+"."+i+".nc"))then   
     108                  files(i)=file_in+"."+i+".nc"
     109               else
     110                  print(" ")
     111                  print("Input file: '"+file_in+"."+i+".nc' does not exist")
     112                  print(" ")
     113                  exit 
     114               end if       
     115            end do         
     116         else
     117            print(" ")
     118            print("Input file: '"+file_in+".nc' does not exist")
     119            print(" ")
     120            exit
     121         end if
     122      else
     123         do i=start_f,end_f
     124            if (isfilepresent(file_in+"."+i+".nc"))then   
     125               files(i-start_f)=file_in+"."+i+".nc"
     126            else
     127               print(" ")
     128               print("Input file: '"+file_in+"."+i+".nc' does not exist")
     129               print(" ")
     130               exit 
     131            end if
     132         end do
     133      end if
     134   end if
     135
     136   f=addfiles(files,"r")
     137   f_att=addfile(files(0),"r")
     138   ListSetType(f,"cat")
     139
     140   vNam=getfilevarnames(f_att)
     141
    73142   print(" ")
    74143   print("Variables in input file:")
     
    82151   end if
    83152
    84    t_all = f->time
     153   t_all = f[:]->time
    85154   nt  = dimsizes(t_all)
    86155   delta_t=t_all(nt-1)/nt
    87    
     156
    88157   ;****************************************************       
    89158   ; start of time step and different types of mistakes that could be done
     
    97166         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")
    98167         print(" ")
    99          print("Please select another 'start_time_step'")
     168         print("Select another 'start_time_step'")
    100169         print(" ")
    101170         exit
     
    105174         print("'start_time_step' = "+ start_time_step +"h is lower than first time step = " + t_all(0)+"s = "+t_all(0)/3600+"h")
    106175         print(" ")
    107          print("Please select another 'start_time_step'")
     176         print("Select another 'start_time_step'")
    108177         print(" ")
    109178         exit
     
    123192      print("'start_time_step' = "+ start_time_step +"h is invalid")
    124193      print(" ")
    125       print("Please select another 'start_time_step'")
     194      print("Select another 'start_time_step'")
    126195      print(" ")
    127196      exit
     
    139208         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")
    140209         print(" ")
    141          print("Please select another 'end_time_step'")
     210         print("Select another 'end_time_step'")
    142211         print(" ")
    143212         exit
     
    147216         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")
    148217         print(" ")
    149          print("Please select another 'end_time_step'") 
     218         print("Select another 'end_time_step'") 
    150219         print(" ")
    151220         exit
     
    155224         print("'end_time_step' = "+ end_time_step +"h is equal or lower than 'start_time_step' = "+start_time_step+"h")
    156225         print(" ")
    157          print("Please select another 'start_time_step' or 'end_time_step'")
     226         print("Select another 'start_time_step' or 'end_time_step'")
    158227         print(" ")
    159228         exit
     
    171240      print("'end_time_step' = "+ end_time_step +"h is invalid")
    172241      print(" ")
    173       print("Please select another 'end_time_step'")
     242      print("Select another 'end_time_step'")
    174243      print(" ")
    175244      exit
     
    186255   print(" ")
    187256
    188    t = f->time(start_time_step:end_time_step)
    189 
     257   t = t_all(start_time_step:end_time_step)/norm_t
    190258 
    191259   ; ***************************************************
     
    210278   res@xyLineColors            = (/237/)
    211279   
    212    res@lgLabelFontHeightF     = .02
     280   res@lgLabelFontHeightF     = 0.02
    213281
    214282   resP                        = True
    215283   resP@txFont                 = "helvetica"
    216    resP@txString               = f@title+" time series "
     284   resP@txString               = f_att@title+" time series "
    217285   resP@txFuncCode             = "~"
    218286   resP@txFontHeightF          = 0.015
     287
     288   res@tmXBMinorPerMajor = 4
     289   res@tmYLMinorPerMajor = 4
    219290
    220291   res@vpWidthF=4
     
    290361         count_var=count_var+1
    291362
    292          data_all = f ->$vNam(varn)$
    293          unit(varn) = data_all@units
     363         data_all = f[:]->$vNam(varn)$
     364         data_att = f_att->$vNam(varn)$
     365         unit(varn) = data_att@units
    294366               
    295367         data(varn,:)=data_all(start_time_step:end_time_step)
     
    303375               if (mini(varn) .EQ. maxi(varn)) then
    304376                  if (min(data(varn,:)) .EQ. 0)then
    305                      mini(varn)= mini(varn)-1.
    306                      maxi(varn)= maxi(varn)+1.
     377                     mini(varn)= mini(varn)-0.1
     378                     maxi(varn)= maxi(varn)+0.1
    307379                  end if
    308380                  if (min(data(varn,:)) .LT. 0)then
     
    322394               if (mini(varn) .EQ. maxi(varn)) then
    323395                  if (min(data(varn,:)) .EQ. 0)then
    324                      mini(varn)= mini(varn)-1.
    325                      maxi(varn)= maxi(varn)+1.
     396                     mini(varn)= mini(varn)-0.1
     397                     maxi(varn)= maxi(varn)+0.1
    326398                  end if
    327399                  if (min(data(varn,:)) .LT. 0)then
     
    341413               if (mini(varn) .EQ. maxi(varn)) then
    342414                  if (mini(varn) .EQ. 0)then
    343                      mini(varn)= mini(varn)-1.
    344                      maxi(varn)= maxi(varn)+1.
     415                     mini(varn)= mini(varn)-0.1
     416                     maxi(varn)= maxi(varn)+0.1
    345417                  end if
    346418                  if (mini(varn) .LT. 0)then
     
    360432               if (mini(varn) .EQ. maxi(varn)) then
    361433                  if (min(data(varn,:)) .EQ. 0)then
    362                      mini(varn)= mini(varn)-1.
    363                      maxi(varn)= maxi(varn)+1.
     434                     mini(varn)= mini(varn)-0.1
     435                     maxi(varn)= maxi(varn)+0.1
    364436                  end if
    365437                  if (min(data(varn,:)) .LT. 0)then
     
    379451               if (mini(varn) .EQ. maxi(varn)) then
    380452                  if (min(data(varn,:)) .EQ. 0)then
    381                      mini(varn)= mini(varn)-1.
    382                      maxi(varn)= maxi(varn)+1.
     453                     mini(varn)= mini(varn)-0.1
     454                     maxi(varn)= maxi(varn)+0.1
    383455                  end if
    384456                  if (min(data(varn,:)) .LT. 0)then
     
    398470               if (mini(varn) .EQ. maxi(varn)) then
    399471                  if (min(data(varn,:)) .EQ. 0)then
    400                      mini(varn)= mini(varn)-1.
    401                      maxi(varn)= maxi(varn)+1.
     472                     mini(varn)= mini(varn)-0.1
     473                     maxi(varn)= maxi(varn)+0.1
    402474                  end if
    403475                  if (min(data(varn,:)) .LT. 0)then
     
    417489               if (mini(varn) .EQ. maxi(varn)) then
    418490                  if (min(data(varn,:)) .EQ. 0)then
    419                      mini(varn)= mini(varn)-1.
    420                      maxi(varn)= maxi(varn)+1.
     491                     mini(varn)= mini(varn)-0.1
     492                     maxi(varn)= maxi(varn)+0.1
    421493                  end if
    422494                  if (min(data(varn,:)) .LT. 0)then
     
    459531      if(check) then
    460532
    461         if (isStrSubset(vNam(varn),"_0" ))then
     533        if (isStrSubset(vNam(varn),"_0 " ))then
    462534            print(" ")
    463535            print("If you have Outputs of statistic regions you cannot overlay variables; 'over' is set to 0")
     
    470542            res@gsnLeftString       = "overlayed plot"
    471543            res@gsnRightString      = unit(varn)
    472             res@tiXAxisString        = " time [s] "
    473             res@tiYAxisString        = " "
    474             res@tiXAxisFontHeightF   = 0.07
    475             res@txFontHeightF        = 0.07
    476             res@tiYAxisFontHeightF   = 0.07           
     544            if (norm_t .NE. 1.)then
     545               res@tiXAxisString        = "t ["+unit_t+"]"
     546            else
     547               res@tiXAxisString        = "t [s]"
     548            end if
     549            res@tiYAxisString = " "
     550            res@tiXAxisFontHeightF   = font_size
     551            res@txFontHeightF        = font_size
     552            res@tiYAxisFontHeightF   = font_size           
    477553
    478554            if (vNam(varn) .EQ. "E")
     
    11051181               if (min(data(varn,:)) .EQ. max(data(varn,:))) then
    11061182                  if (min(data(varn,:)) .EQ. 0)then
    1107                      res@trYMaxF = min(data(varn,:))-1.
    1108                      res@trYMinF = max(data(varn,:))+1.
     1183                     res@trYMaxF = min(data(varn,:))-0.1
     1184                     res@trYMinF = max(data(varn,:))+0.1
    11091185                  end if
    11101186                  if (min(data(varn,:)) .LT. 0)then
     
    11281204            res@gsnLeftString       = vNam(varn)
    11291205            res@gsnRightString      = unit(varn)
    1130             res@tiXAxisString        = " time [s] "
    1131             res@tiYAxisString        = " "
    1132             res@tiXAxisFontHeightF   = 0.07
    1133             res@txFontHeightF        = 0.07
    1134             res@tiYAxisFontHeightF   = 0.07
     1206            if (norm_t .NE. 1.)then
     1207               res@tiXAxisString        = "t ["+unit_t+"]"
     1208            else
     1209               res@tiXAxisString        = "t [s]"
     1210            end if
     1211            res@tiYAxisString = " "
     1212            res@tiXAxisFontHeightF   = font_size
     1213            res@txFontHeightF        = font_size
     1214            res@tiYAxisFontHeightF   = font_size
     1215            res@tmXBLabelFontHeightF = font_size
     1216            res@tmYLLabelFontHeightF = font_size
    11351217            res@trYMaxF        = min(data(varn,:))
    11361218            res@trYMinF        = max(data(varn,:))
    11371219            if (min(data(varn,:)) .EQ. max(data(varn,:))) then
    11381220               if (min(data(varn,:)) .EQ. 0)then
    1139                      res@trYMaxF = min(data(varn,:))-1.
    1140                      res@trYMinF = max(data(varn,:))+1.
     1221                     res@trYMaxF = min(data(varn,:))-0.1
     1222                     res@trYMinF = max(data(varn,:))+0.1
    11411223                  end if
    11421224                  if (min(data(varn,:)) .LT. 0)then
     
    11621244      gsn_panel(wks_ps,plot_ps(1:n),(/n,1/),resP)
    11631245   else
    1164       do np = 1,n,no_lines*no_columns   
    1165          if ( np + no_lines*no_columns .gt. n) then   
    1166             gsn_panel(wks_ps, plot_ps(np:n),(/no_lines,no_columns/),resP)
     1246      do np = 1,n,no_rows*no_columns   
     1247         if ( np + no_rows*no_columns .gt. n) then   
     1248            gsn_panel(wks_ps, plot_ps(np:n),(/no_rows,no_columns/),resP)
    11671249         else
    1168             gsn_panel(wks_ps, plot_ps(np:np+no_lines*no_columns-1),(/no_lines,no_columns/),resP)
     1250            gsn_panel(wks_ps, plot_ps(np:np+no_rows*no_columns-1),(/no_rows,no_columns/),resP)
    11691251         end if
    11701252      end do
Note: See TracChangeset for help on using the changeset viewer.