% This code plots the downward CTD data we collected on the cruise.

clear all
% close all
path='/Users/jfiedler/Documents/GOTOSEE_CTD/data_SP1613/proc/';
ctdlist=dir(fullfile(path,'*.mat'));

% Remove raw from directory
ii=[];
for i=1:length(ctdlist)
    str=ctdlist(i).name;
    if strcmp('raw.mat',str(end-6:end))
        ii=[ii i];
    end
end
ctdlist(ii)=[];
total=length(ctdlist);
clear i ii str 

%% Load first CTD cast
i = 1;
load([path ctdlist(i).name], 'datad_1m')

% the structure that contains all our data is datad (which stands for "data
% down." 
% datad % uncomment to see what's in the data structure
temp1 = datad_1m.t1;
salt1 = datad_1m.s1;
depth1 = datad_1m.depth;
density1 = datad_1m.theta1;


i = 2;
load([path ctdlist(i).name], 'datad_1m')

% the structure that contains all our data is datad (which stands for "data
% down." 
% datad % uncomment to see what's in the data structure
temp2 = datad_1m.t1;
salt2 = datad_1m.s1;
depth2 = datad_1m.depth;
density2 = datad_1m.theta1;


i = 3;
load([path ctdlist(i).name], 'datad')

temp3 = datad.t1;
salt3 = datad.s1;
depth3 = datad.depth;
density3 = datad.theta1;

subplot(1,3,1)
plot(temp1,depth1,'linewidth',2)
hold on
plot(temp2,depth2,'linewidth',2)
plot(temp3,depth3,'linewidth',2)
grid; axis ij;
ylabel('Depth (m)')
xlabel('Temperature (\circ C)')
title('Temperature')
legend('001','002','003','location','southwest')

subplot(1,3,2)
plot(salt1,depth1,'linewidth',2)
hold on
plot(salt2,depth2,'linewidth',2)
plot(salt3,depth3,'linewidth',2)
grid; axis ij;
ylabel('Depth (m)')
xlabel('Salinity (PSU)')
title('Salinity')

subplot(1,3,3)
plot(density1,depth1,'linewidth',2)
hold on
plot(density2,depth2,'linewidth',2)
plot(density3,depth3,'linewidth',2)
grid; axis ij;
ylabel('Depth (m)')
xlabel('Potential Density (kg/m^3)')
title('Potential Density (kg/m^3)')



