function [GPS,Echo]= PP_Latency

%% Load GPS file 
GPS=Read_Cache
GPS.elevation=GPS.Z_RD;
%% Load echosounderfile
disp('---------reading Echo.txt')
Echo=read_Echo;

function [Echo] = read_Echo
%%% allocate matrices
Echo.time_UTC=zeros(1e6,1);  %% arbirary high number (equivalent to 27 h of 10 Hz data)
Echo.depth=zeros(1e6,1);
%%% readfile
Filename.Echo='Echo.txt';
fid = fopen(Filename.Echo);
tline = fgetl(fid); Surveydate=datenum(tline(11:21)); % write the survey date in matlab format e.g. 07/16/2009 => 733970 
for i=1:3;tline = fgetl(fid);end %(Get rid of header lines)

ei=0; % set counter
go = 1;

while go  
    tline = fgetl(fid);
    if length(tline) >= 20
        ei=ei+1;
     
        %%% read tline to structure
        %%% tline info: Time UTC [HHMMSS.decSS] ; depth [m]
        [Echo.time_UTC(ei) Echo.depth(ei)] = strread(tline, '%f %f ', 'delimiter', ' ');
     else    
        go = 0;
     end
      
end    
fclose(fid); 
%%%Recut allocated matrices to right length
Echo.time_UTC=Echo.time_UTC(1:ei,:); 
Echo.depth=Echo.depth(1:ei,:);
Echo.Surveydate(1:ei)=Surveydate;

Echo.GPSMatlabtime = datenum([datestr(Echo.Surveydate(:),'yyyymmdd ') num2str(Echo.time_UTC(:),'%010.3f')],'yyyymmdd HHMMSS.FFF'); %% Matlabtime

%%


