global d;
d=dir ('plan-01-long*');

%finds each site folder and goes into the optode data 
% for i=1:size(d,1)
   for i=1:size(d,1);
    cd (d(i).name);
    op = dir ('*-optodes');
    cd (op.name)
    %OptodeSlopesv3();
    OptodeSlopesSubRef();
end


cd MatlabData
l=dir('*v4.mat');

RefMean=ones(size(l,1),5);

for i=1:size(l,1)
    load(l(i).name);
    RefMean(i,:)=[RefDifData,StbdRefData(3)];
end

PulseNum=input('Enter Pulse Number:','s');

figure;
plot(RefMean(:,5),RefMean(:,1),'bx');
datetick('x','mmmyy','keepticks','keeplimits')
xlabel('Date');ylabel('Mean Ref Optode Difference (uM)');
title('Mean(Abs(Port Ref - Stbd Ref))');
saveas(gcf,strcat('Pulse ',PulseNum,'Mean Ref Optode Diff','.jpg'));

figure;
errorbar(RefMean(:,5),RefMean(:,1),RefMean(:,2))
datetick('x','mmmyy','keepticks','keeplimits')
xlabel('Date');ylabel('Mean + Stdev Ref Optode Difference (uM)');
title(strcat('Pulse',PulseNum ,'Mean +Std(Abs(Port Ref - Stbd Ref))'));
saveas(gcf,strcat('Pulse ',PulseNum,' Mean + Stdev Ref Optode Diff','.jpg'));


figure;
bar(RefMean(:,5),RefMean(:,2));
datetick('x','mmmyy','keepticks','keeplimits')
xlabel('Date');ylabel('Stdev Ref Optode Difference (uM)');
title(strcat('Pulse',PulseNum ,'Std(Abs(Port Ref - Stbd Ref))'));
saveas(gcf,strcat('Pulse ',PulseNum,' Stdev Ref Optode Diff','.jpg'));

figure;
plot(RefMean(:,5),RefMean(:,3),'rx');
hold on;
plot(RefMean(:,5),RefMean(:,4),'bx');
datetick('x','mmmyy','keepticks','keeplimits')
legend('port','stbd');
xlabel('Date');ylabel('Mean Temp (degC)');
title('Mean Temp Port Ref & Stbd Ref');
saveas(gcf,strcat('Pulse ',PulseNum,'Mean Temp Port & Stbd','.jpg'));

figure;
plot(RefMean(:,5),RefMean(:,3)-RefMean(:,4),'kx');
datetick('x','mmmyy','keepticks','keeplimits')
xlabel('Date');ylabel('Port Temp - Stbd Temp (degC)');
title('Port Temp - Stbd Temp');
saveas(gcf,strcat('Pulse ',PulseNum,'Port Temp - Stbd Temp','.jpg'));


