% function [X2,X1] = cleanup_lb(X,Y,y1,y2,i,N)
function [X1] = cleanup_lb(X,Y,y1,i,N)

bf=ones(1,N)/N;  %Use this for averaged time series
af=1;
% bf1=ones(1,3)/3;  %Use this for 1 minute output
% af1=1;

x1=interp1(Y(i),X(i),y1,'linear','extrap');
clear X Y
X1=x1;
X1(~isnan(x1))=filtfilt(bf,af,x1(~isnan(x1))); 
% clear x1 
% X2=interp1(y1,x,y2,'linear','extrap');
% clear y1 y2 x
end

