% preparedata script

% DO THE PRELIMINARY DATA CRUNCHING
XYDATA.x = unwrap_lon(XYDATA.xyt(1,:)');    %Nx1 vectors
XYDATA.y = XYDATA.xyt(2,:)';                      %Nx1 vectors
XYDATA.dday = XYDATA.xyt(3,:)';                 %Nx1 vectors
UVDATA.u = UVDATA.uv(:,1:2:end);                %ndepths x Nvelocities
UVDATA.v = UVDATA.uv(:,2:2:end);                %ndepths x Nvelocities

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

% have full data set ready 
XYDATA.X = XYDATA.x;
XYDATA.Y = XYDATA.y;
XYDATA.DDAY = XYDATA.dday;
XYDATA.Z = XYDATA.z;
XYDATA.ZC = XYDATA.zc;
UVDATA.U = UVDATA.u;
UVDATA.V = UVDATA.v;