function orca_kn_plot(KNR,KNI,cref,psize,cols,iilog)
%
% Call orca_kn_plot(KNR,KNI,cref,psize,cols)
% Plots modes in complex k-plane.
% KNR,KNR   = structures from hdfsd_read of ORCA .hdf file;
% cref	= reference sound speed for converting to cos(theta) (0=plot vs phase velocity);
% psize     = [width,height] of plot;
%
if nargin<6, iilog=1; end
[nfreq,nm_max,nparm]=size(KNR.data);
ncol=length(cols); jplot=0;
iil=0; if iilog, iil=2; end
% Set this parameter so that mode with zero attenuation does not take up entire
% vertical dynamic range of plot
kni_min=.001;       
for jparm=1:nparm,
	for jfreq=1:nfreq,
        f0=KNR.scales{1}(jfreq);
        iim=find(~isnan(KNR.data(jfreq,:,jparm))); nmode=length(iim);
        mode_nos=KNR.scales{2}(iim);
        knr=KNR.data(jfreq,iim,jparm); kni=KNI.data(jfreq,iim,jparm);   
% Normalize real and imaginary axes:
        if cref>0,
            kref=2*pi*f0/cref;
            knr_rat=knr/kref; xlab='cos \theta';
        elseif cref==0,
            knr_rat=2*pi*f0./knr; xlab='Phase Speed - m/s';
        end
        kni_db_km=max(kni_min,kni*8685.9);
% Plot:
        jplot=jplot + 1;
        jcol=mod(jplot-1,ncol) + 1;
        h=plot_cfill(knr_rat,kni_db_km,'o',cols(jcol),5,'none',1.5,iil);
        hold on;
	end
end
%
xlabel(xlab); 
ylabel('Attenuation - dB/km'); grid on;
title(['c_R_E_F = ',num2str(cref)]);
plot_size(gca,'in',psize(1),psize(2));
plot_set3(gca,-1.5,'Arial',14,1);
zoom on;
%
% 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.
