# ADCP_PlotBeamDepths

## PURPOSE

This function plots the beam depths given a csv file output from VMT.

## SYNOPSIS

function ADCP_PlotBeamDepths

## DESCRIPTION

    This function plots the beam depths given a csv file output from VMT.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function ADCP_PlotBeamDepths
    0002
    0003 %This function plots the beam depths given a csv file output from VMT.
    0004
    0005 %P.R. Jackson, 4-16-09
    0006
    0007 [file,path] = uigetfile({'*.txt;*.csv','All Text Files'; '*.*','All Files'},'Select Bathy Text File');
    0008 infile = [path file];
    0009 disp('Loading Bathy File...' );
    0010 disp(infile);
    0011 data = dlmread(infile);
    0012
    0013 ens   = data(:,1);
    0014 x     = data(:,2);
    0015 y     = data(:,3);
    0016 z     = data(:,4);
    0017
    0018 %Break out by beam (accepting only ensembles with all beams valid)
    0019
    0020 xb1 = [];
    0021 xb2 = [];
    0022 xb3 = [];
    0023 xb4 = [];
    0024 yb1 = [];
    0025 yb2 = [];
    0026 yb3 = [];
    0027 yb4 = [];
    0028 zb1 = [];
    0029 zb2 = [];
    0030 zb3 = [];
    0031 zb4 = [];
    0032
    0033 for i = min(ens):1:max(ens)
    0034     indx = find(ens == i);
    0035     if length(indx) == 4;
    0036         xb1 = [xb1; x(indx(1))];
    0037         xb2 = [xb2; x(indx(2))];
    0038         xb3 = [xb3; x(indx(3))];
    0039         xb4 = [xb4; x(indx(4))];
    0040         yb1 = [yb1; y(indx(1))];
    0041         yb2 = [yb2; y(indx(2))];
    0042         yb3 = [yb3; y(indx(3))];
    0043         yb4 = [yb4; y(indx(4))];
    0044         zb1 = [zb1; z(indx(1))];
    0045         zb2 = [zb2; z(indx(2))];
    0046         zb3 = [zb3; z(indx(3))];
    0047         zb4 = [zb4; z(indx(4))];
    0048     end
    0049 end
    0050
    0051 %Now compute distances from start for each beam
    0052
    0053 db1 = sqrt((xb1(1) - xb1).^2 + (yb1(1) - yb1).^2);
    0054 db2 = sqrt((xb2(1) - xb2).^2 + (yb2(1) - yb2).^2);
    0055 db3 = sqrt((xb3(1) - xb3).^2 + (yb3(1) - yb3).^2);
    0056 db4 = sqrt((xb4(1) - xb4).^2 + (yb4(1) - yb4).^2);
    0057
    0058 %Plot
    0059
    0060 figure(1); clf
    0061 plot(db1,zb1,'k-','LineWidth',2); hold on
    0062 plot(db2,zb2,'r-','LineWidth',2); hold on
    0063 plot(db3,zb3,'b-','LineWidth',2); hold on
    0064 plot(db4,zb4,'g-','LineWidth',2); hold on
    0065 xlabel('Distance (m)')
    0066 ylabel('Depth (m)')
    0067
    0068 legend('beam 1','beam 2','beam 3','beam 4','Location','SouthEast')
    0069
    0070
    0071 %Output the data
    0072 if 1
    0073     outmat = [db1 db2 db3 db4 zb1 zb2 zb3 zb4];
    0074     dlmwrite([infile(1:end-4) '_BeamXS.csv'],outmat)
    0075 end
    0076
    0077