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
6 changes: 4 additions & 2 deletions simpeg_drivers/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,10 @@ def uncertainties(self) -> dict[str, dict[float, np.ndarray | None]]:
for k in self.active_components:
out[k] = self.component_uncertainty(k)

for data in out[k].values():
if np.any(np.isnan(data)) or np.any(data < 0):
for uncert, data in zip(
out[k].values(), self.component_data(k).values(), strict=True
):
if np.any((np.isnan(uncert) | (uncert < 0)) & ~np.isnan(data)):
Comment on lines +635 to +638
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Na, we know they always have the same lenght

flags.append(f"{k} component")
break

Expand Down
14 changes: 13 additions & 1 deletion tests/run_tests/driver_mt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,23 @@ def test_bad_uncertainties(
topography = components.topography
data_kwargs = setup_data(geoh5, survey)

for elem in ["uncertainty_zxx_imag_[0]", "uncertainty_zyx_real_[0]"]:
# Add NDV to some uncertainties
for elem in [
"uncertainty_zxx_imag_[0]",
"uncertainty_zyx_real_[0]",
"uncertainty_zyx_imag_[0]",
]:
data = survey.get_entity(elem)[0]
vals = data.values
vals[0] = np.nan
data.values = vals

# Also NDV the data for one of them
data = survey.get_entity("Iteration_0_zyx_imag_[0]")[0]
vals = data.values
vals[0] = np.nan
data.values = vals

# Run the inverse
params = MTInversionOptions.build(
geoh5=geoh5,
Expand All @@ -184,6 +195,7 @@ def test_bad_uncertainties(

assert "zxx_imag" in str(error.value)
assert "zyx_real" in str(error.value)
assert "zyx_imag" not in str(error.value)


def test_magnetotellurics_run(tmp_path: Path, max_iterations=1, pytest=True):
Expand Down
Loading