function image = rtm(xm,xs,xh,z,t,v,shot,wave,it0);

% function img = rtm(xm,xs,xh,z,t,v,shot,wave);

 ns=length(xs);
 nh=length(xh);
 image=zeros(length(z),length(xm));
 oxm=xm(1);dxm=xm(2)-xm(1);
 oxs=xs(1);dxs=xs(2)-xs(1);
 oxh=xh(1);dxh=xh(2)-xh(1);
 
 cpu1=cputime;
 us = sht_down_2t8x(xh,z,t,v,wave,it0);
 cpu2=cputime;
 disp(['CPU time shot_down:', num2str(cpu2-cpu1)]);
 
 cpu1=cputime;
for is=1:ns;
%    load(['s_',num2str(is)]);
    ixm=floor((2*((is-1)*dxs+oxs)-abs(oxh)-oxm)/dxm)+1
    
    ur = rec_down(xh,z,t,v,shot(:,:,is));
%    clear shot;
    img = imaging(us,ur);
    image(:,ixm:ixm+nh-1)=image(:,ixm-1:ixm+nh-2)+img;
    disp(['shot #  ', num2str(is),' from ',num2str(ns)]);
end;
cpu2=cputime;
disp(['time recv_down:', num2str(cpu2-cpu1)]);