2D epicenter determination (fatiando.seismic.epic2d)

Epicenter determination in 2D, i.e., assuming a flat Earth.

There are solvers for the following approximations.

Homogeneous Earth

Estimates the (x, y) cartesian coordinates of the epicenter based on travel-time residuals between S and P waves, assuming a homogeneous velocity distribution.

class fatiando.seismic.epic2d.Homogeneous(ttres, recs, vp, vs)[source]

Bases: fatiando.inversion.misfit.Misfit

Estimate the epicenter assuming a homogeneous Earth.


  • ttres
    : array

    Travel-time residuals between S and P waves

  • recs
    : list of lists

    List with the (x, y) coordinates of the receivers

  • vp
    : float

    Assumed velocity of P waves

  • vs
    : float

    Assumed velocity of S waves


The recommended solver for this inverse problem is the Levemberg-Marquardt method. Since this is a non-linear problem, set the desired method and initial solution using the config method. See the example bellow.


Using synthetic data.

>>> from fatiando.mesher import Square
>>> from fatiando.seismic import ttime2d
>>> # Generate synthetic travel-time residuals
>>> area = (0, 10, 0, 10)
>>> vp = 2
>>> vs = 1
>>> model = [Square(area, props={'vp':vp, 'vs':vs})]
>>> # The true source (epicenter)
>>> src = (5, 5)
>>> recs = [(5, 0), (5, 10), (10, 0)]
>>> srcs = [src, src, src]
>>> #The travel-time residual between P and S waves
>>> ptime = ttime2d.straight(model, 'vp', srcs, recs)
>>> stime = ttime2d.straight(model, 'vs', srcs, recs)
>>> ttres = stime - ptime
>>> # Pass the data to the solver class
>>> solver = Homogeneous(ttres, recs, vp, vs).config('levmarq',
...                                                  initial=[1, 1])
>>> # Estimate the epicenter
>>> x, y = solver.fit().estimate_
>>> print "(%.4f, %.4f)" % (x, y)
(5.0000, 5.0000)


The travel-time residual measured by the ith receiver is a function of the (x, y) coordinates of the epicenter:

\[t_{S_i} - t_{P_i} = \Delta t_i (x, y) = \left(\frac{1}{V_S} - \frac{1}{V_P} \right) \sqrt{(x_i - x)^2 + (y_i - y)^2}\]

The elements \(G_{i1}\) and \(G_{i2}\) of the Jacobian matrix for this data type are

\[G_{i1}(x, y) = -\left(\frac{1}{V_S} - \frac{1}{V_P} \right) \frac{x_i - x}{\sqrt{(x_i - x)^2 + (y_i - y)^2}}\]
\[G_{i2}(x, y) = -\left(\frac{1}{V_S} - \frac{1}{V_P} \right) \frac{y_i - y}{\sqrt{(x_i - x)^2 + (y_i - y)^2}}\]

The Hessian matrix is approximated by \(2\bar{\bar{G}}^T\bar{\bar{G}}\) (Gauss-Newton method).

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_.


Called when accessing the property estimate_.

Use this to convert the parameter vector (p) to a more useful form, like a geometric object, etc.


  • p
    : 1d-array

    The parameter vector.


  • formatted

    Pretty much anything you want.


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


Calculate the Jacobian matrix for the inversion.


Calculate the predicted travel time data given a parameter vector.


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.