% Routine to process Buoy WInd data and generate a stress estimate
% Written as part of an automated crontab job operating on 3 buoys
% 44005, 44008, and 44011 (see autobuoy.pl)
% assumes header line is removed from each .txt file and renamed "b440XX.txt.new"

for ib=[5 8 11];
  if ib<10;
    eval(['load /home3/ocn/jmanning/b4400',num2str(ib),'.txt.new']);
    eval(['w=b4400',num2str(ib),';']);
  else;
    eval(['load /home3/ocn/jmanning/b440',num2str(ib),'.txt.new']);
    eval(['w=b440',num2str(ib),';']);
  end;
  k=0;
  skip=1;
  disp('WARNING: wind.txt files sometimes come with minutes col');
  disp('WARNING: anemometer hgt is hardcoded to 5m');
  for i=1:skip:length(w);
    k=k+1;
    yd(k)=julian(w(i,2),w(i,3),w(i,1),w(i,4)*100);
    [u(k),v(k)]=sd2uv(w(i,6),w(i,5));
    u(k)=u(k)*(-1);
    v(k)=v(k)*(-1);
    [taux(k),tauy(k)]=wstr(u(k),v(k),5);
  end;
  y=[yd;taux;tauy; u; v; ib*ones(1,length(u))]';
  [ydn,id]=sort(y(:,1));
  y=y(id,:);
  fploopy(y,'wind.dat','a');
  fploopy(y,'newwind.dat');
  clear y u v taux tauy yd w
end;


