%overlaySciData.m

clear;


MAXi=5000;
path = 'raw';

fileList = dir(path);
fileList = fileList(~[fileList.isdir]); %remove directories
[junk, sortorder] = sort([fileList.datenum]);
fileList = fileList(sortorder); %list is now in ascending date order
numfiles = numel(fileList);
%In = cell(numfiles,1);
i=1;

P = NaN(numfiles,MAXi);
T = NaN(numfiles,MAXi);
S = NaN(numfiles,MAXi);
FL = NaN(numfiles,MAXi);
FLd = NaN(numfiles,MAXi);
O2 = NaN(numfiles,MAXi);
O2d = NaN(numfiles,MAXi);
CPtime = NaN(numfiles,MAXi);

for ii = 1:numfiles
   fp = sprintf('%s/%s',path,fileList(ii).name);
   fprintf('Processing %s\n',fp);
   [cpP,cpT,cpS,flbbFL,flbbDepth,optodeO2Conc,optodeDepth,cpDateTimeNum]=parseSciData(fp);
   P(i,:)=cpP;
   T(i,:)=cpT;
   S(i,:)=cpS;
   FL(i,:)=flbbFL;
   FLd(i,:)=flbbDepth;
   O2(i,:)=optodeO2Conc;
   O2d(i,:)=optodeDepth;
   CPtime(i,:)=cpDateTimeNum(1,1);
   i=i+1;
end


% figure(1);title('CPF');
% 
% subplot(2,2,1);
% plot(cpT(:),-cpP(:)); hold on
% xlabel('degC'),ylabel('dBar');
% grid on;
% 
% 
% subplot(2,2,2);
% plot(cpS(:),-cpP(:)); hold on
% xlabel('PSU'),ylabel('dBar');
% grid on;
% 
% subplot(2,2,3);
% plot(flbbFL(:),flbbDepth(:)); hold on
% 
% xlabel('flbb'),ylabel('dBar');
% grid on;
% 
% subplot(2,2,4);
% plot(optodeO2Conc(:),optodeDepth(:)); hold on
% 
% xlabel('O2'),ylabel('dBar');
% grid on;

save CPF23MAR16.mat;
