Add horizontal_tilt_angle function and tests#562
Open
ErosKerouak wants to merge 6 commits into
Open
Conversation
Implements the computation of the total horizontal derivative (THDR) of a potential field grid. This function calculates the square root of the sum of squares of the horizontal derivatives in the easting and northing directions.
Includes tests for: - Agreement with a synthetic model - Rejection of 1D and 3D grids - Handling of grids containing NaN values Ensures correctness and robustness of the total_horizontal_gradient filter.
Implements the theta map filter. The function computes the arctangent of the horizontal gradient magnitude over the total gradient amplitude. Includes a detailed docstring with formula and references.
Includes: - Validation against synthetic model using finite differences and FFT - Input error handling for 1D, 3D, and NaN-containing grids - Integration of theta_map import for test discovery
Implements the horizontal tilt angle (HTA) filter, which computes the arctangent of the horizontal gradient magnitude over the absolute value of the upward derivative. Includes a full docstring with LaTeX formula and reference.
Includes: - Validation against synthetic model - Input error handling for 1D, 3D, and NaN-filled grids
|
The Actions logs for the failing The failures are concentrated around the new A minimal patch is: diff --git a/harmonica/_transformations.py b/harmonica/_transformations.py
@@
"""
Apply transformations to regular grids of potential fields
"""
+
import numpy as np
@@
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
+ (horizontal) directions. The horizontal derivatives are calculated though
finite-differences.
@@
- order: *northing*, *easting*. The coordinates must be defined in the same units.
+ order: *northing*, *easting*. The coordinates must be defined in the
+ same units.
@@
- A :class:`xarray.DataArray` containing the total horizontal derivative of
- the input ``grid``.
+ A :class:`xarray.DataArray` containing the total horizontal derivative
+ of the input ``grid``.
@@
horizontal_gradient = (
derivative_easting(grid, order=1),
- derivative_northing(grid, order=1)
+ derivative_northing(grid, order=1),
)
@@
horiz_deriv = np.sqrt(gradient[0] ** 2 + gradient[1] ** 2)
return np.arctan2(horiz_deriv, total_gradient)
+
def horizontal_tilt_angle(grid):
@@
- horizontal gradient magnitude and the absolute value of the upward derivative.
+ horizontal gradient magnitude and the absolute value of the upward
+ derivative.
@@
-
-
def _get_dataarray_coordinate(grid, dimension_index):
diff --git a/harmonica/tests/test_transformations.py b/harmonica/tests/test_transformations.py
@@
"""
Test functions for regular grid transformations
"""
+
from pathlib import Path
@@
derivative_upward,
gaussian_highpass,
gaussian_lowpass,
+ horizontal_tilt_angle,
reduction_to_pole,
- tilt_angle,
theta_map,
- horizontal_tilt_angle,
+ tilt_angle,
@@
- def test_against_synthetic(
- self, sample_potential, sample_g_n, sample_g_e
- ):
+ def test_against_synthetic(self, sample_potential, sample_g_n, sample_g_e):
@@
with pytest.raises(ValueError, match="Found nan"):
theta_map(sample_potential)
+
class TestHorizontalTiltAngle:
@@
- Check if horizontal_tilt_angle raises error on grid with single dimension
+ Check if horizontal_tilt_angle raises error on grid with single
+ dimension
@@
- Check if horizontal_tilt_angle raises error on grid with three dimensions
+ Check if horizontal_tilt_angle raises error on grid with three
+ dimensions
@@
-
class Testfilter:Verified locally on the changed files: isort --check harmonica/_transformations.py harmonica/tests/test_transformations.py
flake8 harmonica/_transformations.py harmonica/tests/test_transformations.py
black --check harmonica/_transformations.py harmonica/tests/test_transformations.py
git diff --checkI couldn't run the new tests in this local environment because |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds the
horizontal_tilt_anglefunction toharmonica._transformations.The horizontal tilt angle is a enhancement filter used in gravity and magnetic interpretation. It computes the arctangent of the horizontal gradient magnitude over the absolute value of the upward derivative.
Summary of changes:
horizontal_tilt_anglefunction with full docstring and LaTeX formulaRelevant issues/PRs:
Closes #559
Related to #560, #561