function remove_sw_biasA
% remove_sw_biasA determines the nighttime
% bias in sw and adjusts sw. for LMG03-02.
% uses sopar to determine when daylight.
% 2/27/03

clf
load lmg_met1m

swbase=nan*sw;
m=find(sopar<=-0);
% plot(t,sopar,t(m),sopar(m),'r')

M=length(sw);
mend=[m(end)+1:M]';

swbase(m)=sw(m);

swbase=gapfil(swbase);
plot(t,sw,t,swbase,'r')
pause

% plot(t,swn,t,sw-swbase,'r')

swn=sw-swbase;
swn(mend)=sw(mend);

% make new base 0
m=find(swn<0);
swn(m)=0;
swn(1:8)=0;

save swnew swn
clear
load lmg_met1m
load swnew
save lmg_met1m



