% plots chl vs. bbp and compares with published data

% loads:
  % float0005.mat (generated by applyCalProfile.m)  

% No mat files are saved

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

clear all
close all

% get float data
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

figure('Units','inches','Resize','off','position',[0 0 3.5 3],'paperposition',[0.5 4 3.5 3]);
I=find(isfinite(Chl_b_corr.*B_LSS_b_corr)==1 &Chl_b_corr>0.02 & P<300 & P>1);
loglog(Chl_b_corr(I),B_LSS_b_corr(I),'ko','MarkerSize',3)
hold on
I=find(isfinite(Chl_b_corr.*B_LSS_b_corr)==1 &Chl_b_corr>0.02 & P<10 & P>1);
loglog(Chl_b_corr(I),B_LSS_b_corr(I),'LineStyle','none','MarkerEdgeColor',[0.8 0.8 0.8],'Marker','o','MarkerSize',3)
chloro=[0:0.01:max(Chl_b_corr(I))];
%bbp_Wang=0.004*chloro.^0.357;% N=19
bbp_Ross=0.001*chloro.^0.667;% N=67
bbp_APFZ=0.004*chloro.^0.822;%
bbp_Huot=(0.005049-5.058e-6*440)*chloro.^(0.298+0.000486*440);
conv_factor=(440/550)^(-1); %1.25
%loglog(chloro,bbp_Wang*1.25,'k');
%([0.03 0.14],[0.001 0.0016],':k')
%loglog(chloro,1.25*bbp_Ross,':k');
%loglog(chloro,1.25*bbp_APFZ,'-k');
%loglog([0.14 max(Chl_b_corr(I))],[0.0016 0.005/0.8*max(Chl_b_corr(I))],'k')
%loglog(chloro,bbp_Huot,'--k');

%bbp_Morel=0.3*chloro.^0.52;
conv_factor=(440/550)^(-1); %1.25
% loglog(chloro,bbp_Huot*1.25,'-.k','LineWidth',2); % Huo07
loglog(chloro,bbp_Huot*1.25,'-','LineWidth',2,'Color',[0 0 1]); % Huo07 dark blue

% loglog(chloro,1.25*bbp_Ross,':k','LineWidth',2);
loglog(chloro,1.25*bbp_Ross,'-','LineWidth',2,'Color',[0 1 1]); % Beh05 black

% loglog(chloro,1.25*bbp_APFZ,'-k','LineWidth',2);  % Rey01a red
loglog(chloro,1.25*bbp_APFZ,'-','LineWidth',2,'Color',[1 0 0]);  % Rey01a red

% loglog([0.03 0.14],[0.001 0.0016],'--k','LineWidth',2); % Rey01b
loglog([0.03 0.14],[0.001 0.0016],'-','LineWidth',2,'Color',[0 0 0]); % Rey01b cyan

% loglog([0.14 max(Chl_b_corr(I))],[0.0016 0.005/0.8*max(Chl_b_corr(I))],'--k','LineWidth',2)
loglog([0.14 max(Chl_b_corr(I))],[0.0016 0.005/0.8*max(Chl_b_corr(I))],'-k','LineWidth',2)

% draw legend
% h=plot([0.50,1.13],[0.00022 0.00022],'-.k','Linewidth',2); % Huo07
h=plot([0.50,1.13],[0.00022 0.00022],'-','Linewidth',2,'Color',[0 0 1]); % Huo07 dark blue
% h=plot([0.50,1.13],[0.00015 0.00015],':k','Linewidth',2);  % Beh05
h=plot([0.50,1.13],[0.00015 0.00015],'-','Linewidth',2,'Color',[0 1 1]);  % Beh05 black
% h=plot([0.50,1.13],[0.00032 0.00032],'-k','Linewidth',2);  % Rey01a
h=plot([0.50,1.13],[0.00032 0.00032],'-','Linewidth',2,'Color',[1 0 0]);  % Rey01a red
% h=plot([0.50,1.13],[0.00047 0.00047],'--k','Linewidth',2); % Rey01b
h=plot([0.50,1.13],[0.00047 0.00047],'-','Linewidth',2,'Color',[0 0 0]); % Rey01b cyan

hold off
axis([0.02 4 0.0001 0.02])
set(gca,'FontName','Times New Roman','FontSize',10);
set(gca,'LineWidth',0.75);
set(gca,'yMinorTick','off');
set(gca,'xMinorTick','off');
ylabel('b_{bp}(440) (m^{-1})');
xlabel('Chlorophyll (mg m^{-3})');

% write legend text
annotation('textbox',[0.73 0.320 0.1 0.1],'String','Beh05','EdgeColor','none','FontName','Times New Roman','FontSize',10);
annotation('textbox',[0.73 0.265 0.1 0.1],'String','Rey01a','EdgeColor','none','FontName','Times New Roman','FontSize',10);
annotation('textbox',[0.73 0.210 0.1 0.1],'String','Huo07','EdgeColor','none','FontName','Times New Roman','FontSize',10);
annotation('textbox',[0.73 0.155 0.1 0.1],'String','Rey01b','EdgeColor','none','FontName','Times New Roman','FontSize',10);
