Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 9 additions & 3 deletions tests/run_tests/sensitivity_cutoff_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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