function [ufilt]=mcfilt(cdf,var,start_ymd,start_hms,stop_ymd,stop_hms)
% [ufilt]=mcfilt(cdf,var,start_ymd,start_hms,stop_ymd,stop_hms)
% lowpass a data series using the pl33 filter 
%    and write the result to an m file


if nargin==2,
  u=mcvgt(cdf,var);
  [start_ymd,start_hms,stop_ymd,stop_hms]=mcgtim(cdf);
else
  u=mcvgt(cdf,var,start_ymd,start_hms,stop_ymd,stop_hms);
end
start
%
ufilt=pl33filt(u) 
timedim=length(ufilt)-67;
time=mcvgt(cdf,'time',33,timedim);
root=max(find(cdf=='.'));
 
cdf_out=[cdf(1:root-1) '_lp.cdf'];    % tack '_lp.cdf' onto file name
 
var_out=[var '_lp'];                  % tack _lp onto variable name
 
mccre(cdf_out,'NC_CLOBBER');          % create file

mcdef(cdf_out,'time',timedim);        % define dimension

mcvdef(cdf_out,var_out,'NC_FLOAT','time');  % define variable
mcvdef(cdf_out,'time','NC_LONG','time');  % define variable

%time stuff
mcapt(cdf_out,'NC_GLOBAL','base_date','NC_SHORT',3,base_date);

mcvpt(cdf_out,var_out,0,timedim,ufilt);      % put the filtered data in 
mcvpt(cdf_out,'time',0,timedim,time);        % put the time values in


