function d_out = ridfill(d_in)
%fill_lp.m - searches for fill values and either fills them via a 1-D interpolation if the 
%values stand alone or it places 0's in all areas affected by fill values once the data
% is low pass filtered.
%
%	input = hour averaged data and time vector
%
%	ouput = 33 hour lowpass filterd data subsampled every 6 hours and time vector
%
%
%	Calls: plfilt.m by Rich Signell to do filtering.
%
%Ben Gutierrez 07/09/2001

%badu = find(d_in > 1000);
%badu

	%Interpolate over bad points for each variable
%	if isempty(badu)==0,
   
%		[m,n] = size(badu);

%		for k = 1:n,
%   		d_in(badu(k)) = (d_in(badu(k) + 1) + d_in(badu(k) - 1))/2;
%		end
   
%	else
%   	fprintf('No fill values for currents! ')
%	end


     d_out = d_in;

	
   
   %CHECK FOR FILL VALUE PROBLEMS
	badu_a = find(d_out > 1000);
	if ~isempty(badu_a),
   
	 	d_out(badu_a) = 0;
   
	else
   	fprintf('No fill values!\n')
   end
   
	badu_b = find(d_out < -1000);
	if ~isempty(badu_b),
   
	 	d_out(badu_b) = 0;
   
	else
   	fprintf('No fill values!\n')
	end
	  
