Home > wafo > onedim > dat2steep.m

dat2steep

PURPOSE ^

Extracts waveheights and steepnesses from data.

SYNOPSIS ^

[S , H,AC1,AT1,TFRONT1,TREAR1,z_ind2,xn2]=dat2steep(xx,rate,method)

DESCRIPTION ^

 DAT2STEEP Extracts waveheights and steepnesses from data. 
  
  CALL:  [S, H,Ac,At,Tcf,Tcb, z_ind,yn] = dat2steep(xn,rate,method); 
  
    S, H = Steepness and the corresponding wave height according to method 
   Ac,At = crest and trough amplitude, respectively 
    Tcf, 
     Tcb = Crest front and crest (rear) back period, respectively 
   z_ind = indices to the zero-crossings (d,u) of the defining   
           trough to trough waves (tw). If M>1 then  
           z_ind=[N1 z_ind1 N2 z_ind2 ...NM z_indM] where  
           Ni = length(z_indi) and z_indi are the indices to  
           the zero-crossings of xi, i=1,2...M. 
  
      yn = interpolated signal 
  
      xn = [ti x1 x2 ... xM], where  
           ti = time and x1 x2 ... xM are M column vectors of  
           sampled surface elevation. 
  
    rate = 1,2,3..., interpolation rate   
           no interpolation done before extracting the 
           parameters if less than one. Interpolates 
           with spline if greater than one. 
                            
  method = 0 max(Vcf, Vcb) and corresponding wave height Hd or Hu in H 
           1 crest front (rise) speed (Vcf) in S and wave height Hd in H. (default) 
          -1 crest back (fall) speed (Vcb) in S and waveheight Hu in H. 
           2 crest front steepness in S and the wave height Hd in H. 
          -2 crest back steepness in S and the wave height Hu in H. 
           3 total wave steepness in S and the wave height Hd in H 
             for zero-downcrossing waves. 
          -3 total wave steepness in S and the wave height Hu in H. 
             for zero-upcrossing waves. 
  
  The parameters are calculated as follows: 
   Crest front speed (velocity) = Vcf = Ac/Tcf 
   Crest back speed  (velocity) = Vcb = Ac/Tcb 
   Crest front steepness  =  2*pi*Ac./Td/Tcf/g 
   Crest back steepness   =  2*pi*Ac./Tu/Tcb/g 
   Total wave steepness (zero-downcrossing wave) =  2*pi*Hd./Td.^2/g 
   Total wave steepness (zero-upcrossing wave)   =  2*pi*Hu./Tu.^2/g 
     
  The definition of g, Ac,At, Tcf, etc. are given in gravity, wavedef, 
  ampdef, and perioddef.  
    
  Example: 
   dt = 0.4; 
   xs = spec2sdat(specinterp(jonswap,dt),6000); rate=8; method=1; 
   [S,H] = dat2steep(xs,rate,method); 
   plot(S,H,'.'),xlabel('Vcf [m/s]'),ylabel('Hd [m]') 
  
  See also  wavedef, ampdef, perioddef, interp1, dat2tc

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [S , H,AC1,AT1,TFRONT1,TREAR1,z_ind2,xn2]=dat2steep(xx,rate,method) 
002 %DAT2STEEP Extracts waveheights and steepnesses from data. 
003 % 
004 % CALL:  [S, H,Ac,At,Tcf,Tcb, z_ind,yn] = dat2steep(xn,rate,method); 
005 % 
006 %   S, H = Steepness and the corresponding wave height according to method 
007 %  Ac,At = crest and trough amplitude, respectively 
008 %   Tcf, 
009 %    Tcb = Crest front and crest (rear) back period, respectively 
010 %  z_ind = indices to the zero-crossings (d,u) of the defining   
011 %          trough to trough waves (tw). If M>1 then  
012 %          z_ind=[N1 z_ind1 N2 z_ind2 ...NM z_indM] where  
013 %          Ni = length(z_indi) and z_indi are the indices to  
014 %          the zero-crossings of xi, i=1,2...M. 
015 % 
016 %     yn = interpolated signal 
017 % 
018 %     xn = [ti x1 x2 ... xM], where  
019 %          ti = time and x1 x2 ... xM are M column vectors of  
020 %          sampled surface elevation. 
021 % 
022 %   rate = 1,2,3..., interpolation rate   
023 %          no interpolation done before extracting the 
024 %          parameters if less than one. Interpolates 
025 %          with spline if greater than one. 
026 %                           
027 % method = 0 max(Vcf, Vcb) and corresponding wave height Hd or Hu in H 
028 %          1 crest front (rise) speed (Vcf) in S and wave height Hd in H. (default) 
029 %         -1 crest back (fall) speed (Vcb) in S and waveheight Hu in H. 
030 %          2 crest front steepness in S and the wave height Hd in H. 
031 %         -2 crest back steepness in S and the wave height Hu in H. 
032 %          3 total wave steepness in S and the wave height Hd in H 
033 %            for zero-downcrossing waves. 
034 %         -3 total wave steepness in S and the wave height Hu in H. 
035 %            for zero-upcrossing waves. 
036 % 
037 % The parameters are calculated as follows: 
038 %  Crest front speed (velocity) = Vcf = Ac/Tcf 
039 %  Crest back speed  (velocity) = Vcb = Ac/Tcb 
040 %  Crest front steepness  =  2*pi*Ac./Td/Tcf/g 
041 %  Crest back steepness   =  2*pi*Ac./Tu/Tcb/g 
042 %  Total wave steepness (zero-downcrossing wave) =  2*pi*Hd./Td.^2/g 
043 %  Total wave steepness (zero-upcrossing wave)   =  2*pi*Hu./Tu.^2/g 
044 %    
045 % The definition of g, Ac,At, Tcf, etc. are given in gravity, wavedef, 
046 % ampdef, and perioddef.  
047 %   
048 % Example: 
049 %  dt = 0.4; 
050 %  xs = spec2sdat(specinterp(jonswap,dt),6000); rate=8; method=1; 
051 %  [S,H] = dat2steep(xs,rate,method); 
052 %  plot(S,H,'.'),xlabel('Vcf [m/s]'),ylabel('Hd [m]') 
053 % 
054 % See also  wavedef, ampdef, perioddef, interp1, dat2tc 
055  
056 % Tested on:Matlab 5.3, 5.2, 5.1 
057 % History: 
058 % revised pab Feb2004   
059 % revised pab 01.12.2002 
060 % -removed disp statement and replaced with call to waitbar. 
061 % revised pab 13.06.2001 
062 % - changed method +/-4 to +/-3 
063 % - added call to ecross => improved accuracy in the zero-crossing 
064 %   period calculations 
065 % revised pab 03.04.2001 
066 % - changed order of methods (hopefully more logical) 
067 % - added example 
068 % revised pab 28.11.2000 
069 % -fixed a bug when rate=1 and M>2 
070 % revised pab 07.03.2000 
071 %  - added method 4 
072 % revised pab 08.02.2000 
073 %  - added Ac,At,Tcf, Tcb to output 
074 % by pab 11.11.98 
075  
076 %     
077    
078   error(nargchk(1,3,nargin)) 
079 if nargin<3|isempty(method),   
080   method=1; % want crestfrontvelocity 
081 end 
082  
083 [S,H,z_ind2,AC1,AT1,TFRONT1,TREAR1]=deal([]); % Initialize to [] 
084 dT    = xx(2,1)-xx(1,1); 
085 [N M] = size(xx); 
086 g     = gravity;  % acceleration of gravity 
087 interpolate = 0; 
088  
089 if nargin<2|isempty(rate)|(rate<=1),  % no interpolation 
090   xn=xx(:,1:2);  
091 else % interpolate with spline 
092   dT  = dT/rate; 
093   ti  = (xx(1,1):dT:xx(N,1))'; 
094   interpolate=1; 
095   xn  = zeros(length(ti),2); 
096   xn(:,1) = ti; 
097   if nargout>=7 
098     xn2 = zeros(length(ti),M); 
099     xn2(:,1) = ti; 
100   end 
101 end 
102  
103 h9 = waitbar(0,'Please wait... for dat2steep to finish.'); 
104 for ix=2:M 
105   waitbar((ix-1)/(M-1),h9) 
106   if interpolate, 
107     %disp(['   ...interpolating column ' int2str(ix)]) 
108     %    xn=[ti ;  interp1(xx(:,1),xx(:,2),ti,'*linear') ]';  
109     xn(:,2)=interp1(xx(:,1),xx(:,ix),ti,'*spline');  
110     %    xn=[interp(xx(:,1),rate)';interp(xx(:,2),rate)' ]'; 
111     %    disp(' finished') 
112      if nargout>7 
113        xn2(:,ix)=xn(:,2); 
114      end 
115    else 
116      xn(:,2)=xx(:,ix); 
117   end 
118  % disp('   ...extracting parameters') 
119   [tc tc_ind,z_ind]=dat2tc(xn,0,'tw'); % finding trough to trough waves 
120   if nargout>6 
121     if M==2, 
122       z_ind2=z_ind; % indices to zerocrossings of xn 
123     else 
124       z_ind2 = [z_ind2; length(z_ind); z_ind]; 
125     end 
126   end 
127   % crest amplitude 
128   AC=tc(2:2:end,2); 
129   % trough  amplitude 
130   AT=-tc(1:2:end,2); 
131  
132   if (0<= method & method <=2)|nargout>4, 
133     % time between zero-upcrossing and  crest  [s] 
134     tu     = ecross(xn(:,1),xn(:,2), z_ind(2:2:(end-1)),0); 
135     TFRONT = tc(2:2:end,1)-tu; 
136     %TFRONT=tc(2:2:end,1)-xn(z_ind(2:2:(end-1)),1); 
137     TFRONT((TFRONT==0))=dT; % avoiding division by zero 
138   end 
139   if (0 >= method & method>=-2)|nargout>5, 
140     % time between  crest and zero-downcrossing [s] 
141     td    = ecross(xn(:,1),xn(:,2), z_ind(3:2:end),0); 
142     TREAR = td-tc(2:2:end,1); 
143     %TREAR=xn(z_ind(3:2:end),1)-tc(2:2:end,1); 
144     TREAR((TREAR==0))=dT;  % avoiding division by zero 
145   end    
146   
147   switch method 
148     case 0,   % max(Vcf, Vcr) and the corresponding wave height Hd or Hu in H 
149       HU      = AC+AT(2:end); 
150       [T ind] = min([TFRONT TREAR],[],2); 
151        
152       H2      = AC+AT(1:end-1); 
153       S       = [S ;AC./T]; 
154       ind     = (ind==2); 
155       H2(ind) = HU(ind); 
156       H       = [H;H2]; 
157     case 1,  % extracting crest front velocity [m/s] and   
158              % Zero-downcrossing wave height [m] 
159       H = [H;AC+AT(1:end-1)] ; % Hd 
160       S = [S ; AC./TFRONT]; 
161        
162     case -1,% extracting crest rear velocity [m/s] and   
163            % Zero-upcrossing wave height [m] 
164       H = [H ; AC+AT(2:end)];  
165       S = [S ; AC./TREAR]; 
166        
167     case 2,  % crest front steepness in S and the wave height Hd in H. 
168       H = [H;AC+AT(1:end-1) ]; 
169       T = diff(ecross(xn(:,1),xn(:,2), z_ind(1:2:end),0)); 
170       %T =xn(z_ind(3:2:end),1)-xn(z_ind(1:2:(end-2)),1); 
171       S = [S ; 2*pi*AC./T./TFRONT/g]; 
172     case -2,  % crest back steepness in S and the wave height Hu in H. 
173       H = [H;AC+AT(2:end) ]; 
174       T = diff(ecross(xn(:,1),xn(:,2), z_ind(2:2:end),0)); 
175       %T=xn(z_ind(4:2:end),1)-xn(z_ind(2:2:(end-1)),1); 
176       S = [S ; 2*pi*AC./T./TREAR/g]; 
177     case 3,   % total steepness in S and the wave height Hd in H 
178               % for zero-doewncrossing waves. 
179       H = [H;AC+AT(1:end-1) ]; 
180       T = diff(ecross(xn(:,1),xn(:,2), z_ind(1:2:end),0)); 
181       %T=xn(z_ind(3:2:end),1)-xn(z_ind(1:2:(end-2)),1); % Period zero-downcrossing waves 
182       S = [S ; 2*pi*H./T.^2/g]; 
183     case -3,   % total steepness in S and the wave height Hu in H for 
184                % zero-upcrossing waves. 
185       H = [H;AC+AT(2:end) ]; 
186       T = diff(ecross(xn(:,1),xn(:,2), z_ind(2:2:end),0)); 
187       %T=xn(z_ind(4:2:end),1)-xn(z_ind(2:2:(end-1)),1); % Period zero-upcrossing waves 
188       S = [S ; 2*pi*H./T.^2/g];  
189     otherwise,  error('unknown option') 
190    end 
191    if nargout>2 
192      AC1=[AC1;AC]; 
193      if nargout>3 
194        AT1=[AT1;AT]; 
195        if nargout>4 
196      TFRONT1=[TFRONT1;TFRONT]; 
197      if nargout>5 
198        TREAR1=[TREAR1;TREAR]; 
199      end 
200        end 
201      end 
202    end 
203      
204    if 0, 
205      ind=(AC<0.5); 
206      V(ind)=[]; 
207      H(ind)=[]; 
208    end 
209 end  
210 close(h9) 
211 return 
212  
213

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003