function adi_array_rot(array_root,LOB,iiph,new_root);
%
% Call adi_array_rot(array_root,LOB,iiph,new_root);
% array_root		= array geometry file root of existing _array file.
%					  (Use adi_array_make to make such files from xyz data);
% LOB			= array LOB in degrees true (east of north) ([] to keep same);
% iiph			= array elements to extract ([] keep all);
% new_root		= New array geometry file root with suffix '_array');
%					  (default is [array_root_LOB_ddd]);
%
% Routines that work with array geometry files include:
% adi_array_make, adi_array_plot, adi_array_rot, adi_array_find, adi_array_geom;
%
if nargin<2, LOB=[]; end
if nargin<3, iiph=[]; end
if nargin<4, new_root=[]; end
if isempty(LOB) & isempty(iiph),
	disp('USER ERROR: LOB and iiph empty'); return
end
%
% Read in xyz positions of array:
%%[xyz,cavg,nph]=arr_geom([array_root,'_array']);
[xyz,cavg,nph,geom_file,iif]=adi_array_find(array_root);
if ~iif, return; end
if isempty(iiph), iiph=[1:nph]; end
if isempty(new_root),
	if ~isempty(LOB),
		new_root=[array_root,'_LOB_',int2str(LOB)], 
	end
	if length(iiph)<nph,
		new_root=[array_root,'_ph_',int2str(length(iiph))],
	end
	if isempty(LOB) & length(iiph)==nph,
		disp(['USER ERROR: no LOB change or number of ', ...
			'phone change - cannot think of default file name']);
		new_root=[array_root,'_new_'],
	end
end
%
if ~isempty(LOB),
	LOB_rad=LOB*pi/180;
	rot=[sin(LOB_rad) cos(LOB_rad); -cos(LOB_rad) sin(LOB_rad)];
	xyz=[xyz(iiph,1:2)*rot, xyz(iiph,3)];
else
	xyz=xyz(iiph,:);
end
%
adi_array_make(new_root,xyz,cavg);


%
% 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.
