% determine coefficients for wetlabs/chelsea FL calib

if 1
  load SAM_001_down 
  www=Wetl;
  vvv=v0;
  fff=10.^v0;
end

if 0
 load SAM_001_fl
 www=[www' Wetl']';
 vvv=[vvv' v0']';
 fff=[fff' 10.^v0']';
end

if 0
  load SAM_001_up
  www=[www' Wetl']';
  fff=[fff' 10.^v0']';
  vvv=[vvv' v0']';
end

www(1:2)=[];
fff(1:2)=[];

if 0
www([1555:1556])=[];
fff([1555:1556])=[];

www([16989:16991])=[];
fff([16989:16991])=[];

www([45249:45253])=[];
fff([45249:45253])=[];

www([35987:35999])=[];
fff([35987:35999])=[];
end

aa=find(www < 1.2 & www > 0);

subplot(4,1,3)
plot(www(aa))
subplot(4,1,4)
plot(fff(aa))


[p,s]=polyfit(fff(aa),www(aa),2);
%%%% these below are from the downcast of cast 1 and work 'ok'
% p=[.1273 -.3648 .3207];

fl=polyval(p,[1:.01:5]); 

subplot(2,1,1)
plot(fff(aa),www(aa),'.',[1:.01:5],fl)
%axis([0.0276    7.8433   -0.2421    3.9705])

xlabel('Chelsea (10^{volts})')
ylabel('Wetlabs (\mug/l)')
title(['SAM\_001 - Intercalibration of Chelsea and Wetlabs' ...
       ' Fluorometers'])
legend('Data','Calibration curve')

return
load SAM_001_fl
plot(Wetl,press,'.',fl,press,'.')
xlabel('Chlorophyll (\mug/l)')
ylabel('Pressure (dbar)')
title('SAM\_001 - Chelsea/Wetlabs Chlorophyll')
legend('Weltabs','Chelsea')