% this m file is used to create plots of parameter vs. date by depth to
% 200m and the stability plots.  
% file loads float0005, which contains profile, date, lat, long, P, theta,
  % S, sigma, B_LSS_b_corr, Chl_b_corr, O2sat, O2
% No mat files are saved.    
    
% written by E. Boss
% UMaine
% 10/19/06    

% need to do manually: move bottom plots up closer to top plots

clear all
close('all')

load float0005
% float0005 contains:
profileNum=float0005(:,1); % profile number
date=float0005(:,2); % date
lat=float0005(:,3); % latitue (degrees)
lon=float0005(:,4); % longitude (degrees)
P=float0005(:,5); % depth (dB)
theta=float0005(:,6); % potential temperature (degrees C)
S=float0005(:,7); % salinity (psu)
sigma=float0005(:,8); % sigma
B_LSS_b_corr=float0005(:,9); % 
Chl_b_corr=float0005(:,10); %  
O2sat=float0005(:,11); % oxygen (% saturation) 
O2=float0005(:,12); % oxygen (um/kg)
POC_b=float0005(:,13);
C_phy=float0005(:,14);
profile=float0005(:,15); % (in days from start)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PLOTS 
%%%%%%%%%%%%%%%%% parameter vs. time and depth plots
% figure(1);
% % subplot(2,3,1) % density
% scatter(tt,-P,5,sigma,'filled'),colorbar;
% xlim([min(tt),max(tt)]);
% ylim([-200,max(-P)]);
% set(gca,'FontName','Times New Roman');
% set(gca,'FontSize',16);
% set(gca,'XTick',[732099 732464 732829 733194 733621]);
% datetick(gca,'x','mmmyy','keepticks');
% title('density-1000 [kg m^{-3}]')
% ylabel('depth [db]')
% xlabel('time [month] starting in 2004')
% 
% figure(2);
% % subplot(2,3,2) % temperature
% scatter(tt,-P,5,theta,'filled'),colorbar;
% xlim([min(tt),max(tt)]);
% ylim([-200,max(-P)]);
% set(gca,'FontName','Times New Roman');
% set(gca,'FontSize',16);
% set(gca,'XTick',[732099 732464 732829 733194 733621]);
% datetick(gca,'x','mmmyy','keepticks');
% title('Potential temperature [C]')
% ylabel('depth [db]')
% xlabel('time [month] starting in 2004')
% 
% figure(3);
% % subplot(2,3,3) % salinity
% scatter(tt,-P,5,S,'filled'),colorbar;
% xlim([min(tt),max(tt)]);
% ylim([-200,max(-P)]);
% set(gca,'FontName','Times New Roman');
% set(gca,'FontSize',16);
% set(gca,'XTick',[732099 732464 732829 733194 733621]);
% datetick(gca,'x','mmmyy','keepticks');
% title('Salinity [PSU]');
% ylabel('depth [db]');
% 
% figure(4);
% % subplot(2,3,4) % chlorophyll
% scatter(tt,-P,5,Chl_b_corr,'filled'),colorbar;
% xlim([min(tt),max(tt)]);
% ylim([-200,max(-P)]);
% set(gca,'FontName','Times New Roman');
% set(gca,'FontSize',16);
% set(gca,'XTick',[732099 732464 732829 733194 733621]);
% datetick(gca,'x','mmmyy','keepticks');
% title('Chlorophyll [mg/m^3]');
% ylabel('depth [db]');
% 
% figure(5);
% % subplot(2,3,5) % side scattering
% scatter(tt,-P,5,B_LSS_b_corr,'filled'),colorbar;
% xlim([min(tt),max(tt)]);
% ylim([-200,max(-P)]);
% set(gca,'FontName','Times New Roman');
% set(gca,'FontSize',16);
% set(gca,'XTick',[732099 732464 732829 733194 733621]);
% datetick(gca,'x','mmmyy','keepticks');
% title('side scatter [m^{-1}]');
% ylabel('depth [db]');

% subplot(2,3,6) % oxygen saturation - INSTRUMENT NOT WORKING
% scatter(tt,-P,5,O2./O2sat*100,'filled'),colorbar;
% caxis([90 120]);
% axis([min(tt),max(tt),-200,max(-P)]);
% datetick('x','mmmyy');
% title('Oxygen saturation');
% ylabel('depth [db]');
% xlabel('time [month] starting in 2004');

%%%%%%%%%%%%%%%%% figure 6: multi plot parameter vs. time :: CIRCLE PLOTS
I=find(P>975); % get data at depth > 900m
 
% figure(6)
% subplot(2,2,1); % density
% plot(tt(I),sigma(I),'o');
% set(gca,'xlim',[datenum('01 jun 2004') datenum('01 jun 2008')]);
% set(gca,'XTick',[datenum('01 jun 2004') datenum('01 jun 2005') datenum('01 jun 2006') datenum('01 jun 2007') datenum('01 jun 2008')]);
% set(gca,'FontName','Times New Roman');
% set(gca,'FontSize',12);
% datetick('x', 'mmmyy','keeplimits','keepticks');
% ylabel('density-1000 [kg]');
% title('Density at Depths Greater Than 975m');

figure('Units','inches','Resize','off','position',[0 0 7.25 5.25],'paperposition',[0.5 3 7.25 5.25]);
% subplot(2,2,1); % temperature
subplot('Position',[0.1 0.55 0.325 0.355]);
plot(tt(I),theta(I),'ko');
hold on;
plot([732910 732910],[0 6],'k','LineWidth',2);
plot([732985 732985],[0 6],'k','LineWidth',2);
hold off
% set(gca,'XTick',[732099 732464 732829 733194 733560]);
tick = [732099 732464 732829 733194 733560];
set(gca,'XTick',tick);
set(gca, 'XTickLabels', datestr(tick,'dd mmm yy'));
set(gca,'FontName','Times New Roman','FontSize',10,'LineWidth',0.75);
% datetick('x', 'dd-mmm-yy','keeplimits','keepticks');
% set(gca,'XTick',[]);
xlim([732090 733250]);
ylim([2.95 5.5]);
% ylabel('Potential Temperature (^{o}C)');
annotation('textbox',[0.01 0.47 0.1 0.1],'String','Potential Temperature (^{o}C)','Rotation',[90],'EdgeColor','none','FontName','Times New Roman','FontSize',10);
% xlabel('Date');
% title('Temperature at Depths Greater Than 975m');

% subplot(2,2,2); % salinity
subplot('Position',[0.55 0.55 0.29 0.365]);
plot(tt(I),S(I),'ko');
hold on;
plot([732910 732910],[34.6 35.1],'k','LineWidth',2);
plot([732985 732985],[34.6 35.1],'k','LineWidth',2);
hold off
% set(gca,'XTick',[732099 732464 732829 733194 733560]);
tick = [732099 732464 732829 733194 733560];
set(gca,'XTick',tick);
set(gca, 'XTickLabels', datestr(tick,'dd mmm yy'));
set(gca,'FontName','Times New Roman','FontSize',10,'LineWidth',0.75);
% datetick('x', 'dd-mmm-yy','keeplimits','keepticks');
xlim([732090 733250]);
ylim([34.79 35.1]);
ylabel('Salinity');
% xlabel('Date');
% title('Salinity at Depths Greater Than 975m');

% subplot(2,2,3); % side scattering
subplot('Position',[0.1 0.103 0.325 0.350]);
loglog(tt(I),B_LSS_b_corr(I),'ko');
hold on;
plot([732910 732910],[0.00009 0.01],'k','LineWidth',2);
plot([732985 732985],[0.00009 0.01],'k','LineWidth',2);
hold off
xlim([732090 733250]);
ylim([0.00009 0.01]); % moved up from 0.0001 to give room on graph
% set(gca,'XTick',[732099 732464 732829 733194 733560]);
tick = [732099 732464 732829 733194 733560];
set(gca,'XTick',tick);
set(gca, 'XTickLabels', datestr(tick,'dd mmm yy'));
set(gca,'FontName','Times New Roman','FontSize',10,'LineWidth',0.75);
% datetick('x', 'dd-mmm-yy','keeplimits','keepticks');
ylabel('b_{bp}(440) (m^{-1})');
xlabel('Date');
% title('Side Scatter at Depths Greater Than 975m');

% subplot(2,2,4); % chlorophyll
subplot('Position',[0.55 0.10 0.29 0.35]);
plot(tt(I),Chl_b_corr(I),'ko');
hold on;
plot([732910 732910],[-0.001 .05],'k','LineWidth',2);
plot([732985 732985],[-0.001 .05],'k','LineWidth',2);
hold off
xlim([732090 733250]);
ylim([-0.001 0.05 ]);
% set(gca,'XTick',[732099 732464 732829 733194 733560]);
tick = [732099 732464 732829 733194 733560];
set(gca,'XTick',tick);
set(gca, 'XTickLabels', datestr(tick,'dd mmm yy'));
set(gca,'FontName','Times New Roman','FontSize',10,'LineWidth',0.75);
% datetick('x', 'dd-mmm-yy','keeplimits','keepticks');
ylabel('Chlorophyll (mg m^{-3})');
xlabel('Date');
% title('Chlorophyll at Depths Greater Than 975m');
