%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PURPOSE: Load DorOdyssey Simulation Results into Matlab and synchronize
%          start times.
% AUTHOR:  Rob McEwen
% DATE:    99/12/20
% NOTES:   See the companion shell script cvt
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
  clear dataSim dataNav dataDC opts;
%
% Get dataNav
%
  if ( exist('dataN')   == 2 )
    disp ' Loading Navigation Data. ', 
    dataN 
  else
    disp ' Navigation Data Not Present.'
    return
  end
%
% Get dataDC
%
  if ( exist('dataD')   == 2 )
    disp ' Loading Dynamic Control Data. ', 
    dataD 
  else
    disp ' Dynamic Control Data Not Present.'
    return
  end
%
% Find latest start time.
%
  startTime = 0;
  if dataNav(1,1) > startTime; startTime = dataNav(1,1);end
  if dataDC(1,1)  > startTime; startTime = dataDC(1,1);end
%
% Reset time in dataNav and dataDC
%
  dataNav(:,1) = dataNav(:,1) - startTime;
  dataDC(:,1)  = dataDC(:,1)  - startTime;
%
% Get and synchronize dataS.
%
  if ( exist('dataS') == 2 ) 
    disp ' Loading Simulation Data ' 
    dataS
    %dataSim(:,1) = dataSim(:,1) - startTime;
  end
%
% Get and synchronize ctdlog
%
  if ( exist('dataCTD') == 2 ) 
    disp ' Loading CTD data ' 
    dataCTD
    ctdlog(:,1) = ctdlog(:,1) - startTime;
  end
%
% Get and synchronize parosci
%
  if ( exist('dataPS') == 2 ) 
    disp ' Loading PS data ' 
    dataPS
    parosci(:,1) = parosci(:,1) - startTime;
  end



%
% Get and synchronize psa916log
%
  if ( exist('dataPSA') == 2 ) 
    disp ' Loading PSA data ' 
    dataPSA
    psa916log(:,1) = psa916log(:,1) - startTime;
  end
%
% Get and synchronize kvhInclin
%
  if ( exist('dataINC') == 2 ) 
    disp ' Loading INC data ' 
    dataINC
    kvhInclin(:,1) = kvhInclin(:,1) - startTime;
  end
%
% Get and synchronize kvhCompass
%
  if ( exist('dataCOM') == 2 ) 
    disp ' Loading COM data ' 
    dataCOM
    kvhCompass(:,1) = kvhCompass(:,1) - startTime;
  end
%
% Get and synchronize Crossbow
%
  if ( exist('dataCrossB') == 2 ) 
    disp ' Loading Crossbow data ' 
    dataCrossB
    dataCB(:,1) = dataCB(:,1) - startTime;
  end
%
% Get and synchronize gps
%
  if ( exist('dataGPS') == 2 ) 
    disp ' Loading GPS data ' 
    dataGPS
    gps(:,1) = gps(:,1) - startTime;
  end


return



if ( exist('dataPS')  == 2 ), disp ' Loading ParoSci Data. ', dataPS, end
if ( exist('dataPSA') == 2 ), disp ' Loading PSA916 Data. ', dataPSA, end
if ( exist('dataGPS') == 2 ), disp ' Loading GPS Data. ', dataINC, end
if ( exist('dataINC') == 2 ), disp ' Loading KVH Inclo Data. ', dataINC, end
if ( exist('dataCOM') == 2 ), disp ' Loading KVH Compass Data. ', dataCOM, end




