function [rho_smooth,depth_smooth]=smoothprofile(rho,dpth)
% function that interpolates profile data into a uniform 5m depth bins, and
% smoothes
% code copied from Dan's version of MLD_bmax code
% 

% interpolate to uniform 2 m grid
indnotnan=[];
indnotnan=find(isnan(rho)==0);
depth_smooth = (5:5:2500)';
dpthu=[];
ia=[];
[dpthu,ia]=unique(dpth(indnotnan));
rhou=[];
rhou=rho(indnotnan);
rhou=rhou(ia);
rhofix=interp1(dpthu',rhou',depth_smooth,'linear','extrap');
% smooth with moving average using filtfilt (to preserve phase)
a=[];
b=[];
a=1;
b=1./15.*ones(15,1);
rho_smooth=filtfilt(b,a,rhofix);
end
