diff --git a/simpeg_drivers-assets/uijson/apparent_conductivity_inversion.ui.json b/simpeg_drivers-assets/uijson/apparent_conductivity_inversion.ui.json index 949ae31f..a6c3cc23 100644 --- a/simpeg_drivers-assets/uijson/apparent_conductivity_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/apparent_conductivity_inversion.ui.json @@ -281,6 +281,14 @@ "value": "", "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components." }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/borehole_tdem_inversion.ui.json b/simpeg_drivers-assets/uijson/borehole_tdem_inversion.ui.json index 80b40d27..073c3052 100644 --- a/simpeg_drivers-assets/uijson/borehole_tdem_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/borehole_tdem_inversion.ui.json @@ -358,6 +358,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "enabled": false }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": "Float", diff --git a/simpeg_drivers-assets/uijson/direct_current_2d_inversion.ui.json b/simpeg_drivers-assets/uijson/direct_current_2d_inversion.ui.json index eb418ed5..5688b8b1 100644 --- a/simpeg_drivers-assets/uijson/direct_current_2d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/direct_current_2d_inversion.ui.json @@ -316,6 +316,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/direct_current_3d_inversion.ui.json b/simpeg_drivers-assets/uijson/direct_current_3d_inversion.ui.json index 2f6d2b31..afb094ec 100644 --- a/simpeg_drivers-assets/uijson/direct_current_3d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/direct_current_3d_inversion.ui.json @@ -279,6 +279,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/fdem1d_inversion.ui.json b/simpeg_drivers-assets/uijson/fdem1d_inversion.ui.json index 4783e753..93021901 100644 --- a/simpeg_drivers-assets/uijson/fdem1d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/fdem1d_inversion.ui.json @@ -314,6 +314,14 @@ "property": "", "enabled": true }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "gradient_rotation": "", "s_norm": { "association": "Cell", diff --git a/simpeg_drivers-assets/uijson/fdem_inversion.ui.json b/simpeg_drivers-assets/uijson/fdem_inversion.ui.json index cf113bdb..73032864 100644 --- a/simpeg_drivers-assets/uijson/fdem_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/fdem_inversion.ui.json @@ -347,6 +347,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/gravity_inversion.ui.json b/simpeg_drivers-assets/uijson/gravity_inversion.ui.json index 2d9c5786..fdcc5fd1 100644 --- a/simpeg_drivers-assets/uijson/gravity_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/gravity_inversion.ui.json @@ -545,6 +545,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/induced_polarization_2d_inversion.ui.json b/simpeg_drivers-assets/uijson/induced_polarization_2d_inversion.ui.json index 46190dc3..8b01d0f4 100644 --- a/simpeg_drivers-assets/uijson/induced_polarization_2d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/induced_polarization_2d_inversion.ui.json @@ -330,6 +330,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/induced_polarization_3d_inversion.ui.json b/simpeg_drivers-assets/uijson/induced_polarization_3d_inversion.ui.json index 445dbca4..499f76d3 100644 --- a/simpeg_drivers-assets/uijson/induced_polarization_3d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/induced_polarization_3d_inversion.ui.json @@ -299,6 +299,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/joint_cross_gradient_inversion.ui.json b/simpeg_drivers-assets/uijson/joint_cross_gradient_inversion.ui.json index 18ea3cbc..2f8a9b6a 100644 --- a/simpeg_drivers-assets/uijson/joint_cross_gradient_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/joint_cross_gradient_inversion.ui.json @@ -243,6 +243,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "min": 0.0, "max": 2.0, diff --git a/simpeg_drivers-assets/uijson/joint_petrophysics_inversion.ui.json b/simpeg_drivers-assets/uijson/joint_petrophysics_inversion.ui.json index 9612de76..e8bea3c8 100644 --- a/simpeg_drivers-assets/uijson/joint_petrophysics_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/joint_petrophysics_inversion.ui.json @@ -189,6 +189,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "min": 0.0, "max": 2.0, diff --git a/simpeg_drivers-assets/uijson/joint_surveys_inversion.ui.json b/simpeg_drivers-assets/uijson/joint_surveys_inversion.ui.json index 22790db9..3df4c714 100644 --- a/simpeg_drivers-assets/uijson/joint_surveys_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/joint_surveys_inversion.ui.json @@ -281,6 +281,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/magnetic_scalar_inversion.ui.json b/simpeg_drivers-assets/uijson/magnetic_scalar_inversion.ui.json index 80c8a0cc..7c8404ea 100644 --- a/simpeg_drivers-assets/uijson/magnetic_scalar_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/magnetic_scalar_inversion.ui.json @@ -576,6 +576,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/magnetic_vector_inversion.ui.json b/simpeg_drivers-assets/uijson/magnetic_vector_inversion.ui.json index 0fb5348d..23154702 100644 --- a/simpeg_drivers-assets/uijson/magnetic_vector_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/magnetic_vector_inversion.ui.json @@ -633,6 +633,14 @@ "parent": "mesh", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/magnetic_vector_pde_inversion.ui.json b/simpeg_drivers-assets/uijson/magnetic_vector_pde_inversion.ui.json index 48d60666..9865b672 100644 --- a/simpeg_drivers-assets/uijson/magnetic_vector_pde_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/magnetic_vector_pde_inversion.ui.json @@ -415,6 +415,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/magnetotellurics_inversion.ui.json b/simpeg_drivers-assets/uijson/magnetotellurics_inversion.ui.json index f32681c1..e1adeb5f 100644 --- a/simpeg_drivers-assets/uijson/magnetotellurics_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/magnetotellurics_inversion.ui.json @@ -495,6 +495,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/tdem1d_inversion.ui.json b/simpeg_drivers-assets/uijson/tdem1d_inversion.ui.json index a3efe754..4e56b787 100644 --- a/simpeg_drivers-assets/uijson/tdem1d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/tdem1d_inversion.ui.json @@ -287,6 +287,14 @@ "property": "", "enabled": true }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "gradient_rotation": "", "s_norm": { "association": "Cell", diff --git a/simpeg_drivers-assets/uijson/tdem_inversion.ui.json b/simpeg_drivers-assets/uijson/tdem_inversion.ui.json index 45271cbc..d1503386 100644 --- a/simpeg_drivers-assets/uijson/tdem_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/tdem_inversion.ui.json @@ -392,6 +392,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "enabled": false }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers-assets/uijson/tipper_inversion.ui.json b/simpeg_drivers-assets/uijson/tipper_inversion.ui.json index 759d14b3..bf9584e1 100644 --- a/simpeg_drivers-assets/uijson/tipper_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/tipper_inversion.ui.json @@ -375,6 +375,14 @@ "tooltip": "Rotate the gradient of the regularization to align with a provided structural orientation.\nThe data should be provided as a data group in the form of either strike & dip, dip direction & dip, or x/y/z components.", "value": "" }, + "reference_model_in_smooth": { + "group": "Regularization", + "label": "Reference model in smoothness", + "value": false, + "verbose": 3, + "visible": true, + "tooltip": "Whether to subtract the reference model before computing the smoothness terms (x, y and z). \nThis is useful for preserving sharp contrasts from a reference model" + }, "s_norm": { "association": "Cell", "dataType": [ diff --git a/simpeg_drivers/driver.py b/simpeg_drivers/driver.py index 42d1a52e..88b19c55 100644 --- a/simpeg_drivers/driver.py +++ b/simpeg_drivers/driver.py @@ -753,6 +753,7 @@ def get_regularization(self): active_cells=self.models.active_cells if forward_mesh is None else None, mapping=mapping, reference_model=self.models.reference_model, + reference_model_in_smooth=self.params.reference_model_in_smooth, ) functions = self.get_modified_regularization( diff --git a/simpeg_drivers/joint/driver.py b/simpeg_drivers/joint/driver.py index 20fda8be..b9b560e0 100644 --- a/simpeg_drivers/joint/driver.py +++ b/simpeg_drivers/joint/driver.py @@ -252,6 +252,23 @@ def n_values(self): return self._n_values + @property + def params(self) -> BaseJointOptions: + """Application parameters.""" + return self._params + + @params.setter + def params( + self, + val: BaseJointOptions, + ): + if not isinstance( + val, + BaseJointOptions, + ): + raise TypeError("Parameters must be of type 'BaseJointOptions'.") + self._params = val + def simpeg_run(self): """Run inversion from params""" self.initialize() @@ -559,7 +576,14 @@ def _overload_regularization(self, regularization: ComboObjectiveFunction): for driver in self.drivers: reg_block = [] for mapping in driver.mapping: - reg_block.append(reg_dict[self._mapping[driver, mapping]]) + reg = reg_dict[self._mapping[driver, mapping]] + reference_model_in_smooth = driver.params.reference_model_in_smooth + + if "reference_model_in_smooth" in self.params.model_fields_set: + reference_model_in_smooth = self.params.reference_model_in_smooth + + reg.reference_model_in_smooth = reference_model_in_smooth + reg_block.append(reg) driver.regularization = ComboObjectiveFunction(objfcts=reg_block) diff --git a/simpeg_drivers/joint/joint_cross_gradient/driver.py b/simpeg_drivers/joint/joint_cross_gradient/driver.py index 512b916b..8c86c459 100644 --- a/simpeg_drivers/joint/joint_cross_gradient/driver.py +++ b/simpeg_drivers/joint/joint_cross_gradient/driver.py @@ -56,6 +56,11 @@ def get_regularization(self): for mapping in driver.mapping: self._mapping[driver, mapping] = mapping + if "reference_model_in_smooth" in self.params.model_fields_set: + driver.params.reference_model_in_smooth = ( + self.params.reference_model_in_smooth + ) + for multiplier, objfct in driver.regularization: multipliers.append(multiplier) reg_list.append(objfct) diff --git a/simpeg_drivers/joint/joint_surveys/driver.py b/simpeg_drivers/joint/joint_surveys/driver.py index b822bd91..3c467d36 100644 --- a/simpeg_drivers/joint/joint_surveys/driver.py +++ b/simpeg_drivers/joint/joint_surveys/driver.py @@ -45,6 +45,8 @@ def get_regularization(self): driver._inversion_mesh = self.inversion_mesh # pylint: disable=protected-access driver._n_values = self.models.n_active # pylint: disable=protected-access driver.mapping = self.mapping + + driver.params.reference_model_in_smooth = self.params.reference_model_in_smooth return driver.get_regularization() def validate_create_models(self): diff --git a/simpeg_drivers/joint/options.py b/simpeg_drivers/joint/options.py index 8a09f04f..ea9f9090 100644 --- a/simpeg_drivers/joint/options.py +++ b/simpeg_drivers/joint/options.py @@ -96,6 +96,7 @@ class BaseJointOptions(CoreOptions): group_c: SimPEGGroup | None = None group_c_multiplier: float | None = None + reference_model_in_smooth: bool = False irls: IRLSOptions = IRLSOptions() directives: DirectiveOptions = DirectiveOptions() cooling_schedule: CoolingSceduleOptions = CoolingSceduleOptions() diff --git a/simpeg_drivers/options.py b/simpeg_drivers/options.py index 45ced345..b61bc20d 100644 --- a/simpeg_drivers/options.py +++ b/simpeg_drivers/options.py @@ -558,7 +558,7 @@ class BaseInversionOptions(CoreOptions): :param conda_environment: Name of the conda environment used to run the program :param data_object: Data object containing the survey data. :param models: Model options for the inversion. - :param regularization: Options specific to the regularization function. + :param reference_model_in_smooth: Whether to include the reference model in the smoothness term of the regularization. :param irls: Options specific to the IRLS (Iteratively Reweighted Least Squares) directive. :param directives: Additional directives to be used in the inversion. :param cooling_schedule: Options controlling the trade-off schedule between data misfit and model regularization. @@ -580,6 +580,7 @@ class BaseInversionOptions(CoreOptions): data_object: Points models: ModelOptions + reference_model_in_smooth: bool = False irls: IRLSOptions = IRLSOptions() directives: DirectiveOptions = DirectiveOptions() cooling_schedule: CoolingSceduleOptions = CoolingSceduleOptions() diff --git a/simpeg_drivers/potential_fields/magnetic_vector_pde/inversion.py b/simpeg_drivers/potential_fields/magnetic_vector_pde/inversion.py index 18a2c675..e2a46a88 100644 --- a/simpeg_drivers/potential_fields/magnetic_vector_pde/inversion.py +++ b/simpeg_drivers/potential_fields/magnetic_vector_pde/inversion.py @@ -43,6 +43,7 @@ def get_regularization(self): active_cells=self.models.active_cells, mapping=mapping, reference_model=self.models.reference_model, + reference_model_in_smooth=self.params.reference_model_in_smooth, ) functions = self.get_modified_regularization( diff --git a/tests/run_tests/driver_grav_test.py b/tests/run_tests/driver_grav_test.py index 55214179..8eeaaa90 100644 --- a/tests/run_tests/driver_grav_test.py +++ b/tests/run_tests/driver_grav_test.py @@ -154,6 +154,7 @@ def test_gravity_run( starting_model=1e-4, topography_object=components.topography, reference_model=reference, + reference_model_in_smooth=True, sens_wts_threshold=1.0, save_sensitivities=True, ) @@ -162,6 +163,7 @@ def test_gravity_run( driver = GravityInversionDriver.start(str(tmp_path / "Inv_run.ui.json")) + assert driver.regularization.objfcts[0].reference_model_in_smooth if not pytest: return diff --git a/tests/run_tests/driver_joint_cross_gradient_test.py b/tests/run_tests/driver_joint_cross_gradient_test.py index 81608ed9..01651b10 100644 --- a/tests/run_tests/driver_joint_cross_gradient_test.py +++ b/tests/run_tests/driver_joint_cross_gradient_test.py @@ -533,10 +533,12 @@ def test_joint_cross_gradient_rotated_run( group_b=drivers[1].out_group, group_b_multiplier=1.0, max_global_iterations=max_iterations, + reference_model_in_smooth=True, ) joint_driver = JointCrossGradientDriver(joint_params) joint_driver.run() + assert joint_driver.regularization.objfcts[0].reference_model_in_smooth assert joint_driver.models.gradient_dip is not None diff --git a/tests/run_tests/driver_joint_pgi_homogeneous_test.py b/tests/run_tests/driver_joint_pgi_homogeneous_test.py index 0454dafb..482a83e0 100644 --- a/tests/run_tests/driver_joint_pgi_homogeneous_test.py +++ b/tests/run_tests/driver_joint_pgi_homogeneous_test.py @@ -19,6 +19,7 @@ from geoh5py.groups.property_group import GroupTypeEnum, PropertyGroup from geoh5py.objects import Octree, Points from geoh5py.workspace import Workspace +from simpeg.regularization import PGIsmallness from simpeg_drivers.joint.joint_petrophysics.driver import JointPetrophysicsDriver from simpeg_drivers.joint.joint_petrophysics.options import JointPetrophysicsOptions @@ -56,7 +57,7 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = {"data_norm": 422.92317507375105, "phi_d": 2920, "phi_m": 417} +target_run = {"data_norm": 4.2090e02, "phi_d": 2.8860e03, "phi_m": 8.2700e01} INDUCING_FIELD = (50000.0, 90.0, 0.0) @@ -337,6 +338,7 @@ def test_homogeneous_run( petrophysical_model=petrophysics, initial_beta_ratio=1e2, max_global_iterations=max_iterations, + reference_model_in_smooth=True, max_irls_iterations=1, ) driver = JointPetrophysicsDriver(joint_params) @@ -352,9 +354,14 @@ def test_homogeneous_run( new_driver = MagneticInversionDriver(params) joint_params.group_b = new_driver.out_group driver = JointPetrophysicsDriver(joint_params) - driver.run() + assert all( + objfct.reference_model_in_smooth + for objfct in driver.regularization.objfcts + if not isinstance(objfct, PGIsmallness) + ) + if use_pytest: assert driver.regularization.objfcts[-1].gmm.fixed_membership[0, 1] == 1 diff --git a/tests/run_tests/driver_joint_surveys_test.py b/tests/run_tests/driver_joint_surveys_test.py index d3e01955..ff225a6c 100644 --- a/tests/run_tests/driver_joint_surveys_test.py +++ b/tests/run_tests/driver_joint_surveys_test.py @@ -213,6 +213,7 @@ def test_joint_surveys_inv_run( x_norm=0.0, y_norm=0.0, z_norm=0.0, + reference_model_in_smooth=True, lower_bound=0.0, max_global_iterations=max_iterations, initial_beta_ratio=1e-2, @@ -224,6 +225,8 @@ def test_joint_surveys_inv_run( driver = JointSurveysDriver.start(str(tmp_path / "Inv_run.ui.json")) + assert driver.regularization.objfcts[0].reference_model_in_smooth + # The rescaling is done evenly on the two tiles for both surveys np.testing.assert_allclose( driver.data_misfit.multipliers, diff --git a/tests/run_tests/driver_mvi_pde_test.py b/tests/run_tests/driver_mvi_pde_test.py index ee197153..ba482ece 100644 --- a/tests/run_tests/driver_mvi_pde_test.py +++ b/tests/run_tests/driver_mvi_pde_test.py @@ -137,12 +137,15 @@ def test_mvi_pde_run( upper_bound=upper_bound, max_global_iterations=max_iterations, initial_beta_ratio=1e-0, + reference_model_in_smooth=True, ) params.write_ui_json(path=tmp_path / "Inv_run.ui.json") driver = MagneticVectorPDEInversionDriver(params) driver.run() + assert driver.regularization.objfcts[0].reference_model_in_smooth is True + if pytest: with Workspace(driver.params.geoh5.h5file) as ws: # Re-open the workspace and get iterations