
function dataOut = read_M1_O2_full(buoy, dep)

% buoy = 'm1-slave1'
% dep = '201507'

% At some point in the time-series for the 201507 deployment, the outputted
%  strings become pretty messed up. There is often a space within the 
%  temperature field, among other problems. Use with caution.

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

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

% fmt = ['%d%*c' repmat('%f',1,13) '%d'];
fmt = ['%d %*c %f %*f %*f %f %*[^\n]'];
fid = fopen([mydir 'data/aanderaaO2']);

%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,4);
 for n=1:ct
   fline = fgetl(fid);
   s = sscanf(fline, fmt)'; %3-5x faster than str2num
   if length(s)==3 %else an incomplete line
     data(n,:) = [str2double(fline(end-3:end)) s(1:3)];
   end
 end
 fclose(fid);
 clear fid ft ct n s ans;

%NaN poorly formatted strings
 f = find(data(:,4) < 150);
 data(f,4) = NaN;
 clear f;
 
%get rid of incomplete lines from pre-allocating
 data(isnan(data(:,4)),:)=[];

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