% plots parameter vs. date at 900m through time
% plots parameter vs. date by distinct depths (the "vertical plots")

% loads:
  % float0005 (generated by applyCalProfile.m)
  % MLD.txt for adding the mixed layer depth line

% no mat files are saved   

% written by E. Boss, UMaine, 2006
% email: emmanuel.boss@maine.edu

clear all
close('all')

load float0005 % float0005 contains:
profileNum=float0005(:,1); %profile number
date=float0005(:,2); %date
lat=float0005(:,3); %latitude (degrees)
lon=float0005(:,4); %longitude (degrees)
P=float0005(:,5); %depth (m)
theta=float0005(:,6); %potential temperature (degrees C)
S=float0005(:,7); %salinity (psu)
sigma=float0005(:,8); %density-1000 (kg/m3)
B_LSS_b_corr=float0005(:,9); %bb (m-1, calibrated using MODIS data downloaded 01/11/08)
Chl_b_corr=float0005(:,10); %chlorophyll (mg/m3, calibrated using MODIS data downloaded 01/11/08) 
O2sat=float0005(:,11); %oxygen (% saturation) !oxygen sensor not working
O2=float0005(:,12); %oxygen (um/kg) !oxygen sensor not working
POC_b=float0005(:,13);
C_phy=float0005(:,14);
profile=float0005(:,15); % (in days from start)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PLOTS

%%%%%%%%%%%%%%%%%%%%% parameter vs. time and depth
MLD=load('MLD.txt');

% get data greater than 2m deep
I=find(P>2);

h=figure('Units','inches','Resize','off','position',[0 0 7.25 5.25],'paperposition',[0.5 3 7.25 5.25]); %density: TOP LEFT PANEL
subplot('Position',[0.08 0.55 0.325 0.355]);
scatter(tt,-P,5,sigma,'filled');
colorbar(caxis,[0.42 0.55 0.018 0.35]);
hold on 
plot(unique(tt),-MLD,'k','LineWidth',1)
hold off
% xlim([min(tt),max(tt)]); % max is 733215
xlim([732099 max(tt)]);
% ylim([-300,max(-P)]);
ylim([-305,0]);
set(gca,'FontName','Times New Roman');
set(gca,'FontSize',10);
set(gca,'LineWidth',0.75);
tick = [732099 732464 732829 733194 733560];
set(gca,'XTick',tick);
set(gca, 'XTickLabel', datestr(tick,'dd mmm yy'));
set(gca,'YTick',[-300 -250 -200 -150 -100 -50 0]);
% set(gca,'XTick',[732115 732480 732850 733215]);
% datetick(gca,'x','mmmyy','keepticks');
% set(gca,'XTick',[]);
% title('Density-1000 (kg m^{-3})');
ylabel('Depth (m)');
annotation('textbox',[0.505 0.78 0.08 0.07587],'String',{'Density-1000 (kg m^{-3})'},'Rotation',[270],'EdgeColor','none','FontName','Times New Roman','FitHeightToText','on');

figure(h); %chlorophyll: TOP RIGHT PANEL
subplot('Position',[0.55 0.543 0.29 0.365]);
scatter(tt(I),-P(I),5,log10(Chl_b_corr(I)),'filled');
hold on 
plot(unique(tt),-MLD,'k','LineWidth',1)
hold off
% caxis([0 2]);
% colorbar(caxis,[0.86 0.12 0.02 0.343]);
colorbar(caxis,[0.85 0.55 0.02 0.349]);
% xlim([min(tt),max(tt)]);
axis(axis,[7.321e+005 7.332e+005 -305 0]);
xlim([732099 max(tt)]);
% ylim([-300,max(-P)]);
ylim([-305,0]);
set(gca,'FontName','Times New Roman');
set(gca,'FontSize',10);
set(gca,'LineWidth',0.75);
tick = [732099 732464 732829 733194 733560];
set(gca,'XTick',tick);
set(gca, 'XTickLabel', datestr(tick,'dd mmm yy'));
% set(gca,'XTick',[732115 732480 732850 733215]);
% datetick(gca,'x','mmmyy','keepticks');
set(gca,'YTick',[]);
% title('Log(chlorophyll) (mg/m^3)');
% xlabel('Day of the Year');
annotation('textbox',[0.95 0.81 0.08 0.07587],'String',{'log(chlorophyll) (mg m^{-3})'},'Rotation',[270],'EdgeColor','none','FontName','Times New Roman','FitHeightToText','on');

% figure(h); %potential temperature
% subplot('Position',[0.55 0.543 0.29 0.365]);
% scatter(tt,-P,5,theta,'filled');
% colorbar(caxis,[0.86 0.543 0.02 0.357]);
% hold on 
% % plot(unique(tt),-ZZ_mld,'k','LineWidth',2)
% plot(unique(tt),-MLD,'k','LineWidth',2)
% hold off
% % xlim([min(tt),max(tt)]);
% xlim([732099 max(tt)]);
% % ylim([-300,max(-P)]);
% ylim([-305,0]);
% set(gca,'FontName','Times New Roman');
% set(gca,'FontSize',10);
% set(gca,'LineWidth',0.75);
% tick = [732099 732464 732829 733194 733560];
% set(gca,'XTick',tick);
% set(gca, 'XTickLabel', datestr(tick,'dd mmm yy'));
% % set(gca,'XTick',[732115 732480 732850 733215]);
% % datetick(gca,'x','mmmyy','keepticks');
% % set(gca,'XTick',[]);
% set(gca,'YTick',[]);
% % title('Potential Temperature (^oC)');
% % ylabel('depth [m]');
% annotation('textbox',[0.95 0.80 0.08 0.07587],'String',{'Potential Temperature (^oC)'},'Rotation',[270],...
%     'EdgeColor','none','FontName','Times New Roman','FitHeightToText','on');

% figure(h); %salinity
% subplot(2,2,2);
% scatter(tt,-P,5,S,'filled'),colorbar;
% hold on 
% plot(unique(tt),-MLD,'k','LineWidth',2)
% hold off
% xlim([min(tt),max(tt)]);
% ylim([-300,max(-P)]);
% set(gca,'FontName','Times New Roman');
% set(gca,'FontSize',16);
% set(gca,'XTick',[732115 732480 732850 733215]);
% datetick(gca,'x','mmmyy','keepticks');
% title('Salinity [PSU]');
% ylabel('Depth [m]');

figure(h); %side scatter: BOTTOM LEFT PANEL
subplot('Position',[0.08 0.12 0.325 0.350]);
scatter(tt(I),-P(I),5,log10(B_LSS_b_corr(I)),'filled');
% caxis([0 0.005]);
hold on 
plot(unique(tt),-MLD,'k','LineWidth',1)
hold off
colorbar(caxis,[0.42 0.12 0.018 0.345]);
% xlim([min(tt),max(tt)]);
xlim([732099 max(tt)]);
% ylim([-300,max(-P)]);
ylim([-305,0]);
set(gca,'FontName','Times New Roman');
set(gca,'FontSize',10);
set(gca,'LineWidth',0.75);
tick = [732099 732464 732829 733194 733560];
set(gca,'XTick',tick);
set(gca, 'XTickLabel', datestr(tick,'dd mmm yy'));
% set(gca,'XTick',[732115 732480 732850 733215]);
% datetick(gca,'x','mmmyy','keepticks');
set(gca,'YTick',[-300 -250 -200 -150 -100 -50 0]);
% title('Log(sidescatter) (m^{-1})');
xlabel('Date');
ylabel('Depth (m)');
annotation('textbox',[0.505 0.34 0.08 0.07587],'String',{'log(b_{bp}(440)) (m^{-1})'},'Rotation',[270],...
    'EdgeColor','none','FontName','Times New Roman','FitHeightToText','on');

figure(h); %chlorophyll/bb: BOTTOM RIGHT PANEL
subplot('Position',[0.55 0.12 0.29 0.35]);
scatter(tt(I),-P(I),5,(Chl_b_corr(I)./B_LSS_b_corr(I)),'filled');
hold on 
plot(unique(tt),-MLD,'k','LineWidth',1)
hold off
% caxis([0 2]);
colorbar(caxis,[0.86 0.12 0.02 0.343]);
% xlim([min(tt),max(tt)]);
axis(axis,[7.321e+005 7.332e+005 -305 0]);
xlim([732099 max(tt)]);
% ylim([-300,max(-P)]);
ylim([-305,0]);
set(gca,'FontName','Times New Roman');
set(gca,'FontSize',10);
set(gca,'LineWidth',0.75);
tick = [732099 732464 732829 733194 733560];
set(gca,'XTick',tick);
set(gca, 'XTickLabel', datestr(tick,'dd mmm yy'));
% set(gca,'XTick',[732115 732480 732850 733215]);
% datetick(gca,'x','mmmyy','keepticks');
set(gca,'YTick',[]);
xlabel('Date');
annotation('textbox',[0.95 0.36 0.08 0.07587],'String',{'Chlorophyll/b_{bp} (mg m^{-2})'},...
    'Rotation',[270],'EdgeColor','none','FontName','Times New Roman','FitHeightToText','on');
% ylabel('depth [m]');
