From 45acf03412cacb29d9f8566dc5dcc9ffe4e1e56d Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 28 Apr 2025 09:59:40 -0700 Subject: [PATCH 1/5] Remove is_sigma in cond model --- simpeg_drivers/components/models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/simpeg_drivers/components/models.py b/simpeg_drivers/components/models.py index 413e997f..85eed000 100644 --- a/simpeg_drivers/components/models.py +++ b/simpeg_drivers/components/models.py @@ -238,15 +238,15 @@ def conductivity(self) -> np.ndarray | None: if self._conductivity.model is None: return None - mstart = self._conductivity.model.copy() + background_sigma = self._conductivity.model.copy() - if mstart is not None and self.is_sigma: + if background_sigma is not None: if getattr(self.driver.params, "model_type", None) == "Resistivity (Ohm-m)": - mstart = 1 / mstart + background_sigma = 1 / background_sigma - mstart = np.log(mstart) + background_sigma = np.log(background_sigma) - return mstart + return background_sigma @property def alpha_s(self) -> np.ndarray | None: From 950e122094172fb56aefb42b6ed9abcd862bea94 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 28 Apr 2025 10:11:57 -0700 Subject: [PATCH 2/5] Change IP test to check handling of cond background --- simpeg_drivers/components/models.py | 10 ++++++++-- tests/run_tests/driver_ip_test.py | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/simpeg_drivers/components/models.py b/simpeg_drivers/components/models.py index 85eed000..c6706fe5 100644 --- a/simpeg_drivers/components/models.py +++ b/simpeg_drivers/components/models.py @@ -185,7 +185,10 @@ def reference(self) -> np.ndarray | None: @property def lower_bound(self) -> np.ndarray | None: - if getattr(self.driver.params, "model_type", None) == "Resistivity (Ohm-m)": + if ( + getattr(self.driver.params, "model_type", None) == "Resistivity (Ohm-m)" + and self.is_sigma + ): bound_model = self._upper_bound.model else: bound_model = self._lower_bound.model @@ -213,7 +216,10 @@ def lower_bound(self) -> np.ndarray | None: @property def upper_bound(self) -> np.ndarray | None: - if getattr(self.driver.params, "model_type", None) == "Resistivity (Ohm-m)": + if ( + getattr(self.driver.params, "model_type", None) == "Resistivity (Ohm-m)" + and self.is_sigma + ): bound_model = self._lower_bound.model else: bound_model = self._upper_bound.model diff --git a/tests/run_tests/driver_ip_test.py b/tests/run_tests/driver_ip_test.py index a768c53c..167b365d 100644 --- a/tests/run_tests/driver_ip_test.py +++ b/tests/run_tests/driver_ip_test.py @@ -85,7 +85,8 @@ def test_ip_3d_run( mesh=mesh, active_cells=ActiveCellsOptions(topography_object=topography), data_object=potential.parent, - conductivity_model=1e-2, + conductivity_model=1e2, + model_type="Resistivity (Ohm-m)", reference_model=1e-6, starting_model=1e-6, s_norm=0.0, From 548d70d2e306fa9908dfd9100393cfdee1824f36 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 28 Apr 2025 10:12:51 -0700 Subject: [PATCH 3/5] Fix logic in driver --- simpeg_drivers/driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simpeg_drivers/driver.py b/simpeg_drivers/driver.py index 326dc7eb..1d2cb02f 100644 --- a/simpeg_drivers/driver.py +++ b/simpeg_drivers/driver.py @@ -708,7 +708,7 @@ def get_path(self, filepath: str | Path) -> str: cluster = ( LocalCluster(processes=True, n_workers=n_workers, threads_per_worker=n_threads) - if (n_workers is None or n_workers > 1 or n_threads is not None) + if ((n_workers is not None and n_workers > 1) or n_threads is not None) else None ) From e0740f674c0d8d263f4c9df714437041d14e7326 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 28 Apr 2025 10:36:29 -0700 Subject: [PATCH 4/5] Update label and tooltips for ips --- .../uijson/induced_polarization_2d_forward.ui.json | 3 ++- .../uijson/induced_polarization_2d_inversion.ui.json | 3 ++- .../uijson/induced_polarization_3d_forward.ui.json | 3 ++- .../uijson/induced_polarization_3d_inversion.ui.json | 3 ++- .../uijson/induced_polarization_batch2d_forward.ui.json | 3 ++- .../uijson/induced_polarization_batch2d_inversion.ui.json | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/simpeg_drivers-assets/uijson/induced_polarization_2d_forward.ui.json b/simpeg_drivers-assets/uijson/induced_polarization_2d_forward.ui.json index 35fdbf76..1d3b32df 100644 --- a/simpeg_drivers-assets/uijson/induced_polarization_2d_forward.ui.json +++ b/simpeg_drivers-assets/uijson/induced_polarization_2d_forward.ui.json @@ -121,7 +121,8 @@ "main": true, "isValue": true, "parent": "mesh", - "label": "Conductivity (S/m)", + "label": "Background", + "tooltip": "Background model in the 'Model units' (S/m or Ohm-m).", "property": "", "value": 0.001 }, 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 291d0523..665942b4 100644 --- a/simpeg_drivers-assets/uijson/induced_polarization_2d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/induced_polarization_2d_inversion.ui.json @@ -140,7 +140,8 @@ "main": true, "isValue": true, "parent": "mesh", - "label": "Conductivity (S/m)", + "label": "Background", + "tooltip": "Background model in the 'Model units' (S/m or Ohm-m).", "property": "", "value": 0.001 }, diff --git a/simpeg_drivers-assets/uijson/induced_polarization_3d_forward.ui.json b/simpeg_drivers-assets/uijson/induced_polarization_3d_forward.ui.json index f3e0843d..ad74bf9e 100644 --- a/simpeg_drivers-assets/uijson/induced_polarization_3d_forward.ui.json +++ b/simpeg_drivers-assets/uijson/induced_polarization_3d_forward.ui.json @@ -50,7 +50,8 @@ "main": true, "isValue": true, "parent": "mesh", - "label": "Conductivity (S/m)", + "label": "Background", + "tooltip": "Background model in the 'Model units' (S/m or Ohm-m).", "property": "", "value": 0.001 }, 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 c8c91d7d..18243153 100644 --- a/simpeg_drivers-assets/uijson/induced_polarization_3d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/induced_polarization_3d_inversion.ui.json @@ -75,7 +75,8 @@ "main": true, "isValue": true, "parent": "mesh", - "label": "Conductivity (S/m)", + "label": "Background", + "tooltip": "Background model in the 'Model units' (S/m or Ohm-m).", "property": "", "value": 0.001 }, diff --git a/simpeg_drivers-assets/uijson/induced_polarization_batch2d_forward.ui.json b/simpeg_drivers-assets/uijson/induced_polarization_batch2d_forward.ui.json index 74805881..827d957a 100644 --- a/simpeg_drivers-assets/uijson/induced_polarization_batch2d_forward.ui.json +++ b/simpeg_drivers-assets/uijson/induced_polarization_batch2d_forward.ui.json @@ -104,7 +104,8 @@ "main": true, "isValue": true, "parent": "mesh", - "label": "Conductivity (S/m)", + "label": "Background", + "tooltip": "Background model in the 'Model units' (S/m or Ohm-m).", "property": "", "value": 0.001 }, diff --git a/simpeg_drivers-assets/uijson/induced_polarization_batch2d_inversion.ui.json b/simpeg_drivers-assets/uijson/induced_polarization_batch2d_inversion.ui.json index 5a75df75..7863b81c 100644 --- a/simpeg_drivers-assets/uijson/induced_polarization_batch2d_inversion.ui.json +++ b/simpeg_drivers-assets/uijson/induced_polarization_batch2d_inversion.ui.json @@ -123,7 +123,8 @@ "main": true, "isValue": true, "parent": "mesh", - "label": "Conductivity (S/m)", + "label": "Background", + "tooltip": "Background model in the 'Model units' (S/m or Ohm-m).", "property": "", "value": 0.001 }, From 459d81463b642fed96ce279c51e7c2412e83ba31 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 28 Apr 2025 10:48:17 -0700 Subject: [PATCH 5/5] Fix logic, beef up test on 2d --- simpeg_drivers/components/models.py | 4 +++- tests/run_tests/driver_ip_2d_test.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/simpeg_drivers/components/models.py b/simpeg_drivers/components/models.py index c6706fe5..3153e21d 100644 --- a/simpeg_drivers/components/models.py +++ b/simpeg_drivers/components/models.py @@ -250,7 +250,9 @@ def conductivity(self) -> np.ndarray | None: if getattr(self.driver.params, "model_type", None) == "Resistivity (Ohm-m)": background_sigma = 1 / background_sigma - background_sigma = np.log(background_sigma) + # Don't apply log if IP inversion + if self.is_sigma: + background_sigma = np.log(background_sigma) return background_sigma diff --git a/tests/run_tests/driver_ip_2d_test.py b/tests/run_tests/driver_ip_2d_test.py index 0190bed6..d4d2e86f 100644 --- a/tests/run_tests/driver_ip_2d_test.py +++ b/tests/run_tests/driver_ip_2d_test.py @@ -58,7 +58,8 @@ def test_ip_2d_fwr_run( mesh=model.parent, active_cells=ActiveCellsOptions(topography_object=topography), starting_model=model, - conductivity_model=1e-2, + conductivity_model=1e2, + model_type="Resistivity (Ohm-m)", line_selection=LineSelectionOptions( line_object=geoh5.get_entity("line_ids")[0], line_id=101,