1111
1212from __future__ import annotations
1313
14- import json
1514from pathlib import Path
1615
17- from geoh5py .groups import SimPEGGroup
1816from geoh5py .workspace import Workspace
1917
2018from simpeg_drivers .electricals .direct_current .two_dimensions .driver import (
2523 DC2DForwardOptions ,
2624 DC2DInversionOptions ,
2725)
28- from simpeg_drivers .electricals .options import (
29- FileControlOptions ,
30- )
3126from simpeg_drivers .options import (
3227 DrapeModelOptions ,
3328 LineSelectionOptions ,
3631 SyntheticsComponents ,
3732)
3833from simpeg_drivers .utils .synthetics .options import (
39- MeshOptions ,
4034 ModelOptions ,
4135 SurveyOptions ,
4236 SyntheticsComponentsOptions ,
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
5347def 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