function [A,B,hits]=dobin2(wind,w,jd,is) 
%function [A,B,hits]=dobin2(wind,w,jd,is) 
% DOBIN2 
% DO a BINsort of current meter velocity on the east and north wind
% components.
% 
%

% sample run
% load rocky
% dobin2(logan_wind_str,wlp(:,18),jdlp,ind)
% does binsort for each season at cdf_group 18 (u6_72)
%
xbins=[-5:1:5];
ybins=[-5:1:5];
axlim=[-5 5 -5 5];
%
n=length(is);
for ii=1:n-1;
  k=is(ii):is(ii+1);
  ind=find([wind(k)+w(k)]~=NaN);
  if(length(ind)>20),
    wu=real(wind(k(ind)));
    wv=imag(wind(k(ind)));
    u=real(w(k(ind)));
    v=imag(w(k(ind)));
    [A,hits,xc,yc]=binsort(wu,wv,u,xbins,ybins);
    [B,hits,xc,yc]=binsort(wu,wv,v,xbins,ybins);
%
% PLOTTING STUFF
%
  hold off
  axis('square')
  axis(axlim)
  [xx,yy]=meshdom(xc,yc);
  arrows(xx(:),yy(:),A(:),B(:),1.,1.,'g-')
  grid
  xlabel('u wind (dyn/cm2)')
  ylabel('v wind (dyn/cm2)')
%  title('Water velocity sorted on wind');
% text(0.70,0.25,file_lbl(cdf2),'sc');
  start_time=gregorian(jd(is(ii)));
  stop_time=gregorian(jd(is(ii+1)));
  text(0.70,0.21,date_lbl(start_time,stop_time),'sc');
%text(0.70,0.17,depth_lbl(cdf2,'east'),'sc');
  if (exist('bin.met')~=2),
   meta bin
  else
   meta
  end
  pause
  showvar(xx(:),yy(:),hits(:)*sum(hits(:)))
  grid
  xlabel('u wind (dyn/cm2)')
  ylabel('v wind (dyn/cm2)')
%  title(['Hits per bin ' cdf2(1:4)])
  pause
  if (exist('hit.met')~=2),
    meta hit
  else
    meta
  end
end
end
