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
17 changes: 4 additions & 13 deletions simpeg_drivers/potential_fields/magnetic_vector/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

from pathlib import Path
from typing import ClassVar
from warnings import warn

from geoh5py.data import FloatData
from geoh5py.ui_json.annotations import Deprecated
from pydantic import model_validator

from simpeg_drivers import assets_path
Expand Down Expand Up @@ -129,19 +129,10 @@ class MVIInversionOptions(BaseInversionOptions):
inducing_field_strength: float | FloatData = 50000.0
inducing_field_inclination: float | FloatData = 90.0
inducing_field_declination: float | FloatData = 0.0

lower_bound: Deprecated | None = None

starting_inclination: float | FloatData | None = None
starting_declination: float | FloatData | None = None
reference_inclination: float | FloatData | None = None
reference_declination: float | FloatData | None = None

@model_validator(mode="after")
def validate_lower_bound(self):
if self.lower_bound is not None:
warn(
"Parameter 'lower_bound' for Magnetic Vector Inversion has been deprecated. "
"Defaulting to the negative value of 'upper_bound'.",
DeprecationWarning,
stacklevel=1,
)
self.lower_bound = None
return self
9 changes: 5 additions & 4 deletions tests/run_tests/driver_mvi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from __future__ import annotations

import logging
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -165,6 +166,7 @@ def test_magnetic_vector_run(

def test_magnetic_vector_bounds_run(
tmp_path: Path,
caplog,
max_iterations=4,
pytest=True,
):
Expand All @@ -185,10 +187,7 @@ def test_magnetic_vector_bounds_run(

# Run the inverse
active_cells = ActiveCellsOptions(topography_object=topography)
with warns(
DeprecationWarning,
match="Parameter 'lower_bound' for Magnetic Vector Inversion",
):
with caplog.at_level(logging.WARNING):
params = MVIInversionOptions(
geoh5=geoh5,
mesh=mesh,
Expand Down Expand Up @@ -216,6 +215,8 @@ def test_magnetic_vector_bounds_run(
)
params.write_ui_json(path=tmp_path / "Inv_run.ui.json")

assert "Skipping deprecated field: lower_bound" in caplog.text

driver = MVIInversionDriver(params)
assert np.all(driver.models.lower_bound == -upper_bound)

Expand Down
Loading