Hi: the three routines I am sending use zp, pressure already converted to equivalent depth. There is a routine around somewhere which looks at non-hydrostatic depth attenuation in the pressure, but I can't find it right now. I guess hydrostatic is ok for peak period and longer, so it may not be an issue. Hope these are legible. Someone else you might ask about this sort of thing is Michael Li. He works in matlab, and does very similar sort of work. -- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Douglas J. Wilson + + Oregon Graduate Institute of Science and Technology + + 20000 NW Walker Rd. Beaverton, OR 97006 + + phone: 503 748 1099 Fax: 503 748 1273 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ function [Usig,twoA,thetas,period] = zeroups(vx,vy,zp,F) % This routine takes two axis velocity and a pressure height % m/s m/s and m(H2O) and does counting-type wave statistics dfifty = 0.00017; vabs = sqrt(vx.*vx + vy.*vy); vabsmean = mean(vabs); vabs2mean = mean(vabs.*vabs); vabsstd = std(vabs); % CUMSUM of the velocity is a way to convert velocity to % excursion distance s = vdt. xpos = cumsum(vx)./F; ypos = cumsum(vy)./F; excur = sqrt(xpos.^2 + ypos.^2); % ---------------------------------------------------------------------- % % * * * * * * * * * * * * * * * * * * * * * % To get a distribution of wave heights, I find the ZERO UP CROSSINGS! zpstd = std(zp); % RMS wave height. zpmean = mean(zp); % mean water depth above sensor iof = find(zp15) % incident wave periods>15 sec invalid, try again. [Y,II] = max(ppres(9:length(ppres),1)); peraray = spctres./(II.*F) %end M = cov([zp(:) vx(:) vy(:)]); M00 = M(1,1); M20 = M(2,2); vxstd = sqrt(M20); vxmean = mean(vx); M02 = M(3,3); vystd = sqrt(M02); vymean = mean(vy); M01 = M(1,2); M10 = M(1,3); M11 = M(2,3); %vxskew = skew(vx); %vyskew = skew(vy); %pskew = skew(zp); % Wave directionality factors, GAMLH is Longuet-Higgin's wave directionality Gam2 = (M20 +M02); Gam3 = sqrt((M20-M02)^2 + 4*M11^2); GamLH = sqrt((Gam2 - Gam3)/(Gam2 + Gam3)); alpham = atan(M10/M01).*(360/pi); % Mean wave direction alphap = atan(2*M11/(M20-M02)).*(180/pi); % Principal wave direction Usig = 2*sqrt(vxstd.*vxstd + vystd.*vystd); % Significant near-bottom wave velocity afit = polyfit(vx,vy,1); alphas = atan(afit(1))*(180/pi); % Orientation of wave orbital ellipse. % Now calculate the Jonsson friction factor from the orbital amplitude. twoA = Usig*peraray/(2.*pi); fw = exp(5.213*(2.5*dfifty*2./twoA).^0.194 - 5.977); thetas = fw*Usig.^2/(32.34*dfifty); function zeta = vxtozeta(vx,F,h,z) % FUNCTION VXTOZETA(VX,F,H,Z) % This function converts current meter velocities to surface elevations % using linear theory, shallow water wave velocity, with all units in meters, % seconds and m/s. % % DECLARATIONS % vx = vector of velocity data to be converted. % F = sampling frequency in samples/sec. % h = is water depth % z = distance current meter is from the bottom. % % % % % % % % % % % % % % % % % % % % % % % % % % % recl = length(vx); spctres = 2048; if(recl/spctres < 1) spctres = recl; end vxsp = spectrum(vx,spctres); [Y,III] = max(vxsp(:,1)); Peak_per = spctres./(III*F); % convert velocities into surface heights g = 9.8; % Gravity in m/s sigma = 2*pi/Peak_per; % Wave angular velocity (mean sort of) kappa = sigma/sqrt(h*g); % Wave number = 2pi/L (linear shallow % water wave theory for convenience. zeta = sinh(kappa*h)*vx./(sigma*cosh(kappa*(h-z)));