function ray_plot_new(pic_file,ii_src_on_left,rcol,lines)
% Call ray_plot_new('pic_file',ii_src_on_left,rcol,lines);
% pic_file is the GAMARAY _pic file name,
% set ii_src_on_left=1 to make the source appear on the left side.
% set rcol = 'r' for red rays, ' ' for different colors.
%
% 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.
load(pic_file);
eval(['pic_array=',pic_file,';']);
if rcol==' ',
	colors=['y','m','c','r','g','b'];
else
	colors=[rcol,rcol,rcol,rcol,rcol,rcol];
end
figure
rmax=pic_array(3,1); zmax=pic_array(2,2);
[nrow,ncol]=size(pic_array),
grid;
hold on
ii=[find(pic_array(:,3)==0); nrow+1];
ii1=ii(1:length(ii)-1); ii2=ii(2:length(ii))-1;
npts=ii2-ii1+1; nptmax=max(npts);
iirays=find(npts>5); nray=length(iirays), iilines=find(npts<=5);
rz_mat=NaN*ones(nptmax,2*nray);
% Draw box and depth lines:
for j=1:length(iilines),
   nl=iilines(j); ii1x=ii1(nl); ii2x=ii2(nl);
   plot(pic_array(ii1x:ii2x,1),pic_array(ii1x:ii2x,2),'w-')
end
% Draw rays:
for j=1:length(iirays),
   nl=iirays(j); ii1x=ii1(nl); ii2x=ii2(nl);
   col=colors(rem(j-1,6)+1);
   if nargin > 3, line=lines(j,:); else, line='-'; end;
   type=[col,line],
   if ii_src_on_left == 1, 
      pic_array(ii1x:ii2x,1)=pic_array(ii2x,1) - pic_array(ii1x:ii2x,1); 
   end
   plot(pic_array(ii1x:ii2x,1),pic_array(ii1x:ii2x,2),type)
   rz_mat(1:npts(nl),2*j-1:2*j)=pic_array(ii1x:ii2x,1:2);
end

hold off
axis('ij'); axis([0,rmax,0,zmax]);
xlabel('Range  Ð km'); ylabel('Depth  Ð m'); title(pic_file);
string=['save ',pic_file,'.asc rz_mat -ascii'],
eval(string);
