function y=W1(lambda,nominal_wl);
% 2005.12
% Emmanuel Boss
% emmanuel.boss@maine.edu
% School of Marine Sciences, University of Maine, USA
%
% Calculates the wavelength weighting function for Eco-type sensors.
%
% INPUT
% Incident wave wavelength                      (lambda) [nm] 
% Nomial wavelength of sensor                   (nominal_wl)  [nm]   
% NB: the LED output and filter wavelengths response are loaded from the
% appropriate files (computed by us for our sensor) and Wetlabs (for the receiver filters
% data). Photodiode responsivity curve is a digitazation of a curve found on
% the WWW at http://beammeasurement.mellesgriot.com/tut_photo_det.asp

% OUTPUT
% integrand value                               (y)

%LED output spectra, starting with 660nm. 

if nominal_wl==412
    load LED_412_rad
elseif nominal_wl==440
    load LED_440_rad
    %load LED_Ecoblue_rad
elseif nominal_wl==488
    load LED_488_rad
elseif nominal_wl==510
    load LED_510_rad
elseif nominal_wl==532
    load LED_532_rad
elseif nominal_wl==595
    load LED_595_rad
elseif nominal_wl==650
    load LED_650_rad
    %load LED_Ecored_rad
elseif nominal_wl==676
    load LED_676_rad
elseif nominal_wl==715
    load LED_715_rad    
else
     disp('the nominal wavelength need to be 412, 440, 488, 512, 532, 555, 650, 676, or 715');
     return
end
W1a=interp1(wl, norm_rad,lambda,'cubic');


%receiver filter spectra
if nominal_wl==412
    load filt_412
elseif nominal_wl==440
    load filt_440
elseif nominal_wl==488
    load filt_488
elseif nominal_wl==510
    load filt_510
elseif nominal_wl==532
    load filt_532
elseif nominal_wl==595
    load filt_595
elseif nominal_wl==650
    load filt_650
elseif nominal_wl==676
    load filt_676
elseif nominal_wl==715
    load filt_715    
else
     return
end
W1b=interp1(wl(1,:), norm_filt,lambda,'cubic');

%photodiode reponsivity spectra
W1c=[350 0.01;400 0.08;450 0.17;500 0.24;550 0.3;600 0.35;650 0.4;700 0.44;750 0.48;800 0.52]';
W1c_l=interp1(W1c(1,:), W1c(2,:),lambda,'cubic');

y=W1a.*W1b.*W1c_l;
