function dnew=pwmoveout(d,x,dt,u)
% Applies plane wave moveout at slowness u to a set of data.
% Returns a new array with the data time shifted by the moveout 
% value.  Ragged edges will be retained from moveout shifts.  
% i.e. don't do anything fancy to taper edges created by moveout flowing
% outside the input data time gate.
%
% arguments:
%  data - data matrix assumed to be seismograms stored in columns
%  x - parallel array to data containing offset values for data column
%    members.  that is x(i) is taken to be the offset for seismic\
%    data in the column data(:,i). 
%  dt - sample interval of data in d
%  u - slowness of correction to be applied (sign matters)

dsize=size(d);
nt=dsize(1);
nx=dsize(2);
xsize=size(x);
if(xsize(1)~=dsize(2))
    'Columns in data array must equal rows in x'
    xsize(1)
    dsize(2)
    return
end
dnew=zeros(dsize);
for j=1:nx
    moveout=x(j)*u;
    imov=fix(moveout/dt);
    if(imov<=0)
        ncopy=nt+imov;
        i0=-imov+1;
        dnew(1:ncopy,j)=d(i0:nt,j);
    else
        ncopy=nt-imov;
        dnew(imov+1:nt,j)=d(1:ncopy,j);
    end
end  