function clean_lmg_sw
% clean_gould_sw creates a new SW
% time series with the variable nighttime 
% bias removed.  just for lmg02-1A period
% when ship south of palmer station.
% 2/28/02

% get sw data 
load cruise_met
swn=zeros(size(sw));
dt=t(2)-t(1);


load sw_baseline
T=X;

for k=1:2:27
   t1=T(k);t2=T(k+1);
   m=find(t>=t1 & t<=t2);m=m(:);
   swb=Y(k) + (Y(k+1)-Y(k)).*(t(m)-t1)./(t2-t1);
   swn(m)=sw(m)-swb;
end

disp([size(sw);size(swn)])

clf
plot(t,sw,t,swn,'r')
save swn swn
clear
load cruise_met
load swn
save cruise_met
delete swn.mat

