%    LBLTIME - Function to display raw LBL travel times.
% 
%        lbltime( time, ping_time, channels, valid )
%
%    B. A. Moran, 20-May-1996

%    Copyright (C) 1996-1998
%    Massachussetts Institute of Technology
%    Sea Grant AUV Laboratory
%    $Id: lbltime.m,v 1.2 1998/05/15 15:01:41 bamoran Exp bamoran $	

function lbltime( time, ping, channels, valid )

global run_name;
				% count pings (pre/post Haro styles)
if finite(mean(ping))
    tp = find( ping > 0 );
else
    tp = find( ping >= 0 );
end

if exist( 'valid' ) ~= 4 | isempty( valid )
    plot( time(tp), zeros(size(tp)), 'mo' );
    title( ['LBL Navigation Raw Replies: ' run_name] );
else
    cla
    set( gca, 'Box', 'On' );
    title( ['LBL Replies with Validation: ' run_name] );
end

colors = ...
    [  .7 0   0;
      0    .5 0;
      0   0   1;
      0    .5  .5;
       .5 1   0];

num = size(channels, 2);
for ii = 1:num
    if exist( 'valid' ) ~= 1 | isempty( valid )
	jj = find( channels(:,ii) > 0.03 );
    else
	jj = find(~valid(:,ii));
	line( time(jj), channels(jj,ii), 'color', colors(ii,:), ...
	    'Marker', '*', 'LineStyle', 'none' );
	jj = find( valid(:,ii) & channels(:,ii) > 0.03 );
    end
    line( time(jj), channels(jj,ii), 'color', colors(ii,:), ...
	'Marker', 'diamond', 'LineStyle', 'none', 'LineWidth', 2 );
end

xlabel( 'elapsed time (s)' );
ylabel( 'travel time (s)' );

zoom on

