vel=np.fromfile("data/marm16km.drt",dtype=np.float32)

print(vel)

nx=576
nz=188
h=0.016
vel.shape=(nx,nz)

plot_vel(vel,h)

times=np.empty((nx,nx,nz),dtype=float32)

for isrc in range(nx):
    if isrc %50 ==0:
        print(isrc,nx)
    times[isrc]=traveltime(vel,h,isrc,0)
#times.tofile("ttime_marm_org.bin")
#times=np.fromfile("ttime_marm_org.bin",dtype=float32)
#times.shape=(nx,nx,nz)

image=kirchhoff(sd,h,times,0.1)

dimg=zdiff2(image)
dimg.min(),dimg.max()

plot_mig(perc_clip(dimg,97),h)

"""
Explanation: Kirchhoff prestack depth migration using the true velocity model
End of explanation
"""


svel=moving_average2d(vel,10,10)
plot_vel(svel,h)

stimes=np.empty((nx,nx,nz),dtype=float32)
for isrc in range(nx):
    if isrc %50 ==0:
        print(isrc,nx)
    stimes[isrc]=traveltime(svel,h,isrc,0)
#stimes.tofile("ttime_marm_sm10.bin")
#stimes=np.fromfile("ttime_marm_sm10.bin",dtype=np.float32)
#stimes.shape=(nx,nx,nz)

simage=kirchhoff(sd,h,stimes,0.1)

dsimg=zdiff2(simage)
dsimg.min(),dsimg.max()

plot_mig(perc_clip(dsimg,97),h)

"""
Explanation: Kirchhoff prestack depth migration using a smooth velocity model
End of explanation
"""


