%----------------------------------------------------
% Water column properties - 
%
%    J. G. Bellingham, 27-August-2000
%    MBARI
%----------------------------------------------------

if (~exist('ctd_depth'))
   ctd_depth = ctd_depth_prep(dataNav(:, 1), dataNav(:, mDepth), ctdlog(:,1));
   dBar = sw_pres(ctd_depth, 36.8);  % Use 36.8 as latitude....
   salt = sw_salt(10*ctdlog(:,conductivity)/sw_c3515,ctdlog(:,temperature),dBar);
end;

if (~exist('going_up'))
   yoyo_process;
end;

if (~exist('ctd_up'))
   dummy1 = 0 * dataNav(:, 1);
   dummy1(going_up) = 1;
   dummy1(going_down) = -1;
   dummy2 = interp1(dataNav(:, 1),dummy1, ctdlog(:,1), 'nearest');
   ctd_up = find(dummy2 == 1);
   ctd_down = find(dummy2 == -1);
end;

% Plot Temperature as function of depth
figure;
run_name = ExtractDirName;
title( ['Water Column Sensors:  ', run_name] );

subplot(1,4,1)
plot( ctdlog(ctd_up, temperature), ctd_depth(ctd_up), 'r.' );
hold on
plot( ctdlog(ctd_down, temperature), ctd_depth(ctd_down), 'b.' );
hold off
set( gca, 'YDir', 'rev' );
xlabel( 'Temperature (^{o}C)')
ylabel( 'Depth (m)' );
zoom on

% Plot Salinity as function of depth...
subplot(1,4,2)
plot( salt(ctd_up), ctd_depth(ctd_up), 'r.' );
hold on
plot( salt(ctd_down), ctd_depth(ctd_down), 'b.' );
hold off
set( gca, 'YDir', 'rev' );
xlabel( 'Salinity (ppt)')
zoom on

% Plot fluorometer...
if (~exist('fluor'))
   fluor = flour;
end;

subplot( 1, 4, 3 )
plot( ctdlog(ctd_up, fluor), ctd_depth(ctd_up), 'r.' );
hold on
plot( ctdlog(ctd_down, fluor), ctd_depth(ctd_down), 'b.' );
hold off
set( gca, 'YDir', 'rev' );
xlabel( 'Fluorometer (V)' )
zoom on

% Plot optical backscatter...
subplot( 1, 4, 4 )
plot( ctdlog(ctd_up, OBS), ctd_depth(ctd_up), 'r.' );
hold on
plot( ctdlog(ctd_down, OBS), ctd_depth(ctd_down), 'b.' );
hold off
set( gca, 'YDir', 'rev' );
xlabel( 'Opical Backscatter (V)' )
zoom on


