Skip to content

Commit

Permalink
Merge pull request #573 from Beramos/BDJ_fix_dips
Browse files Browse the repository at this point in the history
Fix incorrect dips check in `slope_estimation
  • Loading branch information
mrava87 committed Mar 17, 2024
2 parents 7b8727a + 3bd3386 commit 99d91f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pylops/utils/signalprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def slope_estimate(
regdata = l1 > eps
anisos[regdata] = 1 - l2[regdata] / l1[regdata]

if not dips:
if dips:
slopes = 0.5 * np.arctan2(2 * gzx, gzz - gxx)
else:
regdata = np.abs(gzx) > eps
Expand Down
17 changes: 16 additions & 1 deletion pytests/test_signalutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from numpy.testing import assert_array_almost_equal

from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx
from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx, slope_estimate

par1 = {"nt": 51, "nh": 7, "imag": 0, "dtype": "float32"} # odd sign, odd filt, real
par1j = {
Expand Down Expand Up @@ -90,3 +90,18 @@ def test_nonstationary_convmtx(par):
y = np.dot(H[: par["nt"]], x)
y1 = np.dot(H1, x)
assert_array_almost_equal(y, y1, decimal=4)


def test_slope_estimation_dips():
"""Slope estimation using the Structure tensor algorithm should
apply regularisation (some slopes are set to zero)
while dips should not use regularisation."""

img_test = np.identity(20) # generate test with -45° angle
eps = 0.09 # set a regularisation parameter that will be exceeded

slopes, _ = slope_estimate(img_test, dips=False, eps=eps)
slopes_dips, _ = slope_estimate(img_test, dips=True, eps=eps)

assert np.any(np.isclose(slopes, 0.0))
assert not np.any(np.isclose(slopes_dips, 0.0))

0 comments on commit 99d91f1

Please sign in to comment.