% Driver routine to obtain the weighted phase function (sr^-1) needed to compute the calibration
% slope of Eco-type backscattering sensors.
% Incorporate information on the LED output, filter throughput and 
% detector responsivity, as well as finite PSD for beads.
%
%
% 2005.12
% Emmanuel Boss
% emmanuel.boss@maine.edu
% School of Marine Sciences, University of Maine, USA
%
clear all
%modal particle diameter
mean=1.992e-6;
%standard deviation oaround particle diameter
sd=0.025e-6;

subplot(2,2,1)
lambda=400:1:700;
plot(lambda,W1(lambda))
xlabel('wavelength');
ylabel('wavelength weighting function');
subplot(2,2,2)
theta=90:1:180;
plot(theta,W2(theta))
xlabel('angle');
ylabel('angular weighting function');
subplot(2,2,3)
D=[1.9:0.01:2.1]*10^-6;
plot(D,N_sphere(D))
xlabel('particle diameter [m]');
ylabel('PSD weighting function');

W2_int=quad(@W2,90,180)
weighted_b=triplequad(@b_integral,10,11,630,690,mean-3*sd,mean+3*sd)
weighted_PF=triplequad(@backscattering_integral,90,180,630,690,mean-3*sd,mean+3*sd)

weighted_PF=weighted_PF/W2_int/weighted_b