% plot velocity and velocity difference against snr

file = 'ladcp/m09_0101';
range = [33600 35600]; %[4800 6800];% [2800 4800];
nsub = 2;

if ~exist('ts','var')
   [ts, vel, amp, dday] = adp(file, 'ts', 'vel', 'amp',   range, nsub);
end
[ncells, nbeams, nprofs] = size(vel);

figure
orient tall
for ibeam = 1:4,
   v = squeeze(vel(:,ibeam,:));
   a = squeeze(amp(:,ibeam,:));
   subplot(2,2,ibeam)
   plot(a,abs(v),'.', 'MarkerSize', 3);
   grid
   axis([-10 60 0 7])
   xlabel('SNR (db)')
   ylabel('speed (m/s)')
   title(['beam ' num2str(ibeam)]);
end

date_it(['velamp.m; ' file ' ' num2str(range)]);
ht = findobj(gcf,'Type', 'text');
set(ht,'Interpreter','none');


figure
orient tall
for ibeam = 1:4,
   v = squeeze(vel(:,ibeam,:));
   a = squeeze(amp(:,ibeam,:));
   dv = abs(diff(v));
   aa = a(1:(end-1),:);
   ab = a(2:end,:);
   ma = min([aa(:).' ; ab(:).']);
   ma = reshape(ma,(ncells-1),nprofs);

   subplot(2,2,ibeam)
   plot(ma,dv,'.', 'MarkerSize', 3);
   grid
   axis([-10 60 0 14])
   xlabel('min SNR (db)')
   ylabel('speed diff (m/s)')
   title(['beam ' num2str(ibeam)]);
end

date_it(['velamp.m; ' file ' ' num2str(range)]);
ht = findobj(gcf,'Type', 'text');
set(ht,'Interpreter','none');


