diff --git a/simpeg_drivers/depth_of_investigation/sensitivity_cutoff/driver.py b/simpeg_drivers/depth_of_investigation/sensitivity_cutoff/driver.py index ecbd176c7..72e7930a1 100644 --- a/simpeg_drivers/depth_of_investigation/sensitivity_cutoff/driver.py +++ b/simpeg_drivers/depth_of_investigation/sensitivity_cutoff/driver.py @@ -64,8 +64,8 @@ def lower_percent_mask(data: np.ndarray, cutoff: float, logspace=False) -> np.nd if logspace: data[data == 0] = np.nan data = np.log10(data) - data -= np.nanmin(data) + data -= np.nanmin(data) scaled_data = data * 100 / np.nanmax(data) mask = scaled_data > cutoff diff --git a/tests/run_tests/sensitivity_cutoff_test.py b/tests/run_tests/sensitivity_cutoff_test.py index 084a472f2..6c0d13313 100644 --- a/tests/run_tests/sensitivity_cutoff_test.py +++ b/tests/run_tests/sensitivity_cutoff_test.py @@ -55,6 +55,12 @@ def setup_inversion_results( {"gz": {"values": np.random.randn(len(components.survey.vertices))}} ) + # Shift some vertices to avoid 0 sensititives + verts = components.survey.vertices + verts[:, 2] += np.arange(len(verts)) + + components.survey.vertices = verts + params = GravityInversionOptions.build( geoh5=geoh5, mesh=components.mesh, @@ -110,7 +116,7 @@ def test_sensitivity_percent_cutoff_run(tmp_path): SensitivityCutoffDriver.start(str(tmp_path / "sensitivity_cutoff_percent.ui.json")) with Workspace(tmp_path / "inversion_test.ui.geoh5") as geoh5: mask = geoh5.get_entity("5 percent cutoff")[0] - assert mask.values.sum() == 1355 + assert mask.values.sum() == 2546 def test_sensitivity_cutoff_percentile_run(tmp_path): @@ -138,7 +144,7 @@ def test_sensitivity_cutoff_percentile_run(tmp_path): ) with Workspace(tmp_path / "inversion_test.ui.geoh5") as geoh5: mask = geoh5.get_entity("5 percentile cutoff")[0] - assert mask.values.sum() == 22861 + assert mask.values.sum() == 22962 def test_sensitivity_cutoff_log_percent_run(tmp_path): @@ -166,4 +172,4 @@ def test_sensitivity_cutoff_log_percent_run(tmp_path): ) with Workspace(tmp_path / "inversion_test.ui.geoh5") as geoh5: mask = geoh5.get_entity("5 percent log cutoff")[0] - assert mask.values.sum() == 23144 + assert mask.values.sum() == 23178