
function dataOut = read_M1_CTD_full(buoy,dep)

% Uses *slightly* slower import method (line-by-line), which is much
%  cleaner and is the preferred method unless it's CRITICAL that the
%  function run as FAST as POSSIBLE.

if ispc
  pre = '//atlas.shore.mbari.org/';
else
  pre = '/Volumes/';
end

mydir = [pre 'oasis_coredata/deployments/' ...
  buoy '/' dep '/' buoy '/'];

fmt = ['%d%*c%f %f,%f,%*22c%d']; %M1 does not have p or S
fid = fopen([mydir 'data/microcat']);

%skip header
 hd='#';
 while ~isempty(strfind(hd,'#'))
   ft=ftell(fid);
   hd=fgetl(fid);
 end
 clear hd;

%pre-allocate for speed
 fseek(fid,ft,'bof');
 ct=0;
 while ~feof(fid)
   fgetl(fid);
   ct=ct+1;
 end

%read data
 fseek(fid,ft,'bof');
 data=NaN(ct,5);
 for n=1:ct
   s = sscanf(fgetl(fid), fmt)'; %3-5x faster than str2num
   if length(s)==5 %else an incomplete line
     data(n,:) = s([5 1:4]);
   end
 end
 fclose(fid);
 clear fid ft ct n s ans;

%get rid of incomplete lines from pre-allocating
 data(isnan(data(:,1)),:)=[];

%format time
 dataOut = [datenum([data(:,1) zeros(size(data,1),1) ...
   data(:,2)+data(:,3)/1e5]) data(:,4:end)];
 clear data;
