import numpy as np
import sympy as sp
from devito import *
10 - Step-by-step NMO correction
Devito is equally useful as a framework for other stencil computations in general; for example, computations where all array indices are affine functions of loop variables. The Devito compiler is also capable of generating arbitrarily nested, possibly irregular, loops. This key feature is needed to support many complex algorithms that are used in engineering and scientific practice, including applications from image processing, cellular automata, and machine-learning. This tutorial, a step-by-step NMO correction, is an example of it.
In reflection seismology, normal moveout (NMO) describes the effect that the distance between a seismic source and a receiver (the offset) has on the arrival time of a reflection in the form of an increase of time with offset. The relationship between arrival time and offset is hyperbolic.
Based on the field geometry information, each individual trace is assigned to the midpoint between the shot and receiver locations associated with that trace. Those traces with the same midpoint location are grouped together, making up a common midpoint gather (CMP).
Consider a reflection event on a CMP gather. The difference between the two-way time at a given offset and the two-way zero-offset time is called normal moveout (NMO). Reflection traveltimes must be corrected for NMO prior to summing the traces in the CMP gather along the offset axis. The normal moveout depends on velocity above the reflector, offset, two-way zero-offset time associated with the reflection event, dip of the reflector, the source-receiver azimuth with respect to the true-dip direction, and the degree of complexity of the near-surface and the medium above the reflector.
Seismic modelling with devito
Before the NMO corretion we will describe a setup of seismic modelling with Devito in a simple 2D case. We will create a physical model of our domain and define a multiple source and an according set of receivers to model for the forward model. But first, we initialize some basic utilities.
We will create a simple velocity model here by hand for demonstration purposes. This model essentially consists of three layers, each with a different velocity: 1.5km/s in the top layer, 2.5km/s in the middle layer and 4.5 km/s in the bottom layer.
#NBVAL_IGNORE_OUTPUT
from examples.seismic import Model, plot_velocity
= (301, 501) # Number of grid point (nx, ny, nz)
shape = (10., 10) # Grid spacing in m. The domain size is now 3km by 5km
spacing = (0., 0) # What is the location of the top left corner.
origin
# Define a velocity profile. The velocity is in km/s
= np.empty(shape, dtype=np.float32)
v 100] = 1.5
v[:,:100:350] = 2.5
v[:,350:] = 4.5
v[:,
# With the velocity and model size defined, we can create the seismic model that
# encapsulates these properties. We also define the size of the absorbing layer as 10 grid points
= Model(vp=v, origin=origin, shape=shape, spacing=spacing, space_order=4, nbl=40, bcs="damp")
model
plot_velocity(model)
Operator `initdamp` run in 0.05 s
Operator `padfunc` run in 0.01 s
Next we define the positioning and the wave signal of our source, as well as the location of our receivers. To generate the wavelet for our sources we require the discretized values of time that we are going to use to model a multiple “shot”, which depends on the grid spacing used in our model. We will use one source and eleven receivers. The source is located in the position (550, 20). The receivers start at (550, 20) with an even horizontal spacing of 100m at consistent depth.
from examples.seismic import TimeAxis
= 0. # Simulation starts a t=0
t0 = 2400. # Simulation last 2.4 second (2400 ms)
tn = model.critical_dt # Time step from model grid spacing
dt
= TimeAxis(start=t0, stop=tn, step=dt)
time_range
= 250 # Number of Receivers nrcv
#NBVAL_IGNORE_OUTPUT
from examples.seismic import RickerSource
= 0.010 # Source peak frequency is 10Hz (0.010 kHz)
f0 = RickerSource(name='src', grid=model.grid, f0=f0,
src =1, time_range=time_range)
npoint
# Define the wavefield with the size of the model and the time dimension
= TimeFunction(name="u", grid=model.grid, time_order=2, space_order=4)
u
# We can now write the PDE
= model.m * u.dt2 - u.laplace + model.damp * u.dt
pde = Eq(u.forward, solve(pde, u.forward))
stencil
0] = 400 # Source coordinates
src.coordinates.data[:, -1] = 20. # Depth is 20m src.coordinates.data[:,
#NBVAL_IGNORE_OUTPUT
from examples.seismic import Receiver
= Receiver(name='rec', grid=model.grid, npoint=nrcv, time_range=time_range)
rec 0] = np.linspace(src.coordinates.data[0, 0], model.domain_size[0], num=nrcv)
rec.coordinates.data[:,-1] = 20. # Depth is 20m
rec.coordinates.data[:,
# Finally we define the source injection and receiver read function to generate the corresponding code
= src.inject(field=u.forward, expr=src * dt**2 / model.m)
src_term
# Create interpolation expression for receivers
= rec.interpolate(expr=u.forward)
rec_term
= Operator([stencil] + src_term + rec_term, subs=model.spacing_map)
op =time_range.num-1, dt=model.critical_dt) op(time
Operator `Kernel` run in 0.85 s
PerformanceSummary([(PerfKey(name='section0', rank=None),
PerfEntry(time=0.7779790000000012, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[])),
(PerfKey(name='section1', rank=None),
PerfEntry(time=0.028586000000000156, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[])),
(PerfKey(name='section2', rank=None),
PerfEntry(time=0.03306400000000026, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[]))])
How we are modelling a horizontal layers, we will group this traces and made a NMO correction using this set traces.
= []
offset = []
data for i, coord in enumerate(rec.coordinates.data):
= (src.coordinates.data[0, 0] - coord[0])
off
offset.append(off) data.append(rec.data[:,i])
Auxiliary function for plotting traces:
#NBVAL_IGNORE_OUTPUT
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.axes_grid1 import make_axes_locatable
'font', size=16)
mpl.rc('figure', figsize=(8, 6))
mpl.rc(
def plot_traces(rec, xb, xe, t0, tn, colorbar=True):
= np.max(rec)/100
scale = [xb, xe, 1e-3*tn, t0]
extent = plt.imshow(rec, cmap=cm.gray, vmin=-scale, vmax=scale, extent=extent)
plot 'X position (km)')
plt.xlabel('Time (s)')
plt.ylabel(
# Create aligned colorbar on the right
if colorbar:
= plt.gca()
ax = make_axes_locatable(ax)
divider = divider.append_axes("right", size="5%", pad=0.05)
cax =cax)
plt.colorbar(plot, cax plt.show()
Common Midpoint Gather
At this point, we have a dataset composed of the receivers. “If our model wasn’t purely horizontal, we would have to sort these traces by common midpoints prior to NMO correction.”
#NBVAL_IGNORE_OUTPUT
0][0]/1000, rec.coordinates.data[nrcv-1][0]/1000, t0, tn) plot_traces(np.transpose(data), rec.coordinates.data[
NMO Correction
We can correct the measured traveltime of a reflected wave \(t\) at a given offset \(x\) to obtain the traveltime at normal incidence \(t_0\) by applying the following equation:
\[\begin{equation*} t = \sqrt{t_0^2 + \frac{x^2}{V_{nmo}^2}} \end{equation*}\]
in which \(V_{nmo}\) is the NMO velocity. This equation results from the Pythagorean theorem, and is only valid for horizontal reflectors. There are variants of this equation with different degrees of accuracy, but we’ll use this one for simplicity.
For the NMO Correction we use a grid of size samples x traces.
= time_range.num # Number of samples in each trace
ns = Grid(shape=(ns, nrcv)) # Construction of grid with samples X traces dimension grid
In this example we will use a constant velocity guide. The guide will be arranged in a SparseFunction with the number of points equal to number of samples in the traces.
= 1500
vnmo = SparseFunction(name='v', grid=grid, npoint=ns)
vguide = vnmo vguide.data[:]
The computed offset for each trace will be arraged in another SparseFunction with number of points equal to number of traces.
= SparseFunction(name='off', grid=grid, npoint=nrcv)
off = offset off.data[:]
The previous modelled traces will be arranged in a SparseFunction with the same dimensions as the grid.
= SparseFunction(name='amps', grid=grid, npoint=ns*nrcv, dimensions=grid.dimensions, shape=grid.shape)
amps = np.transpose(data) amps.data[:]
Now, we define SparseFunctions with the same dimensions as the grid, describing the NMO traveltime equation. The \(t_0\) SparseFunction isn’t offset dependent, so the number of points is equal to the number of samples.
= grid.dimensions
sample, trace
= SparseFunction(name='t0', grid=grid, npoint=ns, dimensions=[sample], shape=[grid.shape[0]])
t_0 = SparseFunction(name='tt', grid=grid, npoint=ns*nrcv, dimensions=grid.dimensions, shape=grid.shape)
tt = SparseFunction(name='snmo', grid=grid, npoint=ns*nrcv, dimensions=grid.dimensions, shape=grid.shape)
snmo = SparseFunction(name='s', grid=grid, dtype=np.intc, npoint=ns*nrcv, dimensions=grid.dimensions,
s =grid.shape) shape
The Equation relates traveltimes: the one we can measure (\(t_0\)) and the one we want to know (t). But the data in our CMP gather are actually a matrix of amplitudes measured as a function of time (\(t_0\)) and offset. Our NMO-corrected gather will also be a matrix of amplitudes as a function of time (t) and offset. So what we really have to do is transform one matrix of amplitudes into the other.
With Equations we describe the NMO traveltime equation, and use the Operator to compute the traveltime and the samples for each trace.
#NBVAL_IGNORE_OUTPUT
= model.critical_dt/1000 # Time discretization in ms
dtms = Eq(t_0, sample*dtms)
E1 = Eq(tt, sp.sqrt(t_0**2 + (off[trace]**2)/(vguide[sample]**2) ))
E2 = Eq(s, sp.floor(tt/dtms))
E3 = Operator([E1, E2, E3])
op1 op1()
Operator `Kernel` run in 0.01 s
PerformanceSummary([(PerfKey(name='section0', rank=None),
PerfEntry(time=0.001971, gflopss=0.0, gpointss=0.0, oi=0.0, ops=0, itershapes=[]))])
With the computed samples, we remove all that are out of the samples range, and shift the amplitude for the correct sample.
#NBVAL_IGNORE_OUTPUT
>= time_range.num] = 0
s.data[s.data = Eq(snmo, amps[s[sample, trace], trace])
E4
= Operator([E4])
op2
op2()
= snmo.data.sum(axis=1) # We can stack traces and create a ZO section!!!
stack
0][0]/1000, rec.coordinates.data[nrcv-1][0]/1000, t0, tn) plot_traces(snmo.data, rec.coordinates.data[
Operator `Kernel` run in 0.01 s
References:
https://library.seg.org/doi/full/10.1190/tle36020179.1
https://wiki.seg.org/wiki/Normal_moveout
https://en.wikipedia.org/wiki/Normal_moveout