function bb = o2_xpndr( arg, decade )

%  O2_XPNDR    Odyssey II LBL transponder database and plotting.
%
%    XPNDRS = O2_XPNDR( TIME ) returns a 4x4 matrix of transponder
%    data that describes the deployment at TIME (seconds since
%    midnight, 1 Jan 1970 GMT).  Each row describes a different
%    transponder in the format: [north east depth turnaround_time].
%
%    When called with no output arguments, the transponder network is
%    added to the current plot.  The 4 channels are shown respectively
%    as red, green, blue, and yellow.
%
%    O2_XPNDR( OPNAME ) works as above, with OPNAME specified as
%    'swb95', 'bbmay96', 'haro96_1', 'haro96_2', or 'ccbay96'.
%    O2_XPNDR( XPNDRS ) provides direct access to the graphics, given
%    user provided data in the above format.
%
%    Examples:
%        o2_xpndr( o2_time0('96/06/28 22:04:52') );
%
%        haro_beacons = o2_xpndr( 'haro96_1' );
%        o2_xpndr( haro_beacons );
%
%    B. A. Moran, 07-Aug-96

%    Copyright (C) 1996-1998
%    Massachussetts Institute of Technology
%    Sea Grant AUV Laboratory
%    $Id: o2_xpndr.m,v 1.1 2000/01/10 19:08:23 rob Exp $	


if nargin < 1, error( 'usage: o2_xpndr(opname)' ); end
if nargin < 2, decade = 0; end

global TRData

if exist( 'TRData' ) ~= 1 | isempty( TRData )
    disp( 'loading TRData from TRData.dat...' )
    load 'TRData.dat';
    if exist( 'trdata' ) == 1
	TRData = trdata;
	clear trdata;
    end
end

if isstr( arg ) == 1
    opname = arg;
    if strcmp( opname, 'swb95' )
        time = 814028123;
    elseif strcmp( opname, 'bbmay96' )
        time = 832377600;
    elseif strcmp( opname, 'haro96_1' )
        time = 835824888;
    elseif strcmp( opname, 'haro96_2' )
        time = 836343000;
    elseif strcmp( opname, 'ccbay96' )
	time = 847818000;
    else 
       error( ['unknown opname: ' opname] );
    end
elseif prod(size(arg)) == 1
    time = arg;
else
    b = arg;
end

if exist( 'b' ) ~= 1
    tr_row = max(find( TRData(:,1) <= time ));
    if ~isempty( tr_row )
        b = reshape( TRData(tr_row,2:17), 4, 4 )';
    end
end

if nargout < 1

    b(:,1:2) = b(:,1:2)*10.^(-decade);
    line( [b(:,2); b(1,2)], [b(:,1); b(1,1)], ...
        'color', 'k', 'linestyle', '-.' );
    line( [b(1,2); b(3,2)], [b(1,1); b(3,1)], ...
        'color', 'k', 'linestyle', '-.' );
    line( [b(2,2); b(4,2)], [b(2,1); b(4,1)], ...
        'color', 'k', 'linestyle', '-.' );

    colors = get(gca,'colororder');
    for ii = 1:size(b,1)
        line( b(ii,2), b(ii,1), 'Marker', 's', 'LineWidth', 1, ...
	    'color', colors(ii,:) ); 
    end
else
    bb = b;
end
