Skip to content

Commit 7771663

Browse files
committed
Full run of test
1 parent f21b363 commit 7771663

3 files changed

Lines changed: 6 additions & 43 deletions

File tree

simpeg_drivers/electricals/base_2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def inversion_mesh(self) -> InversionMesh:
5050
"""Inversion mesh"""
5151
if getattr(self, "_inversion_mesh", None) is None:
5252
with fetch_active_workspace(self.workspace, mode="r+"):
53-
entity = self.params.mesh
54-
if entity is None:
53+
entity = None
54+
if self.params.mesh is None:
5555
entity = create_mesh_by_line_id(
5656
self.workspace,
5757
self.params.line_selection.line_object,

simpeg_drivers/electricals/options.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,3 @@ class IPModelOptions(ConductivityModelOptions):
2323
"""
2424

2525
lower_bound: float | FloatData | None = 0
26-
27-
28-
class FileControlOptions(BaseModel):
29-
"""
30-
File control parameters for pseudo 3D simulations.
31-
32-
:param files_only: Boolean to only write files.
33-
:param cleanup: Boolean to cleanup files.
34-
"""
35-
36-
files_only: bool = False
37-
cleanup: bool = True

tests/run_tests/driver_dc_b2d_test.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
from __future__ import annotations
1313

14-
import json
1514
from pathlib import Path
1615

17-
from geoh5py.groups import SimPEGGroup
1816
from geoh5py.workspace import Workspace
1917

2018
from simpeg_drivers.electricals.direct_current.two_dimensions.driver import (
@@ -25,9 +23,6 @@
2523
DC2DForwardOptions,
2624
DC2DInversionOptions,
2725
)
28-
from simpeg_drivers.electricals.options import (
29-
FileControlOptions,
30-
)
3126
from simpeg_drivers.options import (
3227
DrapeModelOptions,
3328
LineSelectionOptions,
@@ -36,7 +31,6 @@
3631
SyntheticsComponents,
3732
)
3833
from simpeg_drivers.utils.synthetics.options import (
39-
MeshOptions,
4034
ModelOptions,
4135
SurveyOptions,
4236
SyntheticsComponentsOptions,
@@ -47,7 +41,7 @@
4741
# To test the full run and validate the inversion.
4842
# Move this file out of the test directory and run.
4943

50-
target_run = {"data_norm": 1.0878862593748388, "phi_d": 2050, "phi_m": 37.8}
44+
target_run = {"data_norm": 1.101767837151429, "phi_d": 2210, "phi_m": 21.4}
5145

5246

5347
def test_dc_p3d_fwr_run(
@@ -95,22 +89,14 @@ def test_dc_p3d_run(
9589

9690
with Workspace(workpath) as geoh5:
9791
components = SyntheticsComponents(geoh5)
98-
fwr_group = geoh5.get_entity("Direct Current (DC) 2D Batch Forward")[0]
92+
fwr_group = geoh5.get_entity("Direct Current 2D Forward")[0]
9993
survey = fwr_group.get_entity("survey")[0]
10094
potential = survey.get_data("Iteration_0_potential")[0]
10195

10296
# Run the inverse
10397
params = DC2DInversionOptions.build(
10498
geoh5=geoh5,
10599
mesh=components.mesh,
106-
drape_model=DrapeModelOptions(
107-
u_cell_size=5.0,
108-
v_cell_size=5.0,
109-
depth_core=100.0,
110-
expansion_factor=1.1,
111-
horizontal_padding=1000.0,
112-
vertical_padding=1000.0,
113-
),
114100
topography_object=components.topography,
115101
data_object=potential.parent,
116102
potential_channel=potential,
@@ -129,24 +115,13 @@ def test_dc_p3d_run(
129115
percentile=100,
130116
upper_bound=10,
131117
cooling_rate=1,
132-
file_control=FileControlOptions(cleanup=False),
133118
)
134119
params.write_ui_json(path=tmp_path / "Inv_run.ui.json")
135120

136-
DC2DInversionDriver.start(str(tmp_path / "Inv_run.ui.json"))
137-
138-
basepath = workpath.parent
139-
with open(basepath / "lookup.json", encoding="utf8") as f:
140-
lookup = json.load(f)
141-
middle_line_id = next(k for k, v in lookup.items() if v["line_id"] == 101)
142-
143-
with Workspace(basepath / f"{middle_line_id}.ui.geoh5", mode="r") as workspace:
144-
middle_inversion_group = next(
145-
k for k in workspace.groups if isinstance(k, SimPEGGroup)
146-
)
121+
driver = DC2DInversionDriver.start(str(tmp_path / "Inv_run.ui.json"))
147122

148123
output = get_inversion_output(
149-
basepath / f"{middle_line_id}.ui.geoh5", middle_inversion_group.uid
124+
driver.params.geoh5.h5file, driver.params.out_group.uid
150125
)
151126
if geoh5.open():
152127
output["data"] = potential.values

0 commit comments

Comments
 (0)