% function [zi]=blank(x,y,xi,yi,zi,[crit])
%
% routine to blank out gridded areas where not
% enough samples are taken for accurate contouring
% by calulating range an bearing of all observation
% points around each grid point 
%
% x,y   observation pairs 
% xi,yi grid nodes 
% zi    2-d gridded matrix
%       output with NaN's inserted where needed


function [zi]=blank(x,y,xi,yi,zi,crit);

% This takes time .. notify user
disp('Blanking operation in progress.. please wait..')
if nargin<6;
  crit=0.2*(max(x)-min(x));
  disp(['Maximum search radius defaulted to ',num2str(crit),' units.']);
end;

for i=1:length(xi);
  for j=1:length(yi);

    for k=1:length(x);
      [th(k),r(k)]=directio(xi(i)-x(k),yi(j)-y(k));
    end;

%   check for minimum distance or one sided search

%   use histogram function to get bins of angles
%    [xx,b]=hist(th,4);
%    id=find(b==0);
%    if min(r)>crit|length(id)>=3;

    if min(r)>crit;
      zi(i,j)=NaN;
    end;
  end;

% report progress to user each 25% 
  if i==floor(length(xi/4)); disp(' 25% done ...'); end;
  if i==floor(length(xi/2)); disp(' 50% done ...'); end;
end;
    