function make_lmg_met5m
% make_lmg_met5m makes 5 min time series
% of basic met data for LMG03-02 using 
% pl66tn(x,1/60/12/60) and subsample to make
% 5 min series
% 2/27/03

clear
load lmg_met1m
N=length(t);
n=[1:5:N]';
dt1=1/60;dt2=12/60;
sw=swn;sst=sstn;

% fix lw
b=wild(lw,5,3);
lw=replace(lw,b);
mlw=find(t>47.205 & t<47.45);
lw(mlw)=nan;
lw=gapfil(lw);
mlw=find(t>=58.13 & t<=58.31);
lw(mlw)=nan;
lw=gapfil(lw);
mlw=find(t>=58.72 & t<=58.78);
lw(mlw)=nan;
lw=gapfil(lw);
% plot(t,lw)

z=pl66tn(at,dt1,dt2);at=z(n);
z=pl66tn(rh,dt1,dt2);rh=z(n);
z=pl66tn(bp,dt1,dt2);bp=z(n);
z=pl66tn(sw,dt1,dt2);sw=z(n);
z=pl66tn(lw,dt1,dt2);lw=z(n);
z=pl66tn(gyro,dt1,dt2);gyro=z(n);
z=pl66tn(sst,dt1,dt2);sst=z(n);
z=pl66tn(sopar,dt1,dt2);sopar=z(n);
z=pl66tn(fluor,dt1,dt2);fluor=z(n);
z=pl66tn(u,dt1,dt2);u=z(n);
z=pl66tn(v,dt1,dt2);v=z(n);
z=pl66tn(sss,dt1,dt2);sss=z(n);
z=pl66tn(sog,dt1,dt2);sog=z(n);


x=x(n);y=y(n);t=t(n);

ws=sqrt(u.^2+v.^2);
wd=180*atan2(v,u)./pi;

% fill small gaps
m=find(isnan(sst));
sst(m)=nan;sst=gapfil(sst);
m=find(isnan(sss));
sss(m)=nan;sss=gapfil(sss);


save lmg_met5m t x y u v ws wd at rh bp sw lw sst sss fluor sog gyro

