depthxyz

PURPOSE ^

depthxyz computes the x,y, and z components of the location where each

SYNOPSIS ^

function [exyz]=depthxyz(depthRaw,draft,pitchRaw,roll,heading,beamAngle,unitsID,x,y,elev,ens);

DESCRIPTION ^

 depthxyz computes the x,y, and z components of the location where each
 beam reflects from the streambed using the algorithm provided by Gary
 Murdock, RDI, 10-25-2002

 INPUT
 depthRaw - matrix of beam depths
 draft - draft of instrument
 pitchRaw - pitch vector from ADCP in degrees
 roll - roll vector from ADCP in degrees
 heading - heading vector from ADCP in degrees
 beamAngle - beam angle of instrument in degrees
 magvar - magnetic variation for site
 unitsID - units identifier
 x - x-coordinate(Easting) of center of ADCP
 y - y-coordinate(Northing) of center of ADCP
 elev - elevation of water-surface at ADCP
 ens - vector of ensemble numbers

 OUTPUT

 exyz - matrix with rows of ensembles and columns of x,y, and z

 David S. Mueller
 U.S. Geological Survey
 Office of Surface Water
 dmueller@usgs.gov
 
 June 29, 2006

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [exyz]=depthxyz(depthRaw,draft,pitchRaw,roll,heading,beamAngle,...
0002     unitsID,x,y,elev,ens);
0003 % depthxyz computes the x,y, and z components of the location where each
0004 % beam reflects from the streambed using the algorithm provided by Gary
0005 % Murdock, RDI, 10-25-2002
0006 %
0007 % INPUT
0008 % depthRaw - matrix of beam depths
0009 % draft - draft of instrument
0010 % pitchRaw - pitch vector from ADCP in degrees
0011 % roll - roll vector from ADCP in degrees
0012 % heading - heading vector from ADCP in degrees
0013 % beamAngle - beam angle of instrument in degrees
0014 % magvar - magnetic variation for site
0015 % unitsID - units identifier
0016 % x - x-coordinate(Easting) of center of ADCP
0017 % y - y-coordinate(Northing) of center of ADCP
0018 % elev - elevation of water-surface at ADCP
0019 % ens - vector of ensemble numbers
0020 %
0021 % OUTPUT
0022 %
0023 % exyz - matrix with rows of ensembles and columns of x,y, and z
0024 %
0025 % David S. Mueller
0026 % U.S. Geological Survey
0027 % Office of Surface Water
0028 % dmueller@usgs.gov
0029 %
0030 % June 29, 2006
0031 
0032     % Correct draft for units
0033     if unitsID=='ft'
0034             draft=double(draft)*0.0328083;
0035         else
0036             draft=double(draft)*.01;
0037     end;
0038     
0039     % Depending on how you got here, elev may be a char array. Check and
0040     % convert if necessary
0041     if ischar(elev); elev = str2num(elev); end;
0042         
0043     % Create geo matrix of x, y, and elevation of transducers
0044     geo=[x,y,-1.*repmat(draft,size(y))+elev];    
0045 
0046     % Compute slant range of each beam
0047     if ischar(beamAngle)
0048         beamAngleR=str2double(beamAngle).*pi/180;
0049     else
0050         beamAngleR=beamAngle.*pi/180;
0051     end
0052     range=(depthRaw-draft)./cos(beamAngleR);
0053     
0054     % Adjust heading, pitch, and roll
0055     rollR=roll.*pi/180;
0056     pitchRawR=pitchRaw.*pi/180;
0057     headingR=heading.*pi/180;
0058     pitchR=atan(tan(pitchRawR).*cos(rollR));
0059 
0060     % Compute sine and cosine values
0061     ch=cos(headingR);
0062     sh=sin(headingR);
0063     cp=cos(pitchR);
0064     sp=sin(pitchR);
0065     cr=cos(rollR);
0066     sr=sin(rollR);
0067     
0068     % Configure transformation vectors for east, north, and vertical
0069     trans2e=[ch.*cr+sh.*sp.*sr sh.*cp ch.*sr-sh.*sp.*cr];
0070     trans2n=[-sh.*cr+ch.*sp.*sr ch.*cp -sh.*sr-ch.*sp.*cr];
0071     trans2u=[-cp.*sr sp cp.*cr];
0072     
0073     % Create matrix to convert from slant range to xyz
0074     rng2xyz=[-sin(beamAngleR) 0 -cos(beamAngleR);...
0075               sin(beamAngleR) 0 -cos(beamAngleR);...
0076               0 sin(beamAngleR) -cos(beamAngleR);...
0077              0 -sin(beamAngleR) -cos(beamAngleR)];
0078     
0079     % Compute xyz for each beam
0080     beam1xyz=repmat(rng2xyz(1,:),size(range,1),1).*repmat(range(:,1),1,3);
0081     beam2xyz=repmat(rng2xyz(2,:),size(range,1),1).*repmat(range(:,2),1,3);
0082     beam3xyz=repmat(rng2xyz(3,:),size(range,1),1).*repmat(range(:,3),1,3);
0083     beam4xyz=repmat(rng2xyz(4,:),size(range,1),1).*repmat(range(:,4),1,3);
0084     
0085     % Correct beam 1 xyz for heading, pitch, and roll and compute elevation
0086     beam1enu(:,1)=ens;
0087     beam1enu(:,2)=sum(trans2e.*beam1xyz,2);
0088     beam1enu(:,3)=sum(trans2n.*beam1xyz,2);
0089     beam1enu(:,4)=sum(trans2u.*beam1xyz,2);
0090     beam1enu(:,2:4)=beam1enu(:,2:4)+geo;
0091     
0092     % Correct beam 2 xyz for heading, pitch, and roll and compute elevation
0093     beam2enu(:,1)=ens;
0094     beam2enu(:,2)=sum(trans2e.*beam2xyz,2);
0095     beam2enu(:,3)=sum(trans2n.*beam2xyz,2);
0096     beam2enu(:,4)=sum(trans2u.*beam2xyz,2);
0097     beam2enu(:,2:4)=beam2enu(:,2:4)+geo;
0098     
0099     % Correct beam 3 xyz for heading, pitch, and roll and compute elevation
0100     beam3enu(:,1)=ens;
0101     beam3enu(:,2)=sum(trans2e.*beam3xyz,2);
0102     beam3enu(:,3)=sum(trans2n.*beam3xyz,2);
0103     beam3enu(:,4)=sum(trans2u.*beam3xyz,2);
0104     beam3enu(:,2:4)=beam3enu(:,2:4)+geo;
0105     
0106     % Correct beam 4 xyz for heading, pitch, and roll and compute elevation
0107     beam4enu(:,1)=ens;
0108     beam4enu(:,2)=sum(trans2e.*beam4xyz,2);
0109     beam4enu(:,3)=sum(trans2n.*beam4xyz,2);
0110     beam4enu(:,4)=sum(trans2u.*beam4xyz,2);
0111     beam4enu(:,2:4)=beam4enu(:,2:4)+geo;
0112     
0113     % Create final matrix
0114     exyz=[beam1enu;beam2enu;beam3enu;beam4enu];
0115     exyz=sortrows(exyz,1);
0116

Generated on Thu 21-Aug-2014 10:40:31 by m2html © 2005