function TLm=TLm_avg(TLm_in,iiavg,iisave);
%
% Call TLm=TLm_avg(TLm_in,iiavg,iisave);
%
% TLm_in		= Input measured TL structure;
% iiavg			= dimension(s) over which to average (2=receiver,3=time)
% iisave		= 1 to save TLm with suffix [TLm_in.out_root,'_avg'];
%
% Averages TLm_in.data over dimension iiavg and creates a new TLm;
%
if nargin<2, iiavg=2; end
if nargin<3, iisave=1; end
%
if ischar(TLm_in),
	str=['load ',TLm_in,'_TLm']; eval(str); TLm_in=TLm; clear TLm;
end
%
TLm=cube_avg(TLm_in,iiavg,[],[],[],[],[],0);
if any(iiavg==2),
	TLm.nrec=1; TLm.ii_phavg=1;
end
TLm.out_root=[TLm_in.out_root,'_avg'];
cmax=ceil(max(TLm.data(:))/5)*5;
clo=floor(min(TLm.data(:))/5)*5;
cmin=max(cmax-60,clo);
TLm.clim=[cmin,cmax];
if iisave,
	str=['save ',TLm.out_root,'_TLm TLm']; disp(str); eval(str);
end
%
% 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.
