Algorithm Search⌘K

Algorithmresearch

Least-squares migration

Also called LSM, least-squares RTM.

Find the reflectivity whose Born modeled data best fits the recorded data, solved by conjugate gradients with migration as the adjoint.

Time
O(k (a + n + d)) totalO(a + n + d) per_iteration
Space
O(n + d) extra
Where
a = the cost of one product with the modeling operator or its transpose; d = the number of data samples; k = the number of iterations; n = the number of image points
Properties
deterministiciterativelinearneeds exact adjointregularized by early stopping
Origin
Tamas Nemeth, Chengjun Wu, Gerard T. Schuster, 1999

Least-squares migration (LSM) finds the reflectivity mm whose modeled data LmLm fit the recorded data dd best, min⁡m∥Lm−d∥2\min_m \|Lm - d\|^2, where LL is a linear (Born) modeling operator. Ordinary migration computes only LTdL^{\mathsf T}d, the adjoint, which is not the inverse: it blurs the image with the wavelet, the illumination and the aperture (a theorem about adjoints: LTL≠IL^{\mathsf T}L \ne I in general). LSM removes part of that blur by running CGLS, the conjugate gradient method on the normal equations LTLm=LTdL^{\mathsf T}Lm = L^{\mathsf T}d, with one modeling and one migration per iteration. Any migration can serve as LTL^{\mathsf T} if it is the exact transpose of the modeling: Kirchhoff migration gives least-squares Kirchhoff migration, and reverse-time migration gives least-squares RTM, one variant of the method. LSM is linear in mm for a fixed background velocity; full-waveform inversion instead updates the velocity itself, which is nonlinear.

In plain words

Migration makes a picture of the ground from the echoes, but the picture is not sharp: deep parts are weak, edges are smeared, and gaps in the recording leave stripes. Least-squares migration asks a better question. Which picture of the ground would produce echoes that look like the recorded ones? It starts with an empty picture, simulates the echoes it would make, compares them with the real ones, and migrates the difference to improve the picture. It repeats this, and each round uses the conjugate gradient rule so that it never undoes the gains of earlier rounds. After some rounds the picture is sharper and more balanced. Each round costs one simulation and one migration.

The problem

Given the data d∈Rndd \in \mathbb{R}^{n_d} and a linear modeling operator L:Rn→RndL : \mathbb{R}^{n} \to \mathbb{R}^{n_d} (Born modeling in a fixed background velocity) with its exact transpose LTL^{\mathsf T} (migration), find

m∗=arg⁡min⁡m∥Lm−d∥22,m^* = \arg\min_m \|Lm - d\|_2^2,

or, with damping, min⁡m∥Lm−d∥2+ε∥m∥2\min_m \|Lm - d\|^2 + \varepsilon\|m\|^2, the Tikhonov form. This is seismic migration posed as a linear inverse problem.

The algorithm

  1. LEAST-SQUARES-MIGRATION(L, Lᵀ, d, k_max) ▷ L: Born modeling, Lᵀ: migration
  2. 1m ← 0; r ← d ▷ the data residual
  3. 2s ← Lᵀ r; p ← s; γ ← ‖s‖² ▷ s: the migrated residual
  4. 3for k ← 1 to k_max do
  5. 4if γ = 0 then break
  6. 5q ← L p ▷ one Born modeling
  7. 6α ← γ / ‖q‖²
  8. 7m ← m + α p
  9. 8r ← r - α q
  10. 9s ← Lᵀ r; γ_new ← ‖s‖² ▷ one migration
  11. 10p ← s + (γ_new / γ) p; γ ← γ_new
  12. 11return m

Line L2 is ordinary migration: the first search direction is the migrated image LTdL^{\mathsf T}d. Line L5 models data for the search direction, and line L6 chooses the step that minimizes the residual along it. Lines L7 and L8 update the image and the residual together, so line L9 never needs another modeling. Line L10 makes the next direction conjugate to the earlier ones with respect to LTLL^{\mathsf T}L. For the damped problem, run the same loop with the stacked operator [LεI]\begin{bmatrix} L \\ \sqrt{\varepsilon} I\end{bmatrix} and the data [d0]\begin{bmatrix} d \\ 0\end{bmatrix}.

Example

Migration is not the inverse, by hand. Let L=diag⁡(2,1/2)L = \operatorname{diag}(2, 1/2), a toy operator that sees one reflector four times better than the other, and the true model m=(1,1)m = (1, 1), so d=(2,0.5)d = (2, 0.5). Migration gives LTd=(4,0.25)L^{\mathsf T}d = (4, 0.25): the two equal reflectors differ by a factor of 16 in the image. CGLS fixes this. The first iteration gives m1=(1.0037,0.0627)m_1 = (1.0037, 0.0627) with the residual norm 0.4690.469. The second gives m2=(1,1)m_2 = (1, 1) to rounding, with the residual norm 4×10−164 \times 10^{-16}, because LL has only two distinct singular values (a theorem: CGLS ends in at most that many steps in exact arithmetic).

A Born-Kirchhoff test. The test operator is a zero-offset Born-Kirchhoff operator in constant velocity 2000 m/s with a 30 Hz Ricker wavelet, an image of 8×108 \times 10 points (80 unknowns) and 40 samples on 10 traces (400 data). It has 28540 nonzero entries. The true model has two point scatterers and a flat layer. The best scaled migration image has a relative model error of 0.727. CGLS reaches the following (measurements on this case):

iterations relative model error residual norm / data norm
5 0.575 0.0766
10 0.515 0.0273
25 0.463 0.0087
50 0.410 0.0035
100 0.290 0.0015

The residual drops fast and the model error slowly, because the small singular values of LL belong to image details that the 10 traces barely see.

Correctness

The full proof is in proofs/correctness.md.

  • Minimizers (theorem). The minimizers of ∥Lm−d∥\|Lm - d\| are the solutions of LTLm=LTdL^{\mathsf T}Lm = L^{\mathsf T}d; among them, the one in the range of LTL^{\mathsf T} is the minimum-norm solution L+dL^+d.
  • Invariants (theorem). At line L3 the loop keeps r=d−Lmr = d - Lm and s=LTrs = L^{\mathsf T}r.
  • CGLS is CG on the normal equations (theorem). The iterates are those of the conjugate gradient method on LTLm=LTdL^{\mathsf T}Lm = L^{\mathsf T}d from m=0m = 0. So mkm_k minimizes ∥Lm−d∥\|Lm - d\| over the Krylov space span⁡{LTd,…,(LTL)k−1LTd}\operatorname{span}\{L^{\mathsf T}d, \dots, (L^{\mathsf T}L)^{k-1}L^{\mathsf T}d\}, the residual norms never increase, line L6 never divides by zero, and in exact arithmetic the loop ends within rank⁡(L)\operatorname{rank}(L) iterations at L+dL^+d.
  • Damping (theorem). The stacked operator gives the minimizer of ∥Lm−d∥2+ε∥m∥2\|Lm - d\|^2 + \varepsilon\|m\|^2; the test matches a direct solve to 10−610^{-6}.
  • Exact transpose (theorem). The sparse modeling and migration of the test operator are exact transposes; the dot-product test holds to 10−1210^{-12}.

That the image after a few iterations is a better picture of the earth than the migrated image is not a theorem; it holds when the operator and the background velocity are right (a heuristic, supported by the test above).

Proof: Correctness of least-squares migrationfull

Setting. LL is a real Nd×nN_d \times n matrix (the linear modeling operator), LTL^{\mathsf T} is its transpose (migration), and d∈RNdd \in \mathbb{R}^{N_d} is the data. Least-squares migration asks for a minimizer of Φ(m)=∥Lm−d∥2\Phi(m) = \|L m - d\|^2. All statements are in exact arithmetic. The iteration index kk counts the passes of the loop at line L3; mk,rk,sk,pk,γkm_k, r_k, s_k, p_k, \gamma_k are the values after kk passes.

Lemma 1 (the minimizers). mm minimizes Φ\Phi if and only if LT(d−Lm)=0L^{\mathsf T}(d - L m) = 0 (the normal equations). A minimizer exists, and there is exactly one minimizer in the range of LTL^{\mathsf T}: the minimum-norm solution.

Proof. Φ\Phi is a convex quadratic with the gradient −2LT(d−Lm)-2L^{\mathsf T}(d - Lm), so its minimizers are its stationary points. Write d=d1+d2d = d_1 + d_2 with d1d_1 in the range of LL and d2d_2 orthogonal to it. Then Φ(m)=∥Lm−d1∥2+∥d2∥2\Phi(m) = \|Lm - d_1\|^2 + \|d_2\|^2, and Lm=d1Lm = d_1 has a solution. Two solutions differ by an element of the null space of LL, which is orthogonal to the range of LTL^{\mathsf T}, so at most one solution lies in that range, and the projection of any solution onto it is a solution. □\square

Lemma 2 (invariants). After every pass, rk=d−Lmkr_k = d - L m_k and sk=LTrks_k = L^{\mathsf T} r_k.

Proof. Induction. At the start m0=0m_0 = 0, and lines L1 and L2 set r0=dr_0 = d and s0=LTds_0 = L^{\mathsf T}d. In a pass, line L5 sets q=Lpq = L p, and lines L7 and L8 change mm by αp\alpha p and rr by −αq-\alpha q, so d−L(m+αp)=r−αqd - L(m + \alpha p) = r - \alpha q. Line L9 recomputes s=LTrs = L^{\mathsf T} r. □\square

Theorem 1 (CGLS is CG on the normal equations). Let A=LTLA = L^{\mathsf T}L and b=LTdb = L^{\mathsf T}d. The iterates mkm_k are the iterates of the conjugate gradient method for Am=bA m = b started at 0. Hence:

  1. mkm_k minimizes Φ\Phi over the Krylov space Kk=span⁡{b,Ab,…,Ak−1b}\mathcal{K}_k = \operatorname{span}\{b, Ab, \ldots, A^{k-1}b\};
  2. the residual norms ∥rk∥=∥d−Lmk∥\|r_k\| = \|d - L m_k\| returned in the list are non-increasing in kk;
  3. if γk>0\gamma_k > 0 then ∥Lpk∥>0\|L p_k\| > 0, so line L6 never divides by zero;
  4. γk=0\gamma_k = 0 happens after at most rank⁡(L)≤n\operatorname{rank}(L) \le n passes, and then mkm_k is the minimum-norm minimizer of Φ\Phi.

Proof. By Lemma 2 the CG residual is b−Amk=LT(d−Lmk)=skb - A m_k = L^{\mathsf T}(d - L m_k) = s_k, and γk=∥sk∥2\gamma_k = \|s_k\|^2. The CG step length is ∥sk∥2/(pkTApk)=γk/∥Lpk∥2\|s_k\|^2/(p_k^{\mathsf T} A p_k) = \gamma_k/\|L p_k\|^2, which is line L6, and the CG update pk+1=sk+1+(∥sk+1∥2/∥sk∥2) pkp_{k+1} = s_{k+1} + (\|s_{k+1}\|^2/\|s_k\|^2)\,p_k is line L10. So the two methods produce the same sequences.

The standard results for CG on a symmetric positive semidefinite system with bb in the range of AA (see the conjugate gradient method and CGLS pages) give: the residuals s0,s1,…s_0, s_1, \ldots are mutually orthogonal, pkTsk=∥sk∥2p_k^{\mathsf T}s_k = \|s_k\|^2, and mkm_k minimizes the AA-norm error (m−m⋆)TA(m−m⋆)(m - m^\star)^{\mathsf T}A(m - m^\star) over Kk\mathcal{K}_k for any solution m⋆m^\star. Since (m−m⋆)TA(m−m⋆)=∥Lm−Lm⋆∥2=Φ(m)−Φ(m⋆)(m - m^\star)^{\mathsf T}A(m - m^\star) = \|Lm - Lm^\star\|^2 = \Phi(m) - \Phi(m^\star), this is item 1. The spaces Kk\mathcal{K}_k are nested, so item 2 follows.

For item 3, ∥Lpk∥2=pkTApk\|Lp_k\|^2 = p_k^{\mathsf T}Ap_k and, by Lemma 2, ⟨rk,Lpk⟩=⟨sk,pk⟩=γk>0\langle r_k, Lp_k\rangle = \langle s_k, p_k\rangle = \gamma_k > 0, so Lpk≠0Lp_k \ne 0.

For item 4, b=LTdb = L^{\mathsf T}d and all Kk\mathcal{K}_k lie in the range of LTL^{\mathsf T}, which has the dimension rank⁡(L)\operatorname{rank}(L). The nonzero residuals sks_k are orthogonal and lie in this range, so at most rank⁡(L)\operatorname{rank}(L) of them are nonzero. When γk=0\gamma_k = 0, sk=0s_k = 0, so mkm_k solves the normal equations; it lies in the range of LTL^{\mathsf T}, so by Lemma 1 it is the minimum-norm minimizer. Line L4 then stops the loop, and in any case the loop has at most iters passes, and line L11 returns. ■\blacksquare

Lemma 3 (damping). For ε>0\varepsilon > 0, the stacked operator L~=[Lε I]\tilde L = \begin{bmatrix} L \\ \sqrt{\varepsilon}\, I\end{bmatrix} and the stacked data d~=(d,0)\tilde d = (d, 0) of damped satisfy ∥L~m−d~∥2=∥Lm−d∥2+ε∥m∥2\|\tilde L m - \tilde d\|^2 = \|Lm - d\|^2 + \varepsilon\|m\|^2. The transpose L~T(r1,r2)=LTr1+ε r2\tilde L^{\mathsf T}(r_1, r_2) = L^{\mathsf T}r_1 + \sqrt{\varepsilon}\, r_2 is the second function returned. The damped problem has exactly one minimizer, the solution of (LTL+εI)m=LTd(L^{\mathsf T}L + \varepsilon I)m = L^{\mathsf T}d, and CGLS on (L~,d~)(\tilde L, \tilde d) reaches it in at most nn passes.

Proof. The first identity is the sum of the squared norms of the two blocks. The transpose of a stacked matrix is the row of the transposes. L~TL~=LTL+εI\tilde L^{\mathsf T}\tilde L = L^{\mathsf T}L + \varepsilon I is positive definite, so the normal equations have one solution and rank⁡(L~)=n\operatorname{rank}(\tilde L) = n; apply Theorem 1. □\square

Lemma 4 (the sparse operator). For the sparse rows of born_kirchhoff_operator, matvec and rmatvec are exact transposes: ⟨matvec(x),y⟩=⟨x,rmatvec(y)⟩\langle \mathrm{matvec}(x), y\rangle = \langle x, \mathrm{rmatvec}(y)\rangle.

Proof. Both sides equal ∑k∑(c,w)∈row kw xc yk\sum_k \sum_{(c, w) \in \text{row } k} w\, x_c\, y_k; rmatvec skips rows with yk=0y_k = 0, which add nothing. □\square

The hypothesis of Theorem 1 that the second operator is the transpose of the first is essential: with an approximate adjoint, the residuals need not decrease. Lemma 4 and the adjoint test of the page check it for the example.

What is not claimed. Theorem 1 is about the misfit ∥Lm−d∥\|Lm - d\|. It does not say that mkm_k approaches the true reflectivity: the true model and the minimum-norm minimizer differ by a null-space component, and noise in dd is fitted too, so in practice the iteration is stopped early or damped (a heuristic choice). The statement that the least-squares image is closer to the true model than the scaled migrated image is a measurement for the example on the page, not a theorem. In floating-point arithmetic the orthogonality of the residuals is lost slowly, so finite termination does not hold exactly.

Complexity

  • Real-ram. Each iteration costs one product with LL (line L5), one with LTL^{\mathsf T} (line L9) and O(n+nd)O(n + n_d) for the vectors. With aa the cost of one product, kk iterations cost O(k(a+n+nd))O(k(a + n + n_d)).
  • In practice. For RTM operators one product costs as much as one migration, so kk iterations cost about 2k2k migrations. This cost is the main barrier to its use.
  • Space. The vectors m,p,sm, p, s of size nn and r,qr, q of size ndn_d, plus what the operators need.

Properties

  • A linear problem, a nonlinear iteration. The problem is linear, because the background velocity is fixed. The result after a fixed number of iterations is not linear in dd, because the step sizes depend on dd.
  • Needs an exact adjoint. CGLS assumes that line L9 is the transpose of line L5. An approximate adjoint breaks the conjugacy and can stop convergence; check it with the dot-product test.
  • Early stopping regularizes. The iteration count acts as a regularization parameter: the first iterations fit the large singular values, and later ones fit noise. This is semi-convergence.
  • Sensitive to the velocity. If the background velocity is wrong, events from different shots do not agree, and LSM fits them with artifacts instead of focusing them.

Variants and improvements

  • Least-squares Kirchhoff migration. LL is a ray-based Born operator and LTL^{\mathsf T} is Kirchhoff migration, as in the test.
  • Least-squares RTM. LL is wave-equation Born modeling and LTL^{\mathsf T} is reverse-time migration, which handles complex velocity at a high cost per iteration.
  • Preconditioning. Scale the image by an illumination estimate or use the Hessian diagonal, which speeds up convergence.
  • Single-iteration approximations. Estimate the inverse Hessian with point spread functions or a matching filter between mm and LTLmL^{\mathsf T}Lm, and apply it to the migrated image without iteration.
  • Sparsity and other priors. Replace the damping by an ℓ1\ell_1 norm in a curvelet or seislet domain and use an iterative shrinkage method.
  • Other Krylov solvers. LSQR gives the same iterates as CGLS in exact arithmetic, with a different recursion based on bidiagonalization.

When to use it

Use LSM when migration artifacts limit the interpretation: uneven illumination below complex overburden, gaps in the acquisition, or a need for amplitudes close to reflection coefficients. Use it only when the background velocity is already good and an exact adjoint pair is available. When the velocity itself is wrong, first improve it with tomography or full-waveform inversion.

Pitfalls

  • An inexact adjoint. Using a migration that is not the exact transpose of the modeling in line L9 makes the method stall or diverge after a few iterations. Build LL and LTL^{\mathsf T} as a pair and run the dot-product test.
  • Too many iterations. With noisy data, the model error goes down and then up while the residual keeps falling. Stop early or add damping.
  • Recomputing the residual. Computing r=d−Lmr = d - Lm from scratch in line L8 costs an extra modeling per iteration; the update r←r−αqr \leftarrow r - \alpha q reuses qq from line L5.
  • Forming the normal matrix. Computing LTLL^{\mathsf T}L as a matrix costs O(n2)O(n^2) memory, which is far too much for seismic images, and squares the condition number of the stored problem. CGLS uses only products with LL and LTL^{\mathsf T} (lines L5 and L9).

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.

least_squares_migration.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/least-squares-migration/. The authors are listed in prov/H0YJBB.jsonl.
"""Least-squares migration (LSM): CGLS on the normal equations of a Born modeling operator.

Conventions (the imaging and inverse problems pages):
- The image m is a reflectivity on a grid, flattened row by row; the data d
  is a zero-offset section, flattened by time sample and then trace.
- The modeling operator L maps m to d. Migration is the adjoint L^T, and
  least-squares migration minimizes ||L m - d||^2 by the conjugate gradient
  method on L^T L m = L^T d (CGLS), with one product by L and one by L^T per
  iteration.
- The example operator is a zero-offset Born-Kirchhoff operator in the
  constant velocity v, with the exploding reflector traveltime
  tau = 2 r / v, r = sqrt(z^2 + (x - x_r)^2), the weight
  (z / r) / sqrt(r) (obliquity and 2D spreading) and a Ricker wavelet.
  It is stored as sparse rows, so L^T is its exact transpose.

Cost per iteration: one product with L and one with L^T, plus O(n + m)
for vectors; for the sparse example that is O(nnz(L)).
"""

import math


def ricker(t, f0):
    """The Ricker wavelet (1 - 2 a) exp(-a) with a = (pi f0 t)^2, peak frequency f0."""
    a = (math.pi * f0 * t) ** 2
    return (1.0 - 2.0 * a) * math.exp(-a)


def born_kirchhoff_operator(nt, dt, nx, dx, nz, dz, z_top, vel, f0, cut=2.5):
    """Sparse rows of the zero-offset Born-Kirchhoff operator in constant velocity.

    Image point (i, j) is at x = j dx, z = z_top + i dz (z_top > 0); column
    i * nx + j. Data row k * nx + r holds time k dt at the trace x_r = r dx.
    The entry is dx * (z / r) / sqrt(r) * ricker(k dt - 2 r / vel, f0), kept
    where |k dt - 2 r / vel| < cut / f0. Returns a list of nt * nx rows of
    (column, weight) pairs.
    """
    rows = [[] for _ in range(nt * nx)]
    half = cut / f0
    for i in range(nz):
        z = z_top + i * dz
        for j in range(nx):
            col = i * nx + j
            for r in range(nx):
                dist = math.hypot(z, (j - r) * dx)
                tau = 2.0 * dist / vel
                w = dx * (z / dist) / math.sqrt(dist)
                k0 = max(0, math.ceil((tau - half) / dt))
                k1 = min(nt - 1, math.floor((tau + half) / dt))
                for k in range(k0, k1 + 1):
                    rows[k * nx + r].append((col, w * ricker(k * dt - tau, f0)))
    return rows


def matvec(rows, x):
    """y = L x for sparse rows."""
    return [sum(w * x[c] for c, w in row) for row in rows]


def rmatvec(rows, y, n):
    """x = L^T y for sparse rows and n columns."""
    out = [0.0] * n
    for row, yi in zip(rows, y):
        if yi != 0.0:
            for c, w in row:
                out[c] += w * yi
    return out


def damped(apply_l, apply_lt, d, n, eps):
    """The operators and data of min ||L m - d||^2 + eps ||m||^2 as one least squares problem.

    The stacked operator is [L; sqrt(eps) I] and the stacked data is [d; 0].
    """
    nd = len(d)
    c = math.sqrt(eps)
    return (lambda x: apply_l(x) + [c * v for v in x],
            lambda r: [a + c * b for a, b in zip(apply_lt(r[:nd]), r[nd:])],
            list(d) + [0.0] * n)


def least_squares_migration(apply_l, apply_lt, d, n, iters):
    """CGLS for min ||L m - d||, started at m = 0.

    apply_l(m) and apply_lt(r) are the modeling and migration operators. Returns
    the image after iters steps and the list of the residual norms ||d - L m_k||.
    For a damped problem, pass the operators and data returned by damped().
    """
    m = [0.0] * n
    r = list(d)  # @line L1
    s = apply_lt(r)  # @line L2
    p = list(s)
    gamma = sum(v * v for v in s)
    norms = [math.sqrt(sum(v * v for v in r))]
    for _ in range(iters):  # @line L3
        if gamma == 0.0:  # @line L4
            break
        q = apply_l(p)  # @line L5
        alpha = gamma / sum(v * v for v in q)  # @line L6
        m = [a + alpha * b for a, b in zip(m, p)]  # @line L7
        r = [a - alpha * b for a, b in zip(r, q)]  # @line L8
        s = apply_lt(r)  # @line L9
        gnew = sum(v * v for v in s)
        p = [a + (gnew / gamma) * b for a, b in zip(s, p)]  # @line L10
        gamma = gnew
        norms.append(math.sqrt(sum(v * v for v in r)))
    return m, norms  # @line L11
test_least_squares_migration.py 96 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/least-squares-migration/. The authors are listed in prov/H0YJBB.jsonl.
import math
import random
import unittest

from least_squares_migration import born_kirchhoff_operator, damped, least_squares_migration, matvec, rmatvec

NT, DT, NXG, DX, NZ, DZ, ZTOP, VEL, F0 = 40, 0.004, 10, 10.0, 8, 10.0, 40.0, 2000.0, 30.0
N = NXG * NZ


def operator():
    rows = born_kirchhoff_operator(NT, DT, NXG, DX, NZ, DZ, ZTOP, VEL, F0)
    return rows, (lambda x: matvec(rows, x)), (lambda y: rmatvec(rows, y, N))


def true_model():
    m = [0.0] * N
    m[2 * NXG + 3] = 1.0
    m[5 * NXG + 6] = -0.5
    for j in range(NXG):
        m[6 * NXG + j] += 0.3
    return m


def solve_dense(a, b):
    """Gaussian elimination with partial pivoting, an independent reference."""
    n = len(b)
    a = [row[:] + [b[i]] for i, row in enumerate(a)]
    for c in range(n):
        p = max(range(c, n), key=lambda r: abs(a[r][c]))
        a[c], a[p] = a[p], a[c]
        for r in range(c + 1, n):
            f = a[r][c] / a[c][c]
            if f != 0.0:
                for k in range(c, n + 1):
                    a[r][k] -= f * a[c][k]
    x = [0.0] * n
    for r in range(n - 1, -1, -1):
        x[r] = (a[r][n] - sum(a[r][k] * x[k] for k in range(r + 1, n))) / a[r][r]
    return x


def dist(a, b):
    return math.sqrt(sum((x - y) ** 2 for x, y in zip(a, b)))


class TestLeastSquaresMigration(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.rows, lop, ltop = operator()
        cls.lop, cls.ltop = staticmethod(lop), staticmethod(ltop)
        cls.m_true = true_model()
        cls.d = cls.lop(cls.m_true)

    def test_adjoint(self):
        rng = random.Random(1)
        x = [rng.gauss(0, 1) for _ in range(N)]
        y = [rng.gauss(0, 1) for _ in range(NT * NXG)]
        left = sum(a * b for a, b in zip(self.lop(x), y))
        right = sum(a * b for a, b in zip(x, self.ltop(y)))
        self.assertLess(abs(left - right), 1e-12 * abs(left))

    def test_residual_does_not_increase(self):
        _, norms = least_squares_migration(self.lop, self.ltop, self.d, N, 25)
        for a, b in zip(norms, norms[1:]):
            self.assertLessEqual(b, a * (1.0 + 1e-12))
        self.assertLess(norms[-1], 0.05 * norms[0])

    def test_damped_matches_direct_solve(self):
        cols = [[0.0] * NT * NXG for _ in range(N)]
        for k, row in enumerate(self.rows):
            for c, w in row:
                cols[c][k] += w
        ata = [[sum(a * b for a, b in zip(cols[i], cols[j])) for j in range(N)] for i in range(N)]
        eps = 0.1 * max(ata[i][i] for i in range(N))
        for i in range(N):
            ata[i][i] += eps
        ref = solve_dense(ata, self.ltop(self.d))
        lop, ltop, dd = damped(self.lop, self.ltop, self.d, N, eps)
        m, _ = least_squares_migration(lop, ltop, dd, N, 60)
        self.assertLess(dist(m, ref), 1e-6 * math.sqrt(sum(v * v for v in ref)))

    def test_better_than_scaled_migration(self):
        mig = self.ltop(self.d)
        lmig = self.lop(mig)
        alpha = sum(a * b for a, b in zip(lmig, self.d)) / sum(a * a for a in lmig)
        scaled = [alpha * v for v in mig]
        m, _ = least_squares_migration(self.lop, self.ltop, self.d, N, 25)
        ref = math.sqrt(sum(v * v for v in self.m_true))
        self.assertLess(dist(m, self.m_true) / ref, 0.8 * dist(scaled, self.m_true) / ref)


if __name__ == "__main__":
    unittest.main()

History

Lailly (1983) and Tarantola (1984) showed that migration of the data residuals is the gradient of a least-squares misfit, so migration is the first step of an inversion. Least-squares Kirchhoff migration was studied in the 1990s; Nemeth, Wu and Schuster (1999) showed that it reduces the migration artifacts that incomplete data cause. With more computing power, least-squares RTM in the 2010s brought the method to complex velocity models.

References

  1. Tamas Nemeth, Chengjun Wu and Gerard T. Schuster, Least-squares migration of incomplete reflection data, Geophysics 64(1), 1999, 208 to 221, migration as the adjoint of a Kirchhoff modeling operator and its least-squares inversion by conjugate gradients
  2. Albert Tarantola, Inversion of seismic reflection data in the acoustic approximation, Geophysics 49(8), 1984, 1259 to 1266, the gradient of the least-squares misfit as a migration of the residuals
  3. Magnus R. Hestenes and Eduard Stiefel, Methods of conjugate gradients for solving linear systems, Journal of Research of the National Bureau of Standards 49(6), 1952, 409 to 436, the conjugate gradient method and its form for least-squares problems through the normal equations

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.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.per_iteration
  • a full proof of time.total
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example