Seismic Wave Tomography via Fast Marching#

Open In Colab

If you are running this notebook locally, make sure you’ve followed steps here to set up the environment. (This environment.yml file specifies a list of packages required to run the notebooks)

In this notebook, we use cofi to run a seismic wave tomography example, in which the forward calculation is based on the Fast Marching Fortran code by Nick Rawlinson. The Fast Marching code is wrapped in package cofi_espresso.

Theoretical background#

The goal in travel-time tomography is to infer details about the velocity structure of a medium, given measurements of the minimum time taken for a wave to propagate from source to receiver. For seismic travel times, as we change our model, the route of the fastest path from source to receiver also changes. This makes the problem nonlinear, as raypaths also depend on the sought after velocity or slowness model.

Provided the ‘true’ velocity structure is not too dissimilar from our initial guess, travel-time tomography can be treated as a weakly non-linear problem. In this notebook we optionally treat the ray paths as fixed, and so it becomes a linear problem, or calculate rays in the velociuty model.

The travel-time of an individual ray can be computed as

\[t = \int_\mathrm{path} \frac{1}{v(\mathbf{x})}\,\mathrm{d}\mathbf{x}\]

This points to an additional complication: even for a fixed path, the relationship between velocities and observations is not linear. However, if we define the ‘slowness’ to be the inverse of velocity, \(s(\mathbf{x}) = v^{-1}(\mathbf{x})\), we can write

\[t = \int_\mathrm{path} {s(\mathbf{x})}\,\mathrm{d}\mathbf{x}\]

which is linear.

We will assume that the object we are interested in is 2-dimensional slowness field. If we discretize this model, with \(N_x\) cells in the \(x\)-direction and \(N_y\) cells in the \(y\)-direction, we can express \(s(\mathbf{x})\) as an \(N_x \times N_y\) vector \(\boldsymbol{s}\).

For the linear case, this is related to the data by

\[d_i = A_{ij}s_j\]

where \(d_i\) is the travel time of the ith path, and where \(A_{ij}\) represents the path length in cell \(j\) of the discretized model.

For the nonlinear case, this is related to the data by

\[\delta d_i = A_{ij}\delta s_j\]

where \(\delta d_i\) is the difference in travel time, of the ith path, between the observed time and the travel time in the reference model. Here \(A_{ij}\) represents the path length in cell \(j\) of the discretized model. The parameters \(\delta s_j\) are slowness perturbations to the reference model.

In this notebook we form and solve a travel time tomography problem using model damping and 2nd derivative smoothing. For forward modelling, a fast marching wave front tracker is used, utilizing the Fast Marching Fortran code within the package `FMTOMO <>`__ by Nick Rawlinson.

0. Import modules#

# -------------------------------------------------------- #
#                                                          #
#     Uncomment below to set up environment on "colab"     #
#                                                          #
# -------------------------------------------------------- #

# !pip install -U cofi cofi-espresso
import numpy as np
import matplotlib.pyplot as plt
import pprint

import cofi
import cofi_espresso

Problem setup#

Before we starting working with cofi, let’s get familiar with the problem itself.

Below is a plot of the true model and the paths generated from this model. As you can see, there are two anomalies, one with lower velocity (red, top left) and the other with higher velocity (blue, bottom right).

fmm = cofi_espresso.FmmTomography()

fmm.plot_model(fmm.good_model, with_paths=True);
fmm tomography
 New data set has:
 10  receivers
 10  sources
 100  travel times
 Range of travel times:  0.008911182496368759 0.0153757024856463
 Mean travel time: 0.01085811731230709

<Figure size 600x600 with 2 Axes>
{'author_names': ['Nick Rawlinson', 'Malcolm Sambridge'],
 'citations': [('Rawlinson, N., de Kool, M. and Sambridge, M., 2006. Seismic '
                'wavefront tracking in 3-D heterogeneous media: applications '
                'with multiple data classes, Explor. Geophys., 37, 322-330.',
               ('Rawlinson, N. and Urvoy, M., 2006. Simultaneous inversion of '
                'active and passive source datasets for 3-D seismic structure '
                'with application to Tasmania, Geophys. Res. Lett., 33 L24313',
               ('de Kool, M., Rawlinson, N. and Sambridge, M. 2006. A '
                'practical grid based method for tracking multiple refraction '
                'and reflection phases in 3D heterogeneous media, Geophys. J. '
                'Int., 167, 253-270',
 'contact_email': '',
 'contact_name': 'Malcolm Sambridge',
 'linked_sites': [('Software published on iEarth',
 'problem_short_description': 'The wave front tracker routines solves boundary '
                              'value ray tracing problems into 2D '
                              'heterogeneous wavespeed media, defined by '
                              'continuously varying velocity model calculated '
                              'by 2D cubic B-splines.',
 'problem_title': 'Fast Marching Wave Front Tracking'}

1. Define the problem#

# get problem information from  espresso FmmTomography
model_size = fmm.model_size         # number of model parameters
model_shape = fmm.model_shape       # 2D spatial grids
data_size = fmm.data_size           # number of data points
ref_start_slowness = fmm.starting_model
# define CoFI BaseProblem
fmm_problem = cofi.BaseProblem()
# add regularization: damping + smoothing
damping_factor = 50
smoothing_factor = 5e3
reg_damping = cofi.utils.QuadraticReg(damping_factor, model_size, "damping", ref_start_slowness)
reg_smoothing = cofi.utils.QuadraticReg(smoothing_factor, model_shape, "smoothing")
reg = reg_damping + reg_smoothing
def objective_func(slowness, reg, sigma, reduce_data=None):  # reduce_data=(idx_from, idx_to)
    if reduce_data is None: idx_from, idx_to = (0, fmm.data_size)
    else: idx_from, idx_to = reduce_data
    ttimes = fmm.forward(slowness)
    residual =[idx_from:idx_to] - ttimes[idx_from:idx_to]
    data_misfit = residual.T @ residual / sigma**2
    model_reg = reg(slowness)
    return  data_misfit + model_reg
def gradient(slowness, reg, sigma, reduce_data=None):       # reduce_data=(idx_from, idx_to)
    if reduce_data is None: idx_from, idx_to = (0, fmm.data_size)
    else: idx_from, idx_to = reduce_data
    ttimes, A = fmm.forward(slowness, with_jacobian=True)
    ttimes = ttimes[idx_from:idx_to]
    A = A[idx_from:idx_to]
    data_misfit_grad = -2 * A.T @ ([idx_from:idx_to] - ttimes) / sigma**2
    model_reg_grad = reg.gradient(slowness)
    return  data_misfit_grad + model_reg_grad
def hessian(slowness, reg, sigma, reduce_data=None):        # reduce_data=(idx_from, idx_to)
    if reduce_data is None: idx_from, idx_to = (0, fmm.data_size)
    else: idx_from, idx_to = reduce_data
    A = fmm.jacobian(slowness)[idx_from:idx_to]
    data_misfit_hess = 2 * A.T @ A / sigma**2
    model_reg_hess = reg.hessian(slowness)
    return data_misfit_hess + model_reg_hess
sigma =  0.00001                   # Noise is 1.0E-4 is ~5% of standard deviation of initial travel time residuals

fmm_problem.set_objective(objective_func, args=[reg, sigma, None])
fmm_problem.set_gradient(gradient, args=[reg, sigma, None])
fmm_problem.set_hessian(hessian, args=[reg, sigma, None])

Review what information is included in the BaseProblem object:

Summary for inversion problem: BaseProblem
Model shape: (1536,)
List of functions/properties set by you:
['objective', 'gradient', 'hessian', 'initial_model', 'model_shape']
List of functions/properties created based on what you have provided:
List of functions/properties that can be further set for the problem:
( not all of these may be relevant to your inversion workflow )
['log_posterior', 'log_posterior_with_blobs', 'log_likelihood', 'log_prior', 'hessian_times_vector', 'residual', 'jacobian', 'jacobian_times_vector', 'data_misfit', 'regularization', 'regularization_matrix', 'regularization_factor', 'forward', 'data', 'data_covariance', 'data_covariance_inv', 'blobs_dtype', 'bounds', 'constraints']

2. Define the inversion options#

my_options = cofi.InversionOptions()

# cofi's own simple newton's matrix-based optimization solver
my_options.set_params(num_iterations=6, step_length=1, verbose=True)

Review what’s been defined for the inversion we are about to run:

Summary for inversion options
Solving method: None set
Use `suggest_solving_methods()` to check available solving methods.
Backend tool: `cofi.simple_newton` - CoFI's own solver - simple Newton's approach (for testing mainly)
References: ['']
Use `suggest_tools()` to check available backend tools.
Solver-specific parameters:
num_iterations = 6
step_length = 1
verbose = True
Use `suggest_solver_params()` to check required/optional solver-specific parameters.

3. Start an inversion#

inv = cofi.Inversion(fmm_problem, my_options)
inv_result =
Iteration #0, objective function value: 110298.7001724638
Iteration #1, objective function value: 1787.1051514815424
Iteration #2, objective function value: 121.1495033985667
Iteration #3, objective function value: 5.814222496115815
Iteration #4, objective function value: 4.086694560516768
Iteration #5, objective function value: 1.6665887726105881
Summary for inversion result
model: [0.00048375 0.00048181 0.00048015 ... 0.00050722 0.00050676 0.00050618]
num_iterations: 5
objective_val: 2.98668774544954
n_obj_evaluations: 6
n_grad_evaluations: 6
n_hess_evaluations: 6

4. Plotting#

fmm.plot_model(inv_result.model);            # inverted model
fmm.plot_model(fmm.good_model);       # true model
  • fmm tomography
  • fmm tomography
<Figure size 600x600 with 2 Axes>


watermark_list = ["cofi", "cofi_espresso", "numpy", "matplotlib"]
for pkg in watermark_list:
    pkg_var = __import__(pkg)
    print(pkg, getattr(pkg_var, "__version__"))
cofi 0.1.2.dev22
cofi_espresso 0.0.1.dev10
numpy 1.21.6
matplotlib 3.5.3

sphinx_gallery_thumbnail_number = -1

Total running time of the script: ( 0 minutes 9.712 seconds)

Gallery generated by Sphinx-Gallery