Algorithm Search⌘K

Algorithmcore

Semblance velocity analysis

Also called velocity spectrum, semblance.

Scan trial stacking velocities over a common-midpoint gather, measure the semblance (normalized stack energy) along each hyperbola in a time window, and pick the velocities of the peaks.

Time
O(n k m w) worst · average · best
Space
O(n k) extra
Where
k = the number of trial velocities; m = the number of traces in the gather; n = the number of scanned zero-offset times; w = the number of samples in the window
Properties
deterministicscale invariant
Origin
N. S. Neidell, M. Turhan Taner, 1971

Semblance velocity analysis finds the stacking velocity of the reflections in a common-midpoint gather. For each zero-offset time and each trial velocity it reads the traces along the hyperbola of normal moveout and measures how alike they are with the semblance, a number between 0 and 1. The table of semblance over time and velocity is the velocity spectrum. Its peaks give the velocities that flatten the reflections, which common-midpoint stacking needs, and which the Dix formula converts to interval velocities.

In plain words

A reflection in a gather lies on a curve whose bend depends on the speed of sound in the rock. Guess a speed, follow the curve that this speed predicts, and look at the traces along it. If the guess is right, the traces show the same wiggle at the same time, and adding them gives a big result. If the guess is wrong, the wiggles do not line up and partly cancel. Semblance turns this into a score from 0 to 1: the energy of the sum, divided by what the sum would have if all traces agreed perfectly. Try many speeds at many times and draw the scores as a map. Bright spots on the map mark the reflections and their speeds.

The problem

Input: a gather of mm traces did_i with offsets xix_i and sample interval Δt\Delta t; a list of trial velocities v1,…,vkv_1, \ldots, v_k; a half window WW in samples; the times to scan. Output: the velocity spectrum S(t0,v)S(t_0, v), and for each time of interest the velocity of the largest peak. For one window and one velocity, with ai(τ)=di(τ2+xi2/v2)a_i(\tau) = d_i\big(\sqrt{\tau^2 + x_i^2/v^2}\big),

S(t0,v)=∑τ(∑i=1mai(τ))2m∑τ∑i=1mai(τ)2,S(t_0, v) = \frac{\sum_{\tau} \big(\sum_{i=1}^{m} a_i(\tau)\big)^2}{m \sum_{\tau} \sum_{i=1}^{m} a_i(\tau)^2},

where τ\tau runs over the w=2W+1w = 2W + 1 samples of the window centered at t0t_0.

The algorithm

  1. VELOCITY-SPECTRUM(d, x, Δt, v_1..v_k, W, times)
  2. 1for each zero-offset index j in times do
  3. 2row_j ← [SEMBLANCE(d, x, Δt, j, v_ℓ, W) for ℓ ← 1 to k]
  4. SEMBLANCE(d, x, Δt, j, v, W)
  5. 3A ← 0; B ← 0
  6. 4for τ ← j - W to j + W do
  7. 5a_i ← d_i at time sqrt((τ Δt)² + x_i² / v²) for every trace i ▷ linear interpolation
  8. 6A ← A + (Σ_i a_i)²; B ← B + Σ_i a_i²
  9. 7return A / (m B), or 0 if B = 0
  10. 8return the rows; pick the v_ℓ with the largest value in each row

The window WW smooths the measure over a few samples, about half a period of the wavelet, so that a zero crossing of the wavelet does not make the score jump. The scan does not change the data: it is a search over a grid of velocities, one stack per pair. The pick is a separate step, done by a person or an automatic picker, and it can follow the strongest peak or a smooth velocity trend.

Example

A hand example. One window holds two time samples and three traces: (1,1,1)(1, 1, 1) at the first time and (2,2,0)(2, 2, 0) at the second. Then A=32+42=25A = 3^2 + 4^2 = 25, B=3+8=11B = 3 + 8 = 11, and S=25/(3⋅11)=0.758S = 25/(3 \cdot 11) = 0.758. The first row alone gives S=1S = 1, because its traces agree. A window where only one of three traces is live gives S=1/3S = 1/3.

A gather with two reflections. Take 16 traces at offsets 0 to 1500 m every 100 m, Δt=4\Delta t = 4 ms, and two reflections with a 25 Hz Ricker wavelet: amplitude 1 at t0=0.4t_0 = 0.4 s with v=1900v = 1900 m/s, and amplitude −1-1 at t0=0.9t_0 = 0.9 s with v=2600v = 2600 m/s. Add Gaussian noise with σ=0.4\sigma = 0.4 (seed 6). Scan vv from 1500 to 3100 m/s in steps of 50 m/s with W=5W = 5:

vv (m/s) 1700 1800 1900 2000 2300 2500 2600 2700 2900
SS at 0.4 s 0.049 0.101 0.683 0.108 0.098 0.055 0.051 0.153 0.084
SS at 0.9 s 0.072 0.146 0.064 0.074 0.140 0.460 0.764 0.518 0.207

The peaks are at 1900 and 2600 m/s, the true values. The noise level 1/m=0.06251/m = 0.0625 is the floor of the spectrum. The peak at 0.9 s is wider in velocity, because the moveout of a deep, fast reflection changes slowly with vv: the velocity resolution falls with depth. Without noise the peaks are 0.877 and 0.993; the first is lower because the stretch of the shallow event at far offsets makes the traces differ next to the peak.

Correctness

By the Cauchy-Schwarz inequality, (∑iai)2≤m∑iai2(\sum_i a_i)^2 \le m \sum_i a_i^2 at each time, so 0≤S≤10 \le S \le 1, with S=1S = 1 exactly when all traces agree at every time of the window after the moveout with vv. One live trace gives S=1/mS = 1/m, and for independent noise of equal variance the expected numerator over the expected denominator is 1/m1/m. SS does not change when all traces are scaled by the same factor. These are theorems about the measure. That the peak of SS is at the best stacking velocity is a heuristic: it holds when the event is a hyperbola with that velocity, the noise is weaker than the event, and no other event crosses the window. The proofs are in proofs/correctness.md.

Proof: Semblance lies between 0 and 1, equals 1 exactly when the moveout-corrected traces agree in the window, equals 1/N for one live trace, and has expected numerator over expected denominator 1/N for independent noisefull

Setting. A gather has NN traces with offsets xix_i. For a zero-offset index jj, a trial velocity vv and a half window WW, lines L4 and L5 read the samples ai(k)=di((k Δt)2+xi2/v2)a_i(k) = d_i\big(\sqrt{(k\,\Delta t)^2 + x_i^2/v^2}\big) for k=j−W,…,j+Wk = j - W, \ldots, j + W (by linear interpolation; 00 outside the record). Lines L3 and L6 accumulate

A=∑k(∑iai(k))2,B=∑k∑iai(k)2,A = \sum_k \Big(\sum_i a_i(k)\Big)^2, \qquad B = \sum_k \sum_i a_i(k)^2,

and line L7 returns S=A/(NB)S = A/(N B), or 00 when B=0B = 0. The window and the velocity are fixed in each claim.

Claim 1 (bounds). 0≤S≤10 \le S \le 1.

Proof. A≥0A \ge 0 and B≥0B \ge 0 as sums of squares. If B=0B = 0, line L7 returns 00. Otherwise, for each kk the Cauchy-Schwarz inequality for the vectors (a1(k),…,aN(k))(a_1(k), \ldots, a_N(k)) and (1,…,1)(1, \ldots, 1) gives (∑iai(k))2≤N∑iai(k)2\big(\sum_i a_i(k)\big)^2 \le N \sum_i a_i(k)^2. Summing over kk gives A≤NBA \le N B, so S≤1S \le 1. □\square

Claim 2 (when S=1S = 1). If B>0B > 0, then S=1S = 1 if and only if, at every time kk of the window, all NN samples ai(k)a_i(k) are equal.

Proof. S=1S = 1 means A=NBA = N B, that is ∑k(N∑iai(k)2−(∑iai(k))2)=0\sum_k \big(N \sum_i a_i(k)^2 - (\sum_i a_i(k))^2\big) = 0. Each term is at least 00 by Claim 1, so each term is 00. Equality in Cauchy-Schwarz holds exactly when (ai(k))i(a_i(k))_i is a multiple of (1,…,1)(1, \ldots, 1), that is when all ai(k)a_i(k) are equal for that kk. □\square

So S=1S = 1 means that the moveout correction with vv made the traces identical in the window. For a reflection on the hyperbola of velocity vv the peak lines up on all traces (Claim 2 of the NMO proof), but the NMO stretch makes the far traces wider, so the samples next to the peak differ a little and SS is close to, not equal to, 1.

Claim 3 (one live trace). If exactly one trace is not zero in the window, then S=1/NS = 1/N. If the samples at each time have opposite values in pairs (for example N=2N = 2 and a2(k)=−a1(k)a_2(k) = -a_1(k)), then S=0S = 0.

Proof. With only trace pp live, ∑iai(k)=ap(k)\sum_i a_i(k) = a_p(k), so A=∑kap(k)2=BA = \sum_k a_p(k)^2 = B and S=1/NS = 1/N. With a2=−a1a_2 = -a_1 and N=2N = 2 the sums ∑iai(k)\sum_i a_i(k) are all 00, so A=0A = 0 and S=0S = 0 when B>0B > 0; line L7 returns 00 also when B=0B = 0. □\square

Claim 4 (scale invariance). Multiplying all samples by the same c≠0c \ne 0 does not change SS.

Proof. AA and BB both get the factor c2c^2. □\square

A scale that differs from trace to trace does change SS, so a gather with strong amplitude decay with offset has a lower semblance than the same gather after gain.

Claim 5 (independent noise). If the ai(k)a_i(k) are independent random variables with mean 00 and the same variance σ2>0\sigma^2 > 0, then EA/(N EB)=1/N\mathbb{E} A / (N\,\mathbb{E} B) = 1/N.

Proof. For each kk, E(∑iai(k))2=∑iEai(k)2+∑i≠i′Eai(k) Eai′(k)=Nσ2\mathbb{E}\big(\sum_i a_i(k)\big)^2 = \sum_i \mathbb{E} a_i(k)^2 + \sum_{i \ne i'} \mathbb{E} a_i(k)\,\mathbb{E} a_{i'}(k) = N\sigma^2, and E∑iai(k)2=Nσ2\mathbb{E} \sum_i a_i(k)^2 = N\sigma^2. With L=2W+1L = 2W + 1 window samples, EA=LNσ2\mathbb{E} A = L N \sigma^2 and EB=LNσ2\mathbb{E} B = L N \sigma^2. □\square

The claim is about the ratio of the expectations; the mean of the ratio SS is close to 1/N1/N when the window is long, which the tests measure. So 1/N1/N is the level of pure noise, and a peak well above it marks coherent energy.

Claim 6 (the scan). Lines L1, L2 and L8 return the matrix S[j][ℓ]S[j][\ell] with one entry for each scanned time jj and each trial velocity vℓv_\ell, each computed as above. With ntn_t times, nvn_v velocities, NN traces and a window of LL samples, the cost is O(nt nv NL)O(n_t\, n_v\, N L).

Proof. The double loop calls the semblance once for each pair (j,ℓ)(j, \ell). Each call reads NLN L samples, each with a square root and an interpolation of fixed cost, and does O(NL)O(N L) additions and multiplications. □\square

Complexity

In the real-RAM model each semblance value reads mwm w samples, so the spectrum costs O(nkmw)O(n k m w) for nn times and kk velocities. The sums over the window can be updated in O(m)O(m) as the window slides, which removes the factor ww when all times are scanned. The spectrum needs O(nk)O(n k) space. In practice it is computed on a coarse grid of midpoints, for example every 20th to 50th gather, and the velocities are interpolated in between.

Properties

  • The output is between 0 and 1 and does not depend on the overall amplitude, so spectra of different gathers and times can be compared.
  • The noise floor is about 1/m1/m.
  • Velocity resolution is a heuristic matter: it gets worse with depth (small moveout) and with a short spread (small largest offset), and better with high frequencies.
  • Multiples show as peaks at lower velocities than the primaries at the same time.

Variants and improvements

  • Other coherence measures: the plain stack amplitude or power, the normalized or unnormalized cross-correlation sum (Neidell and Taner 1971 compare them).
  • AB semblance and weighted semblance: they allow the amplitude to change with offset, so that a reflection whose polarity changes with offset still gives a peak.
  • High-resolution spectra based on eigenvalues of the data covariance in the window, in the spirit of high-resolution array processing.
  • Higher-order or anisotropic moveout: scan two parameters, the velocity and a nonhyperbolic term.
  • Automatic picking along a smooth trend, by dynamic programming over the spectrum.

When to use it

Use it to build the stacking velocity field before CMP stacking, and as the first velocity model for time migration and for the Dix conversion to interval velocities. It assumes hyperbolic moveout, so it is suited to reflections from gentle structures.

Pitfalls

  • A peak of a multiple can be picked as a primary, which gives too low a velocity. Follow the expected increase of velocity with depth.
  • Velocities picked at the peak are stacking velocities. They equal rms velocities only for flat layers and small offsets, and Dix conversion amplifies their errors.
  • A window much longer than the wavelet mixes events; a window much shorter makes the spectrum noisy.
  • Strong amplitude decay with offset lowers the semblance of a good velocity; apply a gain first.
  • The velocity grid must be fine enough to sample the peak; a step of 50 m/s on a peak a few hundred m/s wide is enough, a step of 200 m/s may miss it.

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.

semblance_velocity_analysis.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/semblance-velocity-analysis/. The authors are listed in prov/8B18AH.jsonl.
"""Semblance velocity analysis of a common-midpoint gather.

The gather is a list of N traces with offsets x_i, sampled at k * dt. For a
zero-offset time index j and a trial velocity v, the samples a_i(k) are read
along the hyperbola t = sqrt((k dt)^2 + x_i^2 / v^2) for k in a window
j - W .. j + W, and the semblance is

    S = sum_k (sum_i a_i(k))^2 / (N sum_k sum_i a_i(k)^2),

a number between 0 and 1 (0 when the window holds no energy).
"""

import math


def _interp(trace, dt, t):
    n = len(trace)
    u = t / dt
    if n < 2 or u < 0.0 or u > n - 1:
        return 0.0
    k = min(int(math.floor(u)), n - 2)
    f = u - k
    return (1.0 - f) * trace[k] + f * trace[k + 1]


def semblance_of_window(rows):
    """S for a window given as rows a[k][i] (time k, trace i)."""
    num = 0.0
    den = 0.0
    n = 0
    for row in rows:
        n = len(row)
        s = sum(row)
        num += s * s
        den += sum(a * a for a in row)
    if den == 0.0:
        return 0.0
    return num / (n * den)


def semblance(gather, offsets, dt, j, v, half_window):
    """The semblance at zero-offset index j and velocity v, window j - W .. j + W."""
    num = 0.0  # @line L3
    den = 0.0
    for k in range(j - half_window, j + half_window + 1):  # @line L4
        t0 = k * dt
        a = [_interp(tr, dt, math.sqrt(t0 * t0 + (x / v) ** 2)) if k >= 0 else 0.0
             for tr, x in zip(gather, offsets)]  # @line L5
        s = sum(a)  # @line L6
        num += s * s
        den += sum(ai * ai for ai in a)
    if den == 0.0:  # @line L7
        return 0.0
    return num / (len(gather) * den)


def velocity_spectrum(gather, offsets, dt, velocities, half_window, times=None):
    """S[j][m] for every zero-offset index j in times (default all) and velocities[m]."""
    n = len(gather[0])
    idx = range(n) if times is None else times
    spec = []
    for j in idx:  # @line L1
        spec.append([semblance(gather, offsets, dt, j, v, half_window) for v in velocities])  # @line L2
    return spec  # @line L8


def pick_velocity(row, velocities):
    """The trial velocity with the largest semblance in one row of the spectrum."""
    m = max(range(len(row)), key=lambda i: row[i])
    return velocities[m]
test_semblance_velocity_analysis.py 116 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/semblance-velocity-analysis/. The authors are listed in prov/8B18AH.jsonl.

import math
import random

from semblance_velocity_analysis import (
    pick_velocity,
    semblance,
    semblance_of_window,
    velocity_spectrum,
)


def ricker(t, f=25.0):
    a = (math.pi * f * t) ** 2
    return (1.0 - 2.0 * a) * math.exp(-a)


def gather_with_events(events, offsets, dt, n, rng=None, sigma=0.0):
    out = []
    for x in offsets:
        tr = [0.0] * n
        for t0, v, amp in events:
            tx = math.sqrt(t0 * t0 + (x / v) ** 2)
            for k in range(n):
                tr[k] += amp * ricker(k * dt - tx)
        if rng is not None:
            tr = [a + rng.gauss(0.0, sigma) for a in tr]
        out.append(tr)
    return out


def test_bounds_on_random_windows():
    rng = random.Random(1)
    for _ in range(200):
        n_tr = rng.randint(1, 10)
        rows = [[rng.gauss(0.0, 1.0) for _ in range(n_tr)] for _ in range(rng.randint(1, 8))]
        s = semblance_of_window(rows)
        assert -1e-15 <= s <= 1.0 + 1e-12


def test_equal_traces_give_one():
    rng = random.Random(2)
    row_vals = [rng.gauss(0.0, 1.0) for _ in range(9)]
    rows = [[v] * 6 for v in row_vals]
    assert abs(semblance_of_window(rows) - 1.0) < 1e-12


def test_one_live_trace_gives_one_over_n():
    rng = random.Random(3)
    rows = [[rng.gauss(0.0, 1.0)] + [0.0] * 4 for _ in range(7)]
    assert abs(semblance_of_window(rows) - 0.2) < 1e-12


def test_opposite_polarity_gives_zero():
    rows = [[v, -v] for v in (0.3, -1.2, 2.0)]
    assert semblance_of_window(rows) == 0.0
    assert semblance_of_window([[0.0, 0.0]]) == 0.0


def test_scale_invariance():
    rng = random.Random(4)
    rows = [[rng.gauss(0.0, 1.0) for _ in range(5)] for _ in range(4)]
    s1 = semblance_of_window(rows)
    s2 = semblance_of_window([[-3.5 * a for a in r] for r in rows])
    assert abs(s1 - s2) < 1e-12


def test_matches_the_definition_by_brute_force():
    rng = random.Random(5)
    dt, n = 0.004, 120
    offsets = [0.0, 150.0, 300.0, 450.0, 600.0]
    gather = [[rng.gauss(0.0, 1.0) for _ in range(n)] for _ in offsets]
    j, v, w = 60, 2100.0, 4
    rows = []
    for k in range(j - w, j + w + 1):
        row = []
        for tr, x in zip(gather, offsets):
            t = math.sqrt((k * dt) ** 2 + (x / v) ** 2)
            u = t / dt
            i0 = int(math.floor(u))
            f = u - i0
            row.append((1 - f) * tr[i0] + f * tr[i0 + 1])
        rows.append(row)
    assert abs(semblance(gather, offsets, dt, j, v, w) - semblance_of_window(rows)) < 1e-12


def test_flat_event_at_the_right_velocity_gives_one():
    dt, n = 0.004, 250
    offsets = [0.0] * 6
    gather = gather_with_events([(0.5, 2000.0, 1.0)], offsets, dt, n)
    assert abs(semblance(gather, offsets, dt, 125, 2000.0, 5) - 1.0) < 1e-12


def test_picks_the_true_velocity_in_noise():
    rng = random.Random(6)
    dt, n = 0.004, 300
    offsets = [100.0 * i for i in range(16)]
    events = [(0.4, 1900.0, 1.0), (0.9, 2600.0, -1.0)]
    gather = gather_with_events(events, offsets, dt, n, rng, sigma=0.4)
    vels = [1500.0 + 50.0 * m for m in range(33)]
    spec = velocity_spectrum(gather, offsets, dt, vels, 5, times=[100, 225])
    assert abs(pick_velocity(spec[0], vels) - 1900.0) <= 50.0
    assert abs(pick_velocity(spec[1], vels) - 2600.0) <= 100.0
    assert max(spec[0]) > 0.5


def test_pure_noise_gives_about_one_over_n():
    rng = random.Random(7)
    n_tr, n = 8, 600
    offsets = [0.0] * n_tr
    gather = [[rng.gauss(0.0, 1.0) for _ in range(n)] for _ in range(n_tr)]
    vals = [semblance(gather, offsets, 0.004, j, 2000.0, 5) for j in range(10, n - 10, 11)]
    mean = sum(vals) / len(vals)
    assert abs(mean - 1.0 / n_tr) < 0.03

History

Taner and Koehler (1969) computed velocity spectra by digital stacks along trial hyperbolas and used them to pick stacking velocities. Neidell and Taner (1971) defined semblance and compared it with the stack amplitude and the cross-correlation measures; semblance became the standard measure of velocity analysis in seismic processing.

References

  1. N. S. Neidell and M. Turhan Taner, Semblance and other coherency measures for multichannel data, Geophysics 36(3), 1971, 482 to 497, the definition of semblance as a ratio of output to input energy and its comparison with other coherence measures
  2. M. Turhan Taner and Fulton Koehler, Velocity spectra, digital computer derivation and applications of velocity functions, Geophysics 34(6), 1969, 859 to 881, velocity spectra from stacks along trial hyperbolas, and their use for picking stacking velocities
  3. Oz Yilmaz, Seismic Data Analysis, Society of Exploration Geophysicists, 2001, Investigations in Geophysics 10, the chapter on velocity analysis and statics corrections (velocity spectra, semblance, velocity picking)

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.average
  • a full proof of time.best
  • a full proof of time.worst
  • 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