%    O2_ALTP - Altitude plots
%
%    function o2_altp( time, depth_m, alt_m, pitch, roll, poffset, pos )
%
%    B. A. Moran

%    Copyright (C) 1995-1998, Massachussetts Institute of Technology
%    Sea Grant Autonomous Underwater Vehicles Laboratory
%    $Id: o2_altp.m,v 1.6 1998/09/24 04:41:56 bamoran Exp $	

function o2_altp( time, depth_m, alt_m, pitch, roll, poffset, pos )

global run_name;

if nargin < 6, poffset = 0; end
if ( nargin > 6 ), winpos( pos ); end

set( gcf, 'name', 'Odyssey II Altimeter' );

mask = find( alt_m > 0 & alt_m < 99 );
if exist( 'medfilt1' ) == 2 & ~isempty(mask)
    alt_c = medfilt1( alt_m(mask), 5 );
else
    alt_c = alt_m(mask);
end

if ( nargin < 5 )
    cr = 1;
else
    cr = cos(roll(mask));
end

if ( nargin < 4 )
    cp = 1;
else
    cp = cos(pitch(mask)+poffset);
end

alt_c = alt_c.*cr.*cp;

subplot( 2, 1, 1 )

plot( time, depth_m, 'm', time(mask), depth_m(mask) + alt_c, 'b' );
area( time(mask), depth_m(mask) + alt_c, 'facecolor', [0 .75 .5] );
set( gca, 'YDir', 'reverse' );
line( time, depth_m, 'color', [1 0.5 0], 'linewidth', 3 );
title( ['Measured Depth and Calculated Bottom: ' run_name] );
ylabel( 'depth (m)' );
zoom on

subplot( 2, 1, 2 )
plot( time, alt_m, 'ro' );
title( 'Raw Altimeter' );
xlabel( 'elapsed time (s)' );
ylabel( 'range (m)' );
zoom on
