function DATA=hepssp2mat(ssp_root,ll_root,BATHY)
%
% OUTPUTS
% DATA			= Structure containing data, dimensions, scales, and labels;
% DATA.data		= Data matrix;
% DATA.dims		= Array containing data matrix dimensions;
% DATA.scales	= Cell array containing axis values;
% DATA.labels	= Cell array containing axis labels in (1:ndim) and data label in (ndim+1);
%
% DATA=hepssp2mat('HEP01_1_ALL_SVP_dat','HEP01_1_ALL_SVP_ll_dat',BATHY)
%
%
% 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.
[data,text] = xlsread([ll_root,'.xls']);
[nrow,ncol]=size(text),
%
lat=zeros(1,ncol-1); long=lat; ssp_no=cell(1,ncol-1);
for jcol=1:ncol-1,
    jc=jcol+1;
    tt=char(text(nrow,jc)); disp(tt);
    lat(jcol)=sscanf(tt(1:5),'%f');
    long(jcol)=sscanf(tt(9:15),'%f');
    ssp_no{jcol}=char(text(nrow-1,jc));
end
if ~isempty(findstr(tt,'S')), lat=-lat; end
if ~isempty(findstr(tt,'W')), long=-long; end
%
if isempty(BATHY),
    clear BATHY
    adi_global
	[bathy_file,path_name]=uigetfile('*_bathy.mat','Please Choose Bathymetry File');
	bathy_root=bathy_file(1:length(bathy_file)-10);
	bathy_open([path_name,bathy_root]);
end
hw=interp2(BATHY.lat,BATHY.long,BATHY.hw.',lat,long);
hw=floor(hw*2)/2;
hwmax=max(hw);
%
[ssp,text] = xlsread([ssp_root,'.xls']);
[nrow,ncol]=size(ssp); nssp=ncol-1;
%
z_out=unique([0:2:50,55:5:100,110:10:200,225:25:500,600:100:hwmax,round(hw(:))']);
ii=find(z_out<=hwmax); z_out=z_out(ii), nz_out=length(z_out);
data=NaN*ones(nz_out,nssp); nz=zeros(1,nssp); svp_bad=zeros(1,nssp);
for j=1:nssp,
    data(:,j)=interp1(ssp(:,1),ssp(:,j+1),z_out(:),'linear','extrap');
    ii=find(z_out>hw(j)); data(ii,j)=NaN;
    if isempty(ii), nz(j)=nz_out; else, nz(j)=ii(1)-1; end
    ii=find(data(:,j)<1460 | data(:,j)>1570); data(ii,j)=NaN;
    iibad=find(isnan(data(1:nz(j),j))); nbad=length(iibad);
    if nbad>0, svp_bad(j)=1; end
end
%
iiok=find(~svp_bad), nok=length(iiok),
DATA.ndim=2;
DATA.labels={'Depth - m','SSP Number'};
DATA.scales={z_out, [1:nok]};
DATA.dims=[nz_out, nok];
DATA.data=data(:,iiok); DATA.dlab='Sound Speed - m/s';
DATA.hw=hw(iiok);
DATA.nz=nz(iiok); DATA.ssp_no=ssp_no(iiok);
DATA.lat=lat(iiok); DATA.long=long(iiok);
DATA.title=ssp_root;
DATA.clim=[min(DATA.data(:)),max(DATA.data(:))];
%
str=['save ',ssp_root,' DATA']; disp(str); eval(str);
%view5(DATA);
