function dd = read_aux(instclass, filebase)
% dd = read_aux(instclass, filebase)
% filebase should include the path
%should have already run split_aux.py
%


hdgfile = sprintf('%s.hdg', filebase);
navfile = sprintf('%s.mat', filebase);

if (exist(hdgfile, 'file'))
   hdg = load(hdgfile);
   if (length(hdg) > 0)
      dd.loggerday  = hdg(:,1);
      dd.pingnum    = hdg(:,2);   %sequential ping number in this file
      dd.rawoffset  = hdg(:,3);   %offset into raw file for this ping
                                  %dd.attday     = hdg(:,4);
                                  dd.gyro       = hdg(:,5); 
                                  dd.ashgyrodiff= hdg(:,6); 
                                  dd.att.pitch  = hdg(:,7); 
                                  dd.att.roll   = hdg(:,8); 
                                  dd.att.reacq  = hdg(:,9); 
                                  dd.refu       = hdg(:,10);
                                  dd.refv       = hdg(:,11);
                                  dd.refw       = hdg(:,12);
                                  dd.refe       = hdg(:,13);
                                  dd.numrefbins = hdg(:,14);
   else
      fprintf('hdg file has zero length for %s\n',filebase)
   end
else
   fprintf('hdg file does not exist for %s\n',filebase)
end

if (exist(navfile, 'file'))
   load(navfile);
   dd.ggadday =    gps(j_time,:)';
   dd.lon =        gps(j_lon,:)';
   dd.lat =        gps(j_lat,:)';
   dd.j_hdop =     gps(j_hdop,:)';
   dd.nsat =       gps(j_nsat,:)';
else
   fprintf('nav file does not exist for %s\n',filebase)
end
   

%bad spots in navigation from GPS dropouts
%  ??? what to do with navigation dropouts?
%for the moment these times are really close because the 
% software (ue4) is forcing
%the PC which is writing to have nearly the same time as GPS.

   
%   if (length(gps(1,:)) ~= length(hdg(:,1)))
%      warning(sprintf('---> file %s has mismatched hdg  and gga\n', filebase))
%      size(hdg)
%      size(gps)
%      gpsdday = gps(j_time,:);
%      lnxdday =    hdg(:,1)';
%      clg
%      plot(gpsdday,'.')
%      hold on
%      plot(lnxdday,'ro')
%      paused
%   end
%end
