function Tsp=tspread(PULSE)
%
%
% 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.
loaded_fields=fieldnames(PULSE);
for j=1:length(loaded_fields),
	if ~(strcmp(loaded_fields{j},{'data'})),
		expr=['Tsp.',loaded_fields{j},'=PULSE.',loaded_fields{j},';']; eval(expr);
    else,
        Tsp.data=[];
	end
end
Tsp.dlab='Time Spread - s';
Tsp.dims(3)=1;
Tsp.scales{3}=0;
Tsp.labels{3}='Delay Time - s';
pp=10.^(PULSE.data/20);
num_integral=sum(pp,3); den_integral=sum(pp.^2,3); delt=diff(PULSE.scales{3}(1:2)),
Tsp.data=delt*(num_integral.^2)./den_integral;
Ts_max=ceil(max(Tsp.data(:))/.1)*.1; Ts_min=floor(min(Tsp.data(:))/.1)*.1;
Tsp.clim=[Ts_min,Ts_max];
