function [vsmooth] = best_smoother(vsm,windnoise)
% Smooths best track wind speed matrix vsm, which must be in knots. June, 2025
%
m=3;    % order of polynomial
fl=7;   % frame length of data vector
%--------------------------------------------------------------------------
vsmooth=vsm;
[n,~]=size(vsm);
[~,jmax]=min(vsm,[],2);
jmax=jmax-1;
jmax=max(jmax,fl);
for i=1:n
    vseries=vsm(i,1:jmax(i));
    noise = windnoise * (rand(size(vseries)) - 0.5);
    vr=vseries+noise;
    vsmooth(i,1:jmax(i))=sgolayfilt(vr, m, fl); 
end