% amp_ts.m
%
% Plot time series of amplitude in selected cells.
%

nsub = 20;
if 1
   profrange = [2730 35690];
   filename = 'hale4001';
else
   profrange = [14330 48920];
   filename = 'hale5001';
end


ampmin = 8;
ampmax = [50 20 20];
prange = [0 5000];
cells = [1 5 35]

[ts, amp, dday] = adp(filename, 'ts', 'amp', nsub, profrange);
ss = (dday - dday(1))*86400;

figure
orient tall

ncells = length(cells);

for icell = 1:ncells
   subplot(ncells + 1,1,icell)
   plot(ss, squeeze(amp(cells(icell),1,:)), '.', ...
        ss, squeeze(amp(cells(icell),2,:)), '.', ...
        ss, squeeze(amp(cells(icell),3,:)), '.', ...
        ss, squeeze(amp(cells(icell),4,:)), '.')
   title([filename 'cell ' num2str(cells(icell))])
   ylabel('db')
   set(gca,'YLim',[ampmin ampmax(icell)], 'TickDir', 'out');
   grid on
end

subplot(ncells + 1, 1, ncells + 1)
plot(ss, ts(:,5))
set(gca, 'YLim', prange, 'TickDir', 'out');
ylabel('Pressure (dbar)')
xlabel('seconds')
grid on

date_it([filename ', profs ' num2str(profrange) ', nsub ' num2str(nsub)])


