The fatiando package has been deprecated. Please check out the new tools in the Fatiando a Terra website:

Straigh-ray 2D tomography with SrTomo (fatiando.seismic.srtomo)

Straight-ray 2D travel-time tomography (i.e., does not consider reflection or refraction)


  • SRTomo: Data misfit class that runs the tomography.


  • slowness2vel: Safely convert slowness to velocity (avoids zero division)

class fatiando.seismic.srtomo.SRTomo(ttimes, srcs, recs, mesh)[source]

Bases: fatiando.inversion.misfit.Misfit

2D travel-time straight-ray tomography.

Use the fit method to run the tomography and produce a velocity estimate. The estimate is stored in the estimate_ attribute.

Generaly requires regularization, like Damping or Smoothness2D.


  • ttimes
    : array

    Array with the travel-times of the straight seismic rays.

  • srcs
    : list of lists

    List of the [x, y] positions of the sources.

  • recs
    : list of lists

    List of the [x, y] positions of the receivers.

  • mesh
    : SquareMesh or compatible

    The mesh where the inversion (tomography) will take place.

The ith travel-time is the time between the ith element in srcs and the ith element in recs.

config(method, **kwargs)

Configure the optimization method and its parameters.

This sets the method used by fit and the keyword arguments that are passed to it.


  • method
    : string

    The optimization method. One of: 'linear', 'newton', 'levmarq', 'steepest', 'acor'

Other keyword arguments that can be passed are the ones allowed by each method.

Some methods have required arguments:

  • newton, levmarq and steepest require the initial argument (an initial estimate for the gradient descent)
  • acor requires the bounds argument (min/max values for the search space)

See the corresponding docstrings for more information:


Make a copy of me together with all the cached methods.


A nicely formatted version of the estimate.

If the class implements a fmt_estimate method, this will its results. This can be used to convert the parameter vector to a more useful form, like a fatiando.mesher object.


Solve for the parameter vector that minimizes this objective function.

Uses the optimization method and parameters defined using the config method.

The estimated parameter vector can be accessed through the p_ attribute. A (possibly) formatted version (converted to a more manageable type) of the estimate can be accessed through the property estimate_.


Convert the estimated slowness to velocity.


The gradient vector of the misfit function.

\[\bar{g} = -2\bar{\bar{J}}^T\bar{r}\]

where \(\bar{\bar{J}}\) is the Jacobian matrix and \(\bar{r}\) is the residual vector.


  • p
    : 1d-array

    The parameter vector where the gradient is evaluated


  • gradient
    : 1d-array

    The gradient vector.


The Hessian of the misfit function with respect to the parameters.

Calculated using the Gauss approximation:

\[\bar{\bar{H}} \approx 2\bar{\bar{J}}^T\bar{\bar{J}}\]

where \(\bar{\bar{J}}\) is the Jacobian matrix.

For linear problems, the Hessian matrix is cached in memory, so calling this method again will not trigger a re-calculation.


  • p
    : 1d-array

    The parameter vector where the Hessian is evaluated


  • hessian
    : 2d-array

    The Hessian matrix


Build the Jacobian (sensitivity) matrix.

The matrix will contain the length of the path takes by the ray inside each cell of the mesh.


  • p
    : 1d-array

    An estimate of the parameter vector or None.


  • jac
    : 2d-array (sparse CSR matrix from scipy.sparse)

    The Jacobian


Calculate the travel time data predicted by a parameter vector.


  • p
    : 1d-array

    An estimate of the parameter vector


  • pred
    : 1d-array

    The predicted travel time data.


The regularization parameter (scale factor) for the objetive function.

Defaults to 1.


Calculate the residuals vector (observed - predicted data).


  • p
    : 1d-array or None

    The parameter vector used to calculate the residuals. If None, will use the current estimate stored in estimate_.


  • residuals
    : 1d-array or list of 1d-arrays

    The residual vector. If this is the sum of 1 or more Misfit instances, will return the residual vector from each of the summed misfits in the order of the sum.


Set the data weights.

Using weights for the data, the least-squares data-misfit function becomes:

\[\phi = \bar{r}^T \bar{\bar{W}}\bar{r}\]


  • weights
    : 1d-array or 2d-array or None

    Weights for the data vector. If None, will remove any weights that have been set before. If it is a 2d-array, it will be interpreted as the weight matrix \(\bar{\bar{W}}\). If it is a 1d-array, it will be interpreted as the diagonal of the weight matrix (all off-diagonal elements will default to zero). The weight matrix can be a sparse array from scipy.sparse.


Calculate the value of the misfit for a given parameter vector.

The value is given by:

\[\phi(\bar{p}) = \bar{r}^T\bar{\bar{W}}\bar{r}\]

where \(\bar{r}\) is the residual vector and \(bar{\bar{W}}\) are optional data weights.


  • p
    : 1d-array or None

    The parameter vector.


  • value
    : float

    The value of the misfit function.

fatiando.seismic.srtomo.slowness2vel(slowness, tol=1e-08)[source]

Safely convert slowness to velocity.

Almost 0 slowness is mapped to 0 velocity.


  • slowness
    : array

    The slowness values

  • tol
    : float

    Slowness < tol will be set to 0 velocity


  • velocity
    : array

    The converted velocities


>>> import numpy as np
>>> slow = np.array([1, 2, 0.000001, 4])
>>> slowness2vel(slow, tol=0.00001)
array([ 1.  ,  0.5 ,  0.  ,  0.25])