Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 177 additions & 0 deletions harmonica/_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,58 @@ def reduction_to_pole(
)


def total_horizontal_gradient(grid):
r"""
Calculate the total horizontal derivative of a potential field grid.

Compute the amplitude of the horizontal gradient of a regular gridded
potential field `M`. This is a measure of the rate of change in the x and y
(horizontal) directions. . The horizontal derivatives are calculated though
finite-differences.

Parameters
----------
grid : :class:`xarray.DataArray`
A two-dimensional :class:`xarray.DataArray` whose coordinates are
evenly spaced (regular grid). Its dimensions should be in the following
order: *northing*, *easting*. The coordinates must be defined in the same units.

Returns
-------
horizontal_derivative_grid : :class:`xarray.DataArray`
A :class:`xarray.DataArray` containing the total horizontal derivative of
the input ``grid``.

Notes
-----
The total horizontal derivative is calculated as:

.. math::

A(x, y) = \sqrt{
\left( \frac{\partial M}{\partial x} \right)^2
+ \left( \frac{\partial M}{\partial y} \right)^2
}

where :math:`M` is the regularly gridded potential field.

References
----------
[Blakely1995]_
[CordellGrauch1985]_
"""

# Run sanity checks on the grid
grid_sanity_checks(grid)
# Calculate the horizontal gradients of the grid
horizontal_gradient = (
derivative_easting(grid, order=1),
derivative_northing(grid, order=1)
)
# return the total horizontal gradient
return np.sqrt(horizontal_gradient[0] ** 2 + horizontal_gradient[1] ** 2)


def total_gradient_amplitude(grid):
r"""
Calculates the total gradient amplitude of a potential field grid
Expand Down Expand Up @@ -455,6 +507,131 @@ def tilt_angle(grid):
return tilt


def theta_map(grid):
r"""
Calculate the theta map of a potential field grid

Compute the theta map of a regularly gridded potential field
:math:`M`, used to enhance edges in gravity and magnetic data.
The horizontal and vertical derivatives are calculated from the
input grid, and the theta angle is defined as the arctangent
of the ratio between the total horizontal derivative and the
total gradient amplitude.

Parameters
----------
grid : :class:`xarray.DataArray`
A two-dimensional :class:`xarray.DataArray` whose coordinates are
evenly spaced (regular grid). Its dimensions should be in the following
order: *northing*, *easting*. Its coordinates should be defined in the
same units.

Returns
-------
theta_grid : :class:`xarray.DataArray`
A :class:`xarray.DataArray` with the calculated theta angle
in radians.

Notes
-----
The theta angle is calculated as:

.. math::

\theta(M) = \tan^{-1} \left(
\frac{
\sqrt{
\left( \frac{\partial M}{\partial x} \right)^2 +
\left( \frac{\partial M}{\partial y} \right)^2
}
}{
\sqrt{
\left( \frac{\partial M}{\partial x} \right)^2 +
\left( \frac{\partial M}{\partial y} \right)^2 +
\left( \frac{\partial M}{\partial z} \right)^2
}
}
\right)

where :math:`M` is the regularly gridded potential field.

References
----------
[Wijns et al., 2005]_
"""
# Run sanity checks on the grid
grid_sanity_checks(grid)
# Calculate the gradients of the grid
gradient = (
derivative_easting(grid, order=1),
derivative_northing(grid, order=1),
derivative_upward(grid, order=1),
)
# Calculate and return the theta map
total_gradient = np.sqrt(gradient[0] ** 2 + gradient[1] ** 2 + gradient[2] ** 2)
horiz_deriv = np.sqrt(gradient[0] ** 2 + gradient[1] ** 2)
return np.arctan2(horiz_deriv, total_gradient)

def horizontal_tilt_angle(grid):
r"""
Calculate the horizontal tilt angle of a potential field grid

Compute the horizontal tilt angle of a regularly gridded potential field
:math:`M`. This filter computing the arctangent of the ratio between the
horizontal gradient magnitude and the absolute value of the upward derivative.

Parameters
----------
grid : :class:`xarray.DataArray`
A two-dimensional :class:`xarray.DataArray` whose coordinates are
evenly spaced (regular grid). Its dimensions should be in the following
order: *northing*, *easting*. Its coordinates should be defined in the
same units.

Returns
-------
horiz_tilt_grid : :class:`xarray.DataArray`
A :class:`xarray.DataArray` with the calculated horizontal tilt angle
in radians.

Notes
-----
The horizontal tilt angle is calculated as:

.. math::

\text{HTA}(M) = \tan^{-1} \left(
\frac{
\sqrt{
\left( \frac{\partial M}{\partial x} \right)^2 +
\left( \frac{\partial M}{\partial y} \right)^2
}
}{
\left| \frac{\partial M}{\partial z} \right|
}
\right)

where :math:`M` is the regularly gridded potential field.

References
----------
[Cooper & Cowan, 2006]_
"""
# Run sanity checks on the grid
grid_sanity_checks(grid)
# Calculate the gradients of the grid
gradient = (
derivative_easting(grid, order=1),
derivative_northing(grid, order=1),
derivative_upward(grid, order=1),
)
# Calculate and return the horizontal tilt angle
horiz_deriv = np.sqrt(gradient[0] ** 2 + gradient[1] ** 2)
return np.arctan2(horiz_deriv, np.abs(gradient[2]))




def _get_dataarray_coordinate(grid, dimension_index):
"""
Return the name of the easting or northing coordinate in the grid
Expand Down
Loading
Loading