% routine to average by depth the .data files
load /data5/jmanning/ctd/data/oc301.data
d=oc301;

% find new sta id
id=find(diff(d(:,3))<0);
id=[1;id+1];

for i=1:length(id)-1;
  idn=id(i):id(i+1)-1;
  iddep=find(d(idn,3)<=60);
  mnt(i)=mean(d(idn(iddep),5));
  mns(i)=mean(d(idn(iddep),6));
  cast(i)=d(id(i),11);
  sta(i)=d(id(i),12);
  lat(i)=d(id(i),9);
  lon(i)=d(id(i),10);
  yd(i)=d(id(i),4);
end;

y=[sta;yd; lat; lon; mnt; mns; cast]';
fploopy(y,'oc301_depave.out');

  