seisflows.tools.math

Mathematical tools for Seisflows

Module Contents

Functions

angle(x, y)

Determine the angle between two vectors using dot products

dot(x, y)

Calculate the dot product between two vectors

hilbert(w)

Take the Hilbert transform of some function to get the analytic signal

poissons_ratio(vp, vs)

Calculate Poisson's Ratio based on the definition given in the Specfem3D

parabolic_backtrack(f0, g0, x1, f1[, b1, b2])

Safeguarded parabolic backtracking function

gaussian(x, y, mu, sigma[, normalize])

Evaluates Gaussian over points of X, Y

polynomial_fit(x, f)

Least squares (polynomial) line fitting used to fit a line to the

lsq2(x, f)

Parabolic least squares fit

nabla(V[, h])

Finite Differences

nabla2(V[, h])

Finite Differences

grad(V[, h])

Finite Differences

tv(Z[, h, epsilon])

Finite Differences

seisflows.tools.math.angle(x, y)

Determine the angle between two vectors using dot products

Parameters
  • x (np.array) – vector 1

  • y (np.array) – vector 2

Return type

float

Returns

the angle in degrees between x and y

seisflows.tools.math.dot(x, y)

Calculate the dot product between two vectors

Parameters
  • x (np.array) – vector 1

  • y (np.array) – vector 2

Return type

float

Returns

The dot product between x and y

seisflows.tools.math.hilbert(w)

Take the Hilbert transform of some function to get the analytic signal

TODO Change the naming here, it seems confusing to rename a scipy function TODO and then overwrite its name with this function.

Parameters

w (np.array) – signal data, must be real

Return type

float

Returns

imaginary part of the analytic signal

seisflows.tools.math.poissons_ratio(vp, vs)

Calculate Poisson’s Ratio based on the definition given in the Specfem3D source code

Parameters
  • vp (float or np.array) – P-wave velocity

  • vs (float or np.array) – S-wave velocity

Return type

float or np.array

Returns

Poissons ratio

seisflows.tools.math.parabolic_backtrack(f0, g0, x1, f1, b1=0.1, b2=0.5)

Safeguarded parabolic backtracking function Equation provided in Nocedal & Wright, 2006 ??

Parameters
  • f0 (float) – initial misfit function value

  • g0 (float) – slope

  • x1 (float) – step length value

  • f1 (float) – current misfit function value (?)

  • b1 (float) – constant for safeguard

  • b2 (float) – constant for safeguard

Return type

float

Returns

trial step length (alpha)

seisflows.tools.math.gaussian(x, y, mu, sigma, normalize=True)

Evaluates Gaussian over points of X, Y

Parameters
  • x (np.ndarray) – x-axis to evaluate gaussian over

  • y (np.ndarray) – y-axis to evaluate gaussian over

  • mu – expected value

  • sigma – standard deviation

  • normalize (bool) – normalize the results

seisflows.tools.math.polynomial_fit(x, f)

Least squares (polynomial) line fitting used to fit a line to the objective function.

Parameters
  • x (np.array) – trial step lengths

  • f (np.array) – misfit values

Return type

float

Returns

trial step length (alpha)

seisflows.tools.math.lsq2(x, f)

Parabolic least squares fit

Parameters
  • x (np.array) – x coordinates

  • f (np.array) – y coordinates

seisflows.tools.math.nabla(V, h=[])

Finite Differences

Returns sum of first-order spatial derivatives of a function defined on a 2D rectangular grid; generalizes Laplacian

seisflows.tools.math.nabla2(V, h=[])

Finite Differences

Returns sum of second-order spatial derivatives of a function defined on a 2D rectangular grid; generalizes Laplacian

seisflows.tools.math.grad(V, h=[])

Finite Differences

Evaluates derivatives on a 2D rectangular grid

seisflows.tools.math.tv(Z, h=[], epsilon=1e-06)

Finite Differences