Algorithmadvanced
Parabolic Radon transform
Also called Hampson multiple attenuation.
Decompose a moveout-corrected gather into parabolic events by damped least squares, one frequency at a time, then keep the flat primaries and subtract the curved multiples.
- Time
- O(n (m k^2 + k^3) + n^2 (m + k)) worst · average · best
- Space
- O(n (m + k) + m k + k^2) extra
- Where
- k = the number of curvatures; m = the number of traces; n = the number of time samples
- Model
- Real RAM
- Properties
- deterministicleast squareslinear in dataprimaries plus multiples equal data
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Dan Hampson, 1986
The parabolic Radon transform removes multiples from a common-midpoint gather by their moveout. After normal moveout correction with the velocity of the primaries, a primary is flat, and a multiple, which travels slower, still curves down, close to a parabola . The method writes the gather as a sum of parabolic events, one model trace for each curvature , and finds the model by damped least squares. The model traces with large are the multiples: the method maps them back to the gather and subtracts them. Because a parabola is a time shift that does not depend on , the least-squares problem splits into one small system per frequency. It is a seismic relative of the Radon transform of tomography, which integrates an image along straight lines; here the curves are parabolas in time and offset, and the transform is inverted by least squares, not by a filtered back projection.
In plain words
After the usual correction for distance, the echoes that went straight down and up line up flat across the record. Echoes that bounced several times arrive with a bend that remains. The method tries to explain the whole record as a sum of simple curved shapes, from flat to strongly bent. It picks the strength of every shape so that the sum matches the record as closely as possible, with a small penalty that keeps the strengths modest. Then it keeps only the strongly bent shapes, rebuilds the record they make, and subtracts it. What is left is the flat part, the echoes we want. The work is done one frequency at a time, which makes each piece small and fast.
The problem
Input: a gather with offsets , already corrected for normal moveout with the primary velocity; curvatures ; a damping ; a cut . Output: the model , the predicted multiples and the primaries. The forward operator is
and the model minimizes , a Tikhonov problem. Why parabolas: a multiple with rms velocity and zero-offset time arrives at . NMO with the primary velocity moves it to , whose Taylor expansion in starts with , . The parabola is an approximation (a theorem for small offsets, a heuristic at far offsets, where it can be off by a large part of a period). Its gain is that a parabola is a shift by for every , so the DFT turns the forward operator into the matrices , one per frequency. A hyperbola shifts different by different amounts, and its operator does not split this way.
The algorithm
PARABOLIC-RADON-DEMULTIPLE(d, x, q, Δt, μ, q_cut)- 1
D_i ← DFT(d_i) for every trace - 2
for each frequency ω do - 3
L_ij ← exp(-i ω q_j x_i²) - 4
M(ω) ← solution of (Lᴴ L + μ I) M = Lᴴ D(ω) - 5
K_j ← M_j(ω) if q_j > q_cut, else 0 - 6
N(ω) ← L K ▷ predicted multiples - 7
m ← inverse DFT of M; multiples ← inverse DFT of N - 8
return (m, d - multiples, multiples)
The adjoint alone, without the solve, is the plain parabolic stack: the sum of the data along each parabola. It smears each event over many curvatures, because the parabolas through one event all collect some of its energy. The least-squares solve of line L4 focuses the model, so that the multiples can be cut from the primaries in . The damping keeps the system solvable at low frequencies, where the columns of are nearly equal (at they are all equal), and controls the amplification of noise.
Example
The parabolic approximation. A primary with m/s and a multiple with m/s at s. At m the exact residual moveout after NMO is s. The parabola has s/m² and predicts s, 14 ms too much. This error is a fixed property of the approximation; the method accepts it, or it uses a grid wide enough to absorb it.
Separating a multiple. A gather of 16 traces at offsets 0 to 1500 m, 63 samples at ms, a 20 Hz Ricker wavelet. The primary is flat at s. The multiple has amplitude at s and s/m², so its moveout at 1500 m is 0.09 s, about two periods of the wavelet. The data are made with the forward operator itself, on the grid of 14 curvatures from to in steps of s/m². With :
| damping | 0.01 | 0.1 | 1 |
|---|---|---|---|
| relative error of the primaries | 0.113 | 0.124 | 0.145 |
Before the removal, the gather differs from the true primaries by a relative error of 0.700. With , 65 percent of the model energy is at the three curvatures nearest the primary and 27 percent at the three nearest the multiple; for the plain stack the shares are 42 and 22 percent, the rest smeared over the other curvatures. The model is not the true model (its relative error is 0.75): one step in moves the far trace by only 11 ms, about a fifth of the 50 ms period, so neighboring curvatures are not resolved and the energy spreads over them. These numbers are measurements on this synthetic gather.
Correctness
For odd on a periodic time axis, the forward operator is a sum of exact band-limited shifts, its adjoint is the frequency-wise , and the frequency-wise solve of line L4 gives the unique minimizer of over real models, the same model as the dense time-domain normal equations. The predicted multiples are applied to the model traces above the cut, and the returned primaries and multiples add up to the data exactly; the misfit stays with the primaries. At zero frequency every model trace gets the same mean, whatever the data. These are theorems, proved in proofs/correctness.md. That the cut in separates primaries from multiples is a heuristic: it needs the residual moveouts to be parabolic enough and to differ by more than about a period at the far offset.
Proof: The frequency-domain solve returns the unique damped least-squares parabolic Radon model of the gather, the forward and adjoint operators are a pair, and the multiple prediction and the primaries add up to the datafull
Setting. A gather has real traces at offsets , each with samples at times , , and is odd. A model has real traces for the curvatures . The DFT is and the inverse has the factor . For a bin let be the signed index, if and otherwise, and . Because is odd, there is no bin with , and for every . Line L3 forms the matrix . The forward operator maps a model to the gather with spectra , where ; the function adjoint maps a gather to the model with spectra . A family of vectors is conjugate symmetric if for all and is real; the spectra of real signals are exactly the conjugate symmetric families. The inner product of real gathers or models is over all traces and samples.
Claim 1 (the forward operator is a sum of shifts). For a real model, is real. If for an integer , the contribution of to trace is shifted by samples, circularly. In general it is the periodic trigonometric interpolant of evaluated at the times .
Proof. Since and is real, . If is conjugate symmetric, so is , and its inverse DFT is real. For an integer shift, because , and multiplying the DFT by shifts the signal circularly by samples (the shift theorem of the DFT). For a general delay , the trigonometric polynomial with the signed frequencies takes the value at , and .
Claim 2 (adjoint). For a real model and a real gather , , where is the output of the function adjoint, which is real.
Proof. For real signals, Parseval's identity for this DFT is . So . The family is conjugate symmetric, by and the symmetry of , so it is the spectrum of a real model, and the last sum is by Parseval again.
Claim 3 (the solve). Let . Lines L1 to L4 and L7 return the unique real model that minimizes
over all real models. It is the solution of in the time domain.
Proof. By Parseval, , and the term of bin depends only on . Each term is a strictly convex quadratic function of the complex vector , because is Hermitian positive definite, and its unique minimizer is , which is line L4. Taking the complex conjugate of this equation and using and shows , and is real since and are real. So is the spectrum of a real model , which line L7 returns. The family minimizes every term over all complex vectors, so minimizes over the smaller set of real models; any other real model differs in some bin and has a strictly larger term there. The gradient of at is by Claim 2, and it is zero.
Claim 4 (the split). Let keep the model traces with and set the others to zero. Lines L5, L6 and L8 return the multiples and the primaries . So the primaries and the multiples add up to exactly, and the primaries are : the modeled events with plus the part of the data that the model does not fit.
Proof. Line L5 forms the spectra of , bin by bin, and line L6 multiplies them by , which is the spectrum of . The rest is linearity of .
So the misfit , which holds the noise and any event that is not a parabola in the range of , stays with the primaries. This is a design choice of the method: it removes only what it can model as a multiple.
Claim 5 (zero frequency). At all columns of are the vector of ones, and with . So every model trace has the same mean, whatever the data, and the zero-frequency part of the data is split between primaries and multiples in the ratio of the numbers of curvatures at most and above .
Proof. and . The vector solves when , and the solution is unique by Claim 3.
More generally, columns and of differ by the phases . When is small, the two columns are nearly parallel, the normal matrix is badly conditioned, and the damping decides the split. So the method cannot be expected to separate events whose moveouts at the far offset differ by much less than one period of the dominant frequency. This is a heuristic resolution limit, not a theorem.
Claim 6 (cost). With samples, traces and curvatures, the solve costs plus the transforms: forward DFTs and inverse DFTs. The direct DFT used for odd costs per trace; an FFT costs .
Proof. For each of the bins, line L3 costs , the normal matrix , the right-hand side , the dense solve , and line L6 . When the are equally spaced, depends only on , so the matrix is Hermitian Toeplitz and a Levinson-type solver costs in place of .
Complexity
In the real-RAM model each frequency costs for the normal matrix and for the solve, so the solves cost . The code uses a direct DFT for odd , per trace; with an FFT the transforms cost . With equally spaced curvatures the normal matrix is Hermitian Toeplitz, and a Levinson-type solver costs per frequency. Space is for the spectra plus for one frequency.
Properties
- Linear in the data for fixed grid, and (a theorem).
- Primaries plus predicted multiples equal the data (a theorem), so nothing is lost: what the model does not explain stays in the primaries.
- Resolution in grows with the frequency and with the square of the largest offset; events whose far-offset moveouts differ by much less than a period are not separated (a heuristic).
- Time-invariant: one system per frequency serves all times, so the cost does not grow with the number of events.
- Works on gathers with irregular offsets, since the enter only through the matrix entries.
Variants and improvements
- High-resolution or sparse Radon transforms: replace the penalty by a sparsity penalty and solve by reweighted least squares, so that each event focuses at one curvature (sparse signal recovery).
- Time-domain hyperbolic Radon transforms, as in Thorson and Claerbout (1985): exact hyperbolas, at the cost of a large coupled system solved by iterative methods.
- Linear Radon transform (slant stack) for events that are straight lines in the gather, such as ground roll and refractions.
- Apex-shifted parabolas for diffracted multiples.
- Subtract the multiples with an adaptive filter in place of the plain subtraction of line L8.
When to use it
Use it in processing before stacking, on gathers where multiples and primaries differ clearly in stacking velocity, usually at medium and far offsets and at later times. It is a standard step for marine data, often after surface-related multiple elimination has removed most of the surface multiples. It does not need a model of the surface or the source, only the moveout difference.
Pitfalls
- At near offsets the moveout difference is small, so multiples there are not removed; this is a basic limit of the method.
- A grid that is too narrow cannot hold the multiples, and a grid too coarse misses their curvatures.
- The cut must lie between the residual moveouts of primaries and multiples; a primary with a wrong NMO velocity curves and can be cut with the multiples.
- Too little damping amplifies noise at low frequencies; too much damping smears the model and lets energy leak across the cut.
- Aliasing in offset: if changes by more than between neighboring traces at the highest frequency, the transform maps energy to wrong curvatures.
- On a periodic time axis an event near the end of the record wraps to the start; pad the traces with zeros.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Shared helper of the imaging and inverse problems pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Small images and signals for the imaging and inverse problems pages.
Conventions:
- A signal is a list of numbers. An image is a list of rows, img[i][j], with
row i from the top and column j from the left.
- An n x n image covers the square [-1, 1]^2. The center of pixel (i, j) is
x_j = -1 + (2 j + 1) / n and y_i = 1 - (2 i + 1) / n, so y goes up.
- DFT: X_k = sum_j x_j exp(-2 pi i j k / n), unnormalized; the inverse has
the factor 1 / n. Index k stands for frequency k for k < n / 2 and k - n
otherwise. fftshift moves the zero frequency to position n // 2.
- Periodic convolution kernels are stored with their center at index 0
(wrapped around), so a delta kernel gives the identity and no shift.
"""
import cmath
import math
# ------------------------------------------------------------------ images
def new_image(n1, n2, value=0.0):
"""An n1 x n2 image (n1 rows, n2 columns) filled with value."""
return [[value] * n2 for _ in range(n1)]
def img_add(a, b):
"""The pixelwise sum a + b."""
return [[x + y for x, y in zip(ra, rb)] for ra, rb in zip(a, b)]
def img_scale(a, c):
"""The image c a."""
return [[c * x for x in row] for row in a]
def img_dot(a, b):
"""<a, b> = sum conj(a_ij) b_ij."""
return sum(x.conjugate() * y for ra, rb in zip(a, b) for x, y in zip(ra, rb))
def img_norm(a):
"""The Euclidean (Frobenius) norm of an image."""
return math.sqrt(sum(abs(x) ** 2 for row in a for x in row))
def flatten(img):
"""Row-major vector of an image."""
return [x for row in img for x in row]
def unflatten(v, n1, n2):
"""The n1 x n2 image of a row-major vector."""
return [list(v[i * n2:(i + 1) * n2]) for i in range(n1)]
# ------------------------------------------------------------------ DFT
def _is_pow2(n):
return n > 0 and n & (n - 1) == 0
def _fft_pow2(x):
"""Iterative radix-2 FFT, unnormalized forward transform."""
n = len(x)
a = [complex(v) for v in x]
j = 0
for i in range(1, n):
bit = n >> 1
while j & bit:
j ^= bit
bit >>= 1
j |= bit
if i < j:
a[i], a[j] = a[j], a[i]
size = 2
while size <= n:
half = size // 2
tw = [cmath.exp(-2j * math.pi * k / size) for k in range(half)]
for start in range(0, n, size):
for k in range(half):
u = a[start + k]
v = a[start + k + half] * tw[k]
a[start + k] = u + v
a[start + k + half] = u - v
size *= 2
return a
def dft(x):
"""X_k = sum_j x_j exp(-2 pi i j k / n). Radix-2 FFT when n is a power of 2."""
n = len(x)
if n == 0:
return []
if _is_pow2(n):
return _fft_pow2(x)
w = [cmath.exp(-2j * math.pi * t / n) for t in range(n)]
return [sum(x[j] * w[(j * k) % n] for j in range(n)) for k in range(n)]
def idft(xf):
"""x_j = (1/n) sum_k X_k exp(2 pi i j k / n)."""
n = len(xf)
if n == 0:
return []
y = dft([complex(v).conjugate() for v in xf])
return [v.conjugate() / n for v in y]
def _rows_then_cols(img, f):
rows = [f(row) for row in img]
cols = [f(list(col)) for col in zip(*rows)]
return [list(r) for r in zip(*cols)]
def dft2(img):
"""2D DFT: X_kl = sum_jq x_jq exp(-2 pi i (j k / n1 + q l / n2))."""
return _rows_then_cols(img, dft)
def idft2(img):
"""Inverse 2D DFT, with the factor 1 / (n1 n2)."""
return _rows_then_cols(img, idft)
def _shift1(x, s):
return list(x[s:]) + list(x[:s])
def fftshift(x):
"""Move the zero frequency to position n // 2 (1D, or both axes of an image)."""
if x and isinstance(x[0], (list, tuple)):
rows = [fftshift(r) for r in x]
return _shift1(rows, (len(rows) + 1) // 2)
return _shift1(x, (len(x) + 1) // 2)
def ifftshift(x):
"""The inverse of fftshift (1D, or both axes of an image)."""
if x and isinstance(x[0], (list, tuple)):
rows = [ifftshift(r) for r in x]
return _shift1(rows, len(rows) // 2)
return _shift1(x, len(x) // 2)
def circ_conv(x, h):
"""Periodic convolution y_i = sum_j h_j x_{(i - j) mod n}, kernel centered at index 0."""
n = len(x)
nz = [(j, hj) for j, hj in enumerate(h) if hj != 0]
return [sum(hj * x[(i - j) % n] for j, hj in nz) for i in range(n)]
def circ_conv2(img, h):
"""Periodic 2D convolution with the kernel h centered at index (0, 0)."""
n1, n2 = len(img), len(img[0])
nz = [(p, q, h[p][q]) for p in range(len(h)) for q in range(len(h[0])) if h[p][q] != 0]
out = new_image(n1, n2)
for i in range(n1):
for j in range(n2):
out[i][j] = sum(v * img[(i - p) % n1][(j - q) % n2] for p, q, v in nz)
return out
# ------------------------------------------------------------------ phantoms
def pixel_centers(n):
"""(xs, ys): xs[j] = -1 + (2 j + 1) / n and ys[i] = 1 - (2 i + 1) / n."""
xs = [-1.0 + (2 * j + 1) / n for j in range(n)]
ys = [1.0 - (2 * i + 1) / n for i in range(n)]
return xs, ys
# Rows: rho, A, B, x0, y0, phi (degrees). A is the semi-axis along the
# direction phi (counterclockwise from the x axis), B the other semi-axis.
# Geometry and densities of Shepp and Logan (1974), as reproduced in Kak and
# Slaney, Principles of Computerized Tomographic Imaging, Table 3.1. The value
# at the center (0, 0) is 2 - 0.98 = 1.02.
SHEPP_LOGAN = [
(2.0, 0.92, 0.69, 0.0, 0.0, 90.0),
(-0.98, 0.874, 0.6624, 0.0, -0.0184, 90.0),
(-0.02, 0.31, 0.11, 0.22, 0.0, 72.0),
(-0.02, 0.41, 0.16, -0.22, 0.0, 108.0),
(0.01, 0.25, 0.21, 0.0, 0.35, 90.0),
(0.01, 0.046, 0.046, 0.0, 0.1, 0.0),
(0.01, 0.046, 0.046, 0.0, -0.1, 0.0),
(0.01, 0.046, 0.023, -0.08, -0.605, 0.0),
(0.01, 0.023, 0.023, 0.0, -0.605, 0.0),
(0.01, 0.046, 0.023, 0.06, -0.605, 90.0),
]
# The same ellipses with the gray levels of Toft (1996), which give more
# contrast. The value at the center is 1 - 0.8 = 0.2.
MODIFIED_SHEPP_LOGAN = [
(rho, a, b, x0, y0, phi)
for rho, (_, a, b, x0, y0, phi) in zip(
(1.0, -0.8, -0.2, -0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1), SHEPP_LOGAN
)
]
def ellipse_value(x, y, table):
"""The phantom value at the point (x, y): the sum of rho over the ellipses that hold it."""
total = 0.0
for rho, a, b, x0, y0, phi in table:
c, s = math.cos(math.radians(phi)), math.sin(math.radians(phi))
dx, dy = x - x0, y - y0
u = dx * c + dy * s
v = -dx * s + dy * c
if (u / a) ** 2 + (v / b) ** 2 <= 1.0:
total += rho
return total
def ellipse_phantom(n, table):
"""The n x n image of an ellipse table, sampled at the pixel centers."""
xs, ys = pixel_centers(n)
return [[ellipse_value(x, y, table) for x in xs] for y in ys]
def disk_phantom(n, radius):
"""1 at pixel centers with x^2 + y^2 <= radius^2, 0 elsewhere."""
xs, ys = pixel_centers(n)
r2 = radius * radius
return [[1.0 if x * x + y * y <= r2 else 0.0 for x in xs] for y in ys]
def spikes_1d(n, positions, amplitudes):
"""A signal of length n with the given amplitudes at the given positions."""
out = [0.0] * n
for p, a in zip(positions, amplitudes):
out[p] += a
return out
# ------------------------------------------------------------------ projector
def parallel_beam_matrix(n, angles, nbins):
"""Pixel-driven discrete Radon transform of an n x n image on [-1, 1]^2.
Each pixel center (x, y) projects to s = x cos(theta) + y sin(theta). Its
value times the pixel area over the bin width is split linearly between
the two nearest bin centers. The bins cover [-sqrt(2), sqrt(2)]. Row
a * nbins + b holds angle a and bin b; column i * n + j holds pixel (i, j).
Returns the sparse rows, each a list of (column, weight) pairs.
Pixel-driven projection has a ripple: with a bin width close to the pixel
size, a disk projection is off by up to about 10 percent in some bins. A
bin of about twice the pixel size (nbins = 23 for n = 32) keeps it near
1 percent.
"""
xs, ys = pixel_centers(n)
smax = math.sqrt(2.0)
width = 2.0 * smax / nbins
scale = (2.0 / n) ** 2 / width
rows = []
for theta in angles:
c, s = math.cos(theta), math.sin(theta)
acc = [dict() for _ in range(nbins)]
for i, y in enumerate(ys):
for j, x in enumerate(xs):
t = (x * c + y * s + smax) / width - 0.5
b0 = math.floor(t)
frac = t - b0
col = i * n + j
for b, w in ((b0, 1.0 - frac), (b0 + 1, frac)):
if 0 <= b < nbins and w > 0.0:
acc[b][col] = acc[b].get(col, 0.0) + w * scale
rows.extend(sorted(d.items()) for d in acc)
return rows
def sp_matvec(rows, x):
"""y = A x for sparse rows of (column, weight) pairs."""
return [sum(w * x[c] for c, w in row) for row in rows]
def sp_rmatvec(rows, y, ncols):
"""x = A^H y for sparse rows of (column, weight) pairs and ncols columns."""
out = [0.0] * ncols
for row, yi in zip(rows, y):
if yi == 0:
continue
for c, w in row:
out[c] += w.conjugate() * yi
return out
# ------------------------------------------------------------------ noise
def gauss_noise(rng, shape, sigma):
"""Independent N(0, sigma^2) values: a list for an int shape, an image for (n1, n2)."""
if isinstance(shape, int):
return [rng.gauss(0.0, sigma) for _ in range(shape)]
n1, n2 = shape
return [[rng.gauss(0.0, sigma) for _ in range(n2)] for _ in range(n1)]
def _poisson_small(rng, lam):
"""Knuth's product method, exact for a mean lam <= 30."""
limit = math.exp(-lam)
k, p = 0, rng.random()
while p > limit:
k += 1
p *= rng.random()
return k
def poisson_sample(rng, lam):
"""An exact Poisson(lam) sample: a sum of Knuth samples with means at most 30."""
if lam < 0:
raise ValueError("negative mean")
total = 0
while lam > 30.0:
total += _poisson_small(rng, 30.0)
lam -= 30.0
if lam > 0.0:
total += _poisson_small(rng, lam)
return total
imgla.py 259 lines
# SPDX-License-Identifier: MIT
# Shared helper of the imaging and inverse problems pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Dense linear algebra on lists of rows (float, complex or Fraction entries).
A matrix is a list of rows. A vector is a list of numbers. The inner product
is <u, v> = sum_i conj(u_i) v_i, linear in the second argument, so that the
adjoint A^H satisfies <A x, y> = <x, A^H y>.
"""
import math
def _flat(x):
"""Flatten a list of rows (an image) into one list; a vector is returned as is."""
if x and isinstance(x[0], (list, tuple)):
return [v for row in x for v in row]
return x
def zeros(m, n):
"""The m x n zero matrix."""
return [[0.0] * n for _ in range(m)]
def eye(n):
"""The n x n identity matrix."""
out = zeros(n, n)
for i in range(n):
out[i][i] = 1.0
return out
def transpose(a):
"""A^T."""
return [list(col) for col in zip(*a)]
def conj_transpose(a):
"""A^H, the conjugate transpose."""
return [[v.conjugate() for v in col] for col in zip(*a)]
def matmul(a, b):
"""The product A B."""
bt = list(zip(*b))
return [[sum(x * y for x, y in zip(row, col)) for col in bt] for row in a]
def matvec(a, x):
"""The product A x."""
return [sum(v * w for v, w in zip(row, x)) for row in a]
def rmatvec(a, y):
"""The product A^H y."""
n = len(a[0]) if a else 0
out = [0.0] * n
for row, yi in zip(a, y):
if yi == 0:
continue
for j, v in enumerate(row):
out[j] += v.conjugate() * yi
return out
def dot(u, v):
"""<u, v> = sum_i conj(u_i) v_i. Images (lists of rows) are flattened."""
return sum(a.conjugate() * b for a, b in zip(_flat(u), _flat(v)))
def norm2(x):
"""The Euclidean norm. Images (lists of rows) are flattened."""
return math.sqrt(sum(abs(v) ** 2 for v in _flat(x)))
def solve(a, b):
"""Solve A x = b by Gaussian elimination with partial pivoting.
b is a vector or a matrix (a list of rows). A must be square and
nonsingular; a zero pivot raises ValueError. Fractions stay exact.
"""
n = len(a)
vec = not (b and isinstance(b[0], (list, tuple)))
rhs = [[bi] for bi in b] if vec else [list(r) for r in b]
m = [list(row) + rhs[i] for i, row in enumerate(a)]
w = len(m[0])
for c in range(n):
p = max(range(c, n), key=lambda r: abs(m[r][c]))
if m[p][c] == 0:
raise ValueError("singular matrix")
m[c], m[p] = m[p], m[c]
piv = m[c][c]
for r in range(c + 1, n):
f = m[r][c] / piv
if f != 0:
mr, mc = m[r], m[c]
for j in range(c, w):
mr[j] -= f * mc[j]
x = [[0.0] * (w - n) for _ in range(n)]
for r in range(n - 1, -1, -1):
for j in range(w - n):
s = m[r][n + j] - sum(m[r][k] * x[k][j] for k in range(r + 1, n))
x[r][j] = s / m[r][r]
return [row[0] for row in x] if vec else x
def cholesky(a):
"""Lower triangular L with A = L L^H for a Hermitian positive definite A."""
n = len(a)
low = zeros(n, n)
for j in range(n):
d = a[j][j] - sum(abs(low[j][k]) ** 2 for k in range(j))
d = d.real if isinstance(d, complex) else d
if not d > 0:
raise ValueError("matrix is not positive definite")
ljj = math.sqrt(d)
low[j][j] = ljj
for i in range(j + 1, n):
s = a[i][j] - sum(low[i][k] * low[j][k].conjugate() for k in range(j))
low[i][j] = s / ljj
return low
def cho_solve(low, b):
"""Solve (L L^H) x = b, with L from cholesky."""
n = len(low)
z = [0.0] * n
for i in range(n):
z[i] = (b[i] - sum(low[i][k] * z[k] for k in range(i))) / low[i][i]
x = [0.0] * n
for i in range(n - 1, -1, -1):
s = z[i] - sum(low[k][i].conjugate() * x[k] for k in range(i + 1, n))
x[i] = s / low[i][i].conjugate()
return x
def _rot_params(app, aqq, apq):
"""c, s of the Jacobi rotation that zeroes the (p, q) entry of [[app, apq], [apq, aqq]]."""
theta = (aqq - app) / (2.0 * apq)
t = (1.0 if theta >= 0 else -1.0) / (abs(theta) + math.sqrt(theta * theta + 1.0))
c = 1.0 / math.sqrt(1.0 + t * t)
return c, c * t
def sym_eig(a, tol=1e-15, max_sweeps=100):
"""Eigenvalues (ascending) and eigenvectors (as columns) of a real symmetric matrix.
Cyclic Jacobi method. Returns (w, Q) with A = Q diag(w) Q^T.
"""
n = len(a)
m = [[float(v) for v in row] for row in a]
q = eye(n)
for _ in range(max_sweeps):
off = sum(m[i][j] ** 2 for i in range(n) for j in range(n) if i != j)
scale = sum(m[i][i] ** 2 for i in range(n)) + off
if off <= (tol * tol) * scale or off == 0.0:
break
for p in range(n - 1):
for r in range(p + 1, n):
apq = m[p][r]
if apq == 0.0:
continue
c, s = _rot_params(m[p][p], m[r][r], apq)
for k in range(n):
mkp, mkr = m[k][p], m[k][r]
m[k][p] = c * mkp - s * mkr
m[k][r] = s * mkp + c * mkr
mp, mr = m[p], m[r]
for k in range(n):
mpk, mrk = mp[k], mr[k]
mp[k] = c * mpk - s * mrk
mr[k] = s * mpk + c * mrk
m[p][r] = m[r][p] = 0.0
for k in range(n):
qkp, qkr = q[k][p], q[k][r]
q[k][p] = c * qkp - s * qkr
q[k][r] = s * qkp + c * qkr
order = sorted(range(n), key=lambda i: m[i][i])
w = [m[i][i] for i in order]
qs = [[q[k][i] for i in order] for k in range(n)]
return w, qs
def _complete(cols, m):
"""Replace zero columns of an m-row column list by unit vectors orthogonal to the others."""
for idx, col in enumerate(cols):
if any(v != 0.0 for v in col):
continue
for e in range(m):
cand = [0.0] * m
cand[e] = 1.0
for _ in range(2):
for jdx, other in enumerate(cols):
if jdx == idx or not any(v != 0.0 for v in other):
continue
h = sum(a * b for a, b in zip(other, cand))
cand = [a - h * b for a, b in zip(cand, other)]
nrm = math.sqrt(sum(v * v for v in cand))
if nrm > 0.5:
cols[idx] = [v / nrm for v in cand]
break
return cols
def svd(a, tol=1e-15, max_sweeps=100):
"""Thin SVD of a real m x n matrix by one-sided Jacobi (Hestenes).
Returns (U, S, V) with p = min(m, n): U is m x p, S a list of p values in
descending order, V is n x p, U^T U = I, V^T V = I and A = U diag(S) V^T.
"""
m, n = len(a), len(a[0])
if m < n:
v, s, u = svd(transpose(a), tol, max_sweeps)
return u, s, v
cols = [[float(a[i][j]) for i in range(m)] for j in range(n)]
vcols = [[1.0 if i == j else 0.0 for i in range(n)] for j in range(n)]
for _ in range(max_sweeps):
rotated = False
for p in range(n - 1):
for r in range(p + 1, n):
cp, cr = cols[p], cols[r]
alpha = sum(x * x for x in cp)
beta = sum(x * x for x in cr)
gamma = sum(x * y for x, y in zip(cp, cr))
if gamma == 0.0 or abs(gamma) <= tol * math.sqrt(alpha * beta):
continue
rotated = True
c, s = _rot_params(alpha, beta, gamma)
cols[p] = [c * x - s * y for x, y in zip(cp, cr)]
cols[r] = [s * x + c * y for x, y in zip(cp, cr)]
vp, vr = vcols[p], vcols[r]
vcols[p] = [c * x - s * y for x, y in zip(vp, vr)]
vcols[r] = [s * x + c * y for x, y in zip(vp, vr)]
if not rotated:
break
sig = [math.sqrt(sum(x * x for x in col)) for col in cols]
# A column below 1e-150 times the largest one is zero to working precision;
# its squares underflow, so its direction carries no information.
floor = max(sig) * 1e-150 if sig else 0.0
sig = [t if t > floor and t > 1e-150 else 0.0 for t in sig]
order = sorted(range(n), key=lambda j: -sig[j])
s_out = [sig[j] for j in order]
ucols = [[x / sig[j] for x in cols[j]] if sig[j] > 0.0 else [0.0] * m for j in order]
ucols = _complete(ucols, m)
u = [[ucols[j][i] for j in range(n)] for i in range(m)]
v = [[vcols[j][i] for j in order] for i in range(n)]
return u, s_out, v
def adjoint_gap(apply_a, apply_ah, x, y):
"""|<A x, y> - <x, A^H y>| / (||A x|| ||y||) for given functions A and A^H.
x and y may be vectors or images (lists of rows). If the denominator is
zero, the absolute gap is returned.
"""
ax = apply_a(x)
gap = abs(dot(ax, y) - dot(x, apply_ah(y)))
den = norm2(ax) * norm2(y)
return gap / den if den > 0.0 else gap
parabolic_radon_transform.py 114 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/parabolic-radon-transform/. The authors are listed in prov/5J6KMF.jsonl.
"""The least-squares parabolic Radon transform and its use for multiple removal.
A gather is a list of traces d[i] (offset x_i), each with n samples at k * dt.
A model is a list of traces m[j] (curvature q_j in s/m^2) with n samples at
tau = k * dt. The forward operator sums the model along parabolas,
d(t, x_i) = sum_j m(t - q_j x_i^2, q_j),
with the time shifts done exactly in the frequency domain on a periodic time
axis. For each frequency w_k = 2 pi k' / (n dt) (k' the signed index) it is
the matrix L_k[i][j] = exp(-1j w_k q_j x_i^2), and the damped least-squares
model is M_k = (L_k^H L_k + mu I)^(-1) L_k^H D_k. Use an odd n: then there is
no Nyquist bin, a real model gives real data, and the shifts are exact.
"""
import cmath
import math
import imgkit as ik
import imgla as la
def omega(k, n, dt):
"""The angular frequency of DFT bin k (signed index k or k - n)."""
ks = k if k <= n // 2 else k - n
return 2.0 * math.pi * ks / (n * dt)
def operator_matrix(w, offsets, qs):
"""L[i][j] = exp(-1j w q_j x_i^2)."""
return [[cmath.exp(-1j * w * q * x * x) for q in qs] for x in offsets]
def _spectra(traces):
return [ik.dft(tr) for tr in traces]
def _traces(spectra):
return [[v.real for v in ik.idft(sp)] for sp in spectra]
def forward(m, offsets, qs, dt):
"""d = L m: sum the model traces along the parabolas t = tau + q x^2."""
n = len(m[0])
mf = _spectra(m)
df = [[0j] * n for _ in offsets]
for k in range(n):
lk = operator_matrix(omega(k, n, dt), offsets, qs)
col = la.matvec(lk, [mf[j][k] for j in range(len(qs))])
for i in range(len(offsets)):
df[i][k] = col[i]
return _traces(df)
def adjoint(d, offsets, qs, dt):
"""m = L^T d: the plain parabolic stack (sum the data along each parabola)."""
n = len(d[0])
dfs = _spectra(d)
mf = [[0j] * n for _ in qs]
for k in range(n):
lk = operator_matrix(omega(k, n, dt), offsets, qs)
col = la.rmatvec(lk, [dfs[i][k] for i in range(len(offsets))])
for j in range(len(qs)):
mf[j][k] = col[j]
return _traces(mf)
def demultiple(d, offsets, qs, dt, mu, q_cut):
"""Least-squares parabolic Radon transform and multiple removal.
d must be NMO-corrected with the primary velocity, so the primaries are
flat (q near 0) and the multiples curve down (q > 0). Returns
(m, primaries, multiples): the model, d minus the predicted multiples,
and the predicted multiples (built from the model at q_j > q_cut).
"""
n = len(d[0])
nq = len(qs)
dfs = _spectra(d) # @line L1
mf = [[0j] * n for _ in qs]
mulf = [[0j] * n for _ in offsets]
for k in range(n): # @line L2
lk = operator_matrix(omega(k, n, dt), offsets, qs) # @line L3
dk = [dfs[i][k] for i in range(len(offsets))]
lh = la.conj_transpose(lk)
normal = la.matmul(lh, lk)
for j in range(nq):
normal[j][j] += mu
mk = la.solve(normal, la.matvec(lh, dk)) # @line L4
keep = [mk[j] if qs[j] > q_cut else 0j for j in range(nq)] # @line L5
dmul = la.matvec(lk, keep) # @line L6
for j in range(nq):
mf[j][k] = mk[j]
for i in range(len(offsets)):
mulf[i][k] = dmul[i]
m = _traces(mf) # @line L7
multiples = _traces(mulf)
primaries = [[a - b for a, b in zip(tr, mt)] for tr, mt in zip(d, multiples)]
return m, primaries, multiples # @line L8
def residual_moveout(t0, x, v_primary, v_multiple):
"""Exact residual time of a multiple after NMO with the primary velocity.
The multiple arrives at sqrt(t0^2 + x^2 / v_multiple^2); NMO with
v_primary maps it to sqrt(t0^2 + x^2 (1 / v_multiple^2 - 1 / v_primary^2)).
"""
return math.sqrt(t0 * t0 + x * x * (1.0 / v_multiple ** 2 - 1.0 / v_primary ** 2)) - t0
def parabolic_curvature(t0, v_primary, v_multiple):
"""q = (1 / v_multiple^2 - 1 / v_primary^2) / (2 t0), the small-offset parabola."""
return (1.0 / v_multiple ** 2 - 1.0 / v_primary ** 2) / (2.0 * t0)
test_parabolic_radon_transform.py 100 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/parabolic-radon-transform/. The authors are listed in prov/5J6KMF.jsonl.
import math
import random
import imgla as la
from parabolic_radon_transform import (
adjoint,
demultiple,
forward,
parabolic_curvature,
residual_moveout,
)
def ricker(t, f=20.0):
a = (math.pi * f * t) ** 2
return (1.0 - 2.0 * a) * math.exp(-a)
def flat(rows):
return [v for r in rows for v in r]
def rel_err(a, b):
num = math.sqrt(sum((p - q) ** 2 for p, q in zip(flat(a), flat(b))))
return num / math.sqrt(sum(q * q for q in flat(b)))
def test_example_numbers():
assert abs(residual_moveout(1.0, 2000.0, 2500.0, 2000.0) - 0.16619) < 1e-5
q = parabolic_curvature(1.0, 2500.0, 2000.0)
assert abs(q - 4.5e-8) < 1e-20
assert abs(q * 2000.0 ** 2 - 0.18) < 1e-12
def test_integer_shift_is_exact():
n, dt = 15, 0.004
x = 200.0
q = 3 * dt / (x * x)
rng = random.Random(1)
tr = [rng.gauss(0.0, 1.0) for _ in range(n)]
d = forward([tr], [0.0, x], [q], dt)
assert max(abs(a - b) for a, b in zip(d[0], tr)) < 1e-12
shifted = [tr[(k - 3) % n] for k in range(n)]
assert max(abs(a - b) for a, b in zip(d[1], shifted)) < 1e-12
def test_adjoint():
rng = random.Random(2)
n, dt = 21, 0.004
offsets = [0.0, 150.0, 400.0, 700.0, 900.0]
qs = [-1e-8, 0.0, 2e-8, 5e-8]
x = [[rng.gauss(0.0, 1.0) for _ in range(n)] for _ in qs]
y = [[rng.gauss(0.0, 1.0) for _ in range(n)] for _ in offsets]
gap = la.adjoint_gap(lambda v: forward(v, offsets, qs, dt),
lambda v: adjoint(v, offsets, qs, dt), x, y)
assert gap < 1e-12
def test_equals_dense_time_domain_least_squares():
rng = random.Random(3)
n, dt, mu = 7, 0.004, 0.3
offsets = [0.0, 300.0, 600.0]
qs = [0.0, 1.5e-8]
d = [[rng.gauss(0.0, 1.0) for _ in range(n)] for _ in offsets]
cols = []
for j in range(len(qs)):
for k in range(n):
e = [[0.0] * n for _ in qs]
e[j][k] = 1.0
cols.append(flat(forward(e, offsets, qs, dt)))
a = la.transpose(cols)
at = cols
normal = la.matmul(at, a)
for i in range(len(normal)):
normal[i][i] += mu
m_dense = la.solve(normal, la.matvec(at, flat(d)))
m, _, _ = demultiple(d, offsets, qs, dt, mu, q_cut=1.0)
assert max(abs(p - q) for p, q in zip(flat(m), m_dense)) < 1e-9
def test_removes_a_curved_multiple():
n, dt = 63, 0.008
offsets = [100.0 * i for i in range(16)]
qs = [-1e-8 + 0.5e-8 * j for j in range(14)]
jp, jm = 2, 10
model = [[0.0] * n for _ in qs]
model[jp] = [ricker(k * dt - 0.15) for k in range(n)]
model[jm] = [-0.7 * ricker(k * dt - 0.2) for k in range(n)]
d = forward(model, offsets, qs, dt)
only_primary = [row if j == jp else [0.0] * n for j, row in enumerate(model)]
p_true = forward(only_primary, offsets, qs, dt)
m, primaries, multiples = demultiple(d, offsets, qs, dt, 1e-2, 1.2e-8)
assert rel_err(d, p_true) > 0.69
assert rel_err(primaries, p_true) < 0.15
energy = [sum(v * v for v in row) for row in m]
assert max(range(len(qs)), key=lambda j: energy[j]) in (jp, jm)
assert energy[jm] > 10 * energy[jm - 4]
History
Thorson and Claerbout (1985) described the velocity stack and the slant stack as inverse problems: the model is the set of events in velocity or ray parameter, and it is found by fitting the data in the least-squares sense with a prior on the model. Hampson (1986) proposed to work on gathers after NMO correction, where the residual moveout of multiples is close to a parabola. A parabolic moveout is a pure time shift, so the least-squares problem splits by frequency into small systems. This made the method fast enough for production processing, and the parabolic Radon demultiple became a standard step in seismic processing.
References
- Dan Hampson, Inverse velocity stacking for multiple elimination, Journal of the Canadian Society of Exploration Geophysicists 22(1), 1986, 44 to 55, the parabolic approximation of the residual moveout after NMO, the least-squares transform solved frequency by frequency, and the subtraction of the multiples
- Dan Hampson, Inverse velocity stacking for multiple elimination, SEG Technical Program Expanded Abstracts 1986, 422 to 424, the short conference version of the method
- John R. Thorson and Jon F. Claerbout, Velocity-stack and slant-stack stochastic inversion, Geophysics 50(12), 1985, 2727 to 2741, the velocity stack and the slant stack posed as inverse problems with a least-squares fit and a model prior
- Oz Yilmaz, Seismic Data Analysis, Society of Exploration Geophysicists, 2001, Investigations in Geophysics 10, the chapter on multiple attenuation (the parabolic Radon transform and its use to separate primaries and multiples)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 5J6KMF Edit this page History Report an error Markdown