function data = load_adcp(prefix, matpath)
% data = load_adcp(prefix, matpath)
% data is a structure with fields
% dday, x, y
% u,v
% z    
% prefix is  to get to prefix_xy.mat, prefix_uv.mat
% path is assumed to be './' unless specified

if (nargin == 1)
   matpath = '.';
end

uv = [];
dday = [];
x = [];
y = [];


xyfile = sprintf('%s_xy.mat',  fullfile(matpath, prefix));
uvfile = sprintf('%s_uv.mat',  fullfile(matpath, prefix));
if (exist(xyfile))
   load(xyfile);
   load(uvfile);
else
   fprintf('FAILURE: could not find file %s\n', xyfile)
   return
end




% parse the data -----------------------------------------------

u = uv(:,1:2:end);
v = uv(:,2:2:end);
dday = xyt(3,:);
x = xyt(1,:);
y = xyt(2,:);
x = unwrap_lon(x);


badi = find(isnan(dday));
dday(badi) = [];
x(badi) = [];
y(badi) = [];
u(:, badi) = [];
v(:, badi) = [];

data.x = x;
data.y = y;
data.dday = dday;
data.u = u;
data.v = v;
data.z = z;
data.zc = zc;



