
function dataOut = read_M1_GPS_daily(buoy,dep)

% Unlike OA code, this loads ALL the individual daily files
%  (not just yesterday, today, and tomorrow's files).
% The only reason this function is necessary at all, is that 
%  the 'full' data fill starts 4/2013, whereas these daily
%  files start when they're supposed to (2/2012).

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

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

fmt = ['%d%*c%f %f %f' repmat('%*f ',1,6) '%*s'];

d = dir([mydir '20*']);

%do it
 data=[];
 for n=1:length(d)

   fid = fopen([mydir d(n).name]);

    %get year from filename
     yr = str2num(d(n).name(1:4));

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

    %read data
     fseek(fid,ft,'bof');
     while ~feof(fid)
       out = fscanf(fid,fmt,[4,Inf])';
       if size(out,2)==4
         data = [data; yr*ones(size(out,1),1) out];
       else
         fgetl(fid); %get the bad line and move to the next line
       end
     end
     fclose(fid);
     clear fid yr ft out ans;

 end
 clear d fmt n;

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

