Home > wafo > multidim > private > hwestimate.m

# hwestimate

## PURPOSE

Estimate absolute value of transfer function H(w) from sensor spectra

## SYNOPSIS

Hw = HwEstimate(Sf,SfBest,Hw,pos);

## DESCRIPTION

``` HWESTIMATE  Estimate absolute value of transfer function H(w) from sensor spectra

CALL Hw = hwestimate(Sf,SfBest,Hw,pos)

Internal function to dat2dspec.```

## CROSS-REFERENCE INFORMATION

This function calls:
 mean Average or mean value. unique Set unique. warning Display warning message; disable or enable warning messages.
This function is called by:
 dat2dspec Estimates the directional wave spectrum from timeseries

## SOURCE CODE

```001 function Hw = HwEstimate(Sf,SfBest,Hw,pos);
002 %HWESTIMATE  Estimate absolute value of transfer function H(w) from sensor spectra
003 %
004 % CALL Hw = hwestimate(Sf,SfBest,Hw,pos)
005 %
006 % Internal function to dat2dspec.
007
008 %---------------------------------------------------------------------------------
009 %Estimate the absolute value of the transfer function H(w) from the sensor spectra
010 %---------------------------------------------------------------------------------
011 def  = unique(pos(:,4)).';
012 k0   = find(def==5|def==7|def==11|def==14|def==17);
013 if any(k0), def(k0) = def(k0)-1;end
014 k0  = find(def==8);
015 if any(k0), def(k0) = def(k0)-2;end
016 def = unique(def);
017
018 k = find(SfBest~= 0); % avoid division by zero
019
020 for sensorType1 = def
021   if (sensorType1==6)  % surface curvatures          : n_xx, n_yy, n_xy
022     sensorType2 = 7; sensorType3 = 8;
023     ix1 = find(pos(:,4)==sensorType1); Nx1 = length(Nx1);
024     ix2 = find(pos(:,4)==sensorType2); Nx2 = length(Nx2);
025     ix3 = find(pos(:,4)==sensorType3); Nx3 = length(Nx3);
026     Nx  = min([Nx1,Nx2,Nx3]); % need at least one pair of observations
027     if (Nx>0)
028       Hw0 = sqrt(mean(Sf(ix1(1:Nx),k)+Sf(ix2(1:Nx),k)+2*Sf(ix3(1:Nx),k),1)./SfBest(k));
029       %plot(fi(k),Hw0,fi,Hw(ix1(1),:)), legend('Hw0','Hw'), pause
030       Hw([ix1;ix2;ix3],k) = Hw0(ones(Nx1+Nx2+Nx3,1),k);
031     else
032       warning('Unable to estimate the surface curvature transferfunction!')
033     end
034   elseif any(sensorType1==[2:3 9 12 15 18])
035     ix1 = find(pos(:,4)==sensorType1);
036     Nx  = length(ix1);
037     if Nx>0
038       Hw0       = sqrt(mean(Sf(ix1,k),1)./SfBest(k));
039       %plot(fi(k),Hw0,fi,Hw(ix1(1),:)), legend('Hw0','Hw'), pause
040       Hw(ix1,k) = Hw0(ones(Nx,1),:);
041     else
042        warning('Unable to estimate the transferfunction')
043     end
044   elseif any(sensorType1==[4 10 14 16])
045     % surface slopes,water particle velocity, water particle acceleration
046     % or water particle displacement
047     sensorType2 = sensorType1+1;
048     ix1 = find(pos(:,4)==sensorType1); Nx1 = length(ix1);
049     ix2 = find(pos(:,4)==sensorType2); Nx2 = length(ix2);
050     Nx  = min(Nx1,Nx2); % need at least one pair of observations
051     if (Nx>0)
052       Hw0 = sqrt(mean(Sf(ix1(1:Nx),k)+Sf(ix2(1:Nx),k),1)./SfBest(k));
053       %plot(fi(k),Hw0,fi,Hw(ix1(1),:)), legend('Hw0','Hw'), pause
054
055       Hw([ix1;ix2],k) = Hw0(ones(Nx1+Nx2,1),:);
056     else %if (any()
057       warning('Unable to estimate the transferfunction')
058     end
059   end
060 end
061 return```

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