function DATA=data_set_depth(DATA,REC);
%
% Call DATA=data_set_depth(DATA,REC);
%
% Sets DATA.scales2 and DATA.labels2 for depth dimension according to array element depths
% in REC.dzr and reference depth in REC.txyvp(1,6).
%
%
% 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.
if ~isfield(DATA,'scales2'), DATA.scales2=DATA.scales; DATA.labels2=DATA.labels; end
%
% Find DATA dimension containing depth:
jdim_depth=0;
for jdim=1:DATA.ndim
    if ~isempty(findstr(DATA.labels{jdim},'eceiver')),
        jdim_depth=jdim; break;
    end
end
if jdim_depth==0, error('Could not find "Receiver" in DATA.scales{:}'); return; end
%
nrec_data=DATA.dims(jdim_depth); iiok=[1:REC.nzr];
if nrec_data~=REC.nzr,
    disp(['nrec from DATA ~= nrec from REC array: ',int2str([nrec_data,REC.nzr]), ...
            ';  Choose receiver array or depths to match DATA.']);
    iiok=str2num(input('Enter phone numbers to fill, e.g. "1:20" (<CR> for 1:nrec_data): ','s'));
    if isempty(iiok), iiok=[1:nrec_data]; end
    if nrec_data~=length(iiok), error('nrec from DATA not equal to number of phones entered'); end
end
DATA.scales2{jdim_depth}=REC.txyvp(1,6) + REC.dzr(iiok)';
DATA.labels2{jdim_depth}='Depth - m';
DATA.rec_array=REC.geom_file;

