function DIST=phase_map_plot(XS,krec);
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
if nargin<2, krec=1; end
%
f0=XS.f_bb_shift; fac=1500/(2*f0);
nrec=XS.dims(3);
data=squeeze(XS.data);
%figure; plot_cfill(0,krec,'o','r',5); text(0,krec,int2str(krec)); hold on;
dlast=0;
DIST=XS; DIST.ndim=2; DIST.dims=[nrec,1]; DIST.labels={'Receiver','Column'}; DIST.scales={XS.scales{3},[0]};
DIST.dlab='Relative Distance - m'; DIST.data=zeros(nrec,1);
DIST.data(krec,1)=0;
for jcol=1:nrec-1,
    data(krec,krec)=999;
    [dmin,phmin]=min(abs(data(:,krec))); disp([krec,dmin,phmin]);
    phval=dlast + data(phmin,krec); data(phmin,:)=999; data(krec,:)=999; data(krec,phmin)=999;
%    plot_cfill(fac*phval,phmin,'o','r',5); text(phval,phmin,int2str(phmin));
    DIST.data(phmin,1)=fac*phval;
    krec=phmin; dlast=phval;
end
DIST.ii_img=0; DIST.vdims=[1 2 3]; DIST.iiq=1; DIST.size=[8 2]; DIST.sym={'o'}; DIST.sty={'none'};
view5(DIST,[],0,1); hold on;
for jrec=1:DIST.dims(1),
    ht=text(DIST.data(jrec,1),jrec,[' ',int2str(jrec)]);
    set(ht,'FontName','Arial','FontWeight','Bold','FontSize',12);
end
%zoom on;
    
