Skip to content

Commit 99d91f1

Browse files
authored
Merge pull request #573 from Beramos/BDJ_fix_dips
Fix incorrect dips check in `slope_estimation
2 parents 7b8727a + 3bd3386 commit 99d91f1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

pylops/utils/signalprocessing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def slope_estimate(
246246
regdata = l1 > eps
247247
anisos[regdata] = 1 - l2[regdata] / l1[regdata]
248248

249-
if not dips:
249+
if dips:
250250
slopes = 0.5 * np.arctan2(2 * gzx, gzz - gxx)
251251
else:
252252
regdata = np.abs(gzx) > eps

pytests/test_signalutils.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from numpy.testing import assert_array_almost_equal
44

5-
from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx
5+
from pylops.utils.signalprocessing import convmtx, nonstationary_convmtx, slope_estimate
66

77
par1 = {"nt": 51, "nh": 7, "imag": 0, "dtype": "float32"} # odd sign, odd filt, real
88
par1j = {
@@ -90,3 +90,18 @@ def test_nonstationary_convmtx(par):
9090
y = np.dot(H[: par["nt"]], x)
9191
y1 = np.dot(H1, x)
9292
assert_array_almost_equal(y, y1, decimal=4)
93+
94+
95+
def test_slope_estimation_dips():
96+
"""Slope estimation using the Structure tensor algorithm should
97+
apply regularisation (some slopes are set to zero)
98+
while dips should not use regularisation."""
99+
100+
img_test = np.identity(20) # generate test with -45° angle
101+
eps = 0.09 # set a regularisation parameter that will be exceeded
102+
103+
slopes, _ = slope_estimate(img_test, dips=False, eps=eps)
104+
slopes_dips, _ = slope_estimate(img_test, dips=True, eps=eps)
105+
106+
assert np.any(np.isclose(slopes, 0.0))
107+
assert not np.any(np.isclose(slopes_dips, 0.0))

0 commit comments

Comments
 (0)