function [migi]=migrate0(cdp1,nx,nz,ntime,dt,ap,dx,dz,c,TOTS,TOTE)
migi=zeros(nx,TOTE-TOTS+1);

for ixtrace=1:nx;
    %ixtrace
    istart=1 + (ixtrace-1)-ap;iend=1+ (ixtrace-1)+ap;
    if istart<1;istart=1;end;
    if iend>nx;iend=nx;end;
    for ixs=istart:iend;
        for t0=TOTS:TOTE;
            r = c(ixtrace,t0-TOTS+1)*t0;
            time = 2*round(1+sqrt((t0/2)^2 + ((ixtrace*dx-ixs*dx)/c(ixtrace,t0-TOTS+1)/dt)^2)); %two-way time
            if time <= ntime
                %obl=izs*dz/r;
                migi(ixs,t0-TOTS+1) = migi(ixs,t0-TOTS+1) + cdp1(ixtrace,time)/r;
                %migi(ixs,izs-TOZS+1) = migi(ixs,izs-TOZS+1) + obl*cdp1(ixtrace,time)/r^2;
            end
        end;
    end;
end;
