From 6909ccd3432881053d44ac9c6db9d9882d89d918 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 3 Feb 2025 11:47:56 -0800 Subject: [PATCH] Coarsen mesh in EM tests --- tests/run_tests/driver_airborne_tem_test.py | 14 +++++++------- tests/run_tests/driver_fem_test.py | 10 +++++++--- tests/run_tests/driver_ground_tem_test.py | 17 ++++++++++------- tests/run_tests/driver_mt_test.py | 8 ++++++-- tests/run_tests/driver_tipper_test.py | 10 +++++++--- 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/tests/run_tests/driver_airborne_tem_test.py b/tests/run_tests/driver_airborne_tem_test.py index a818749c..2bfb0937 100644 --- a/tests/run_tests/driver_airborne_tem_test.py +++ b/tests/run_tests/driver_airborne_tem_test.py @@ -28,11 +28,7 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = { - "data_norm": 2.81018e-10, - "phi_d": 15400, - "phi_m": 718.9, -} +target_run = {"data_norm": 7.05481e-08, "phi_d": 198200000, "phi_m": 7806} def test_bad_waveform(tmp_path: Path): @@ -76,6 +72,7 @@ def test_airborne_tem_fwr_run( tmp_path: Path, n_grid_points=3, refinement=(2,), + cell_size=(20.0, 20.0, 20.0), ): # Run the forward geoh5, _, model, survey, topography = setup_inversion_workspace( @@ -84,6 +81,7 @@ def test_airborne_tem_fwr_run( anomaly=1.0, n_electrodes=n_grid_points, n_lines=n_grid_points, + cell_size=cell_size, refinement=refinement, inversion_type="airborne_tem", drape_height=10.0, @@ -200,7 +198,7 @@ def test_airborne_tem_run(tmp_path: Path, max_iterations=1, pytest=True): ) output["data"] = orig_dBzdt if pytest: - check_target(output, target_run, tolerance=0.5) + check_target(output, target_run, tolerance=0.1) nan_ind = np.isnan(run_ws.get_entity("Iteration_0_model")[0].values) inactive_ind = run_ws.get_entity("active_cells")[0].values == 0 assert np.all(nan_ind == inactive_ind) @@ -208,7 +206,9 @@ def test_airborne_tem_run(tmp_path: Path, max_iterations=1, pytest=True): if __name__ == "__main__": # Full run - test_airborne_tem_fwr_run(Path("./"), n_grid_points=5, refinement=(0, 0, 4)) + test_airborne_tem_fwr_run( + Path("./"), n_grid_points=5, cell_size=(5.0, 5.0, 5.0), refinement=(0, 0, 4) + ) test_airborne_tem_run( Path("./"), max_iterations=15, diff --git a/tests/run_tests/driver_fem_test.py b/tests/run_tests/driver_fem_test.py index 88fdfbee..c7a0a32e 100644 --- a/tests/run_tests/driver_fem_test.py +++ b/tests/run_tests/driver_fem_test.py @@ -31,13 +31,14 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = {"data_norm": 47.522882323952054, "phi_d": 729, "phi_m": 883.8} +target_run = {"data_norm": 81.8361, "phi_d": 2161, "phi_m": 5828} def test_fem_fwr_run( tmp_path: Path, n_grid_points=3, refinement=(2,), + cell_size=(20.0, 20.0, 20.0), ): # Run the forward geoh5, _, model, survey, topography = setup_inversion_workspace( @@ -48,6 +49,7 @@ def test_fem_fwr_run( n_lines=n_grid_points, refinement=refinement, drape_height=15.0, + cell_size=cell_size, padding_distance=400, inversion_type="fem", flatten=True, @@ -166,7 +168,7 @@ def test_fem_run(tmp_path: Path, max_iterations=1, pytest=True): ) if pytest: - check_target(output, target_run, tolerance=0.5) + check_target(output, target_run, tolerance=0.1) nan_ind = np.isnan(run_ws.get_entity("Iteration_0_model")[0].values) inactive_ind = run_ws.get_entity("active_cells")[0].values == 0 assert np.all(nan_ind == inactive_ind) @@ -174,7 +176,9 @@ def test_fem_run(tmp_path: Path, max_iterations=1, pytest=True): if __name__ == "__main__": # Full run - test_fem_fwr_run(Path("./"), n_grid_points=5, refinement=(4, 4, 4)) + test_fem_fwr_run( + Path("./"), n_grid_points=5, cell_size=(5.0, 5.0, 5.0), refinement=(4, 4, 4) + ) test_fem_run( Path("./"), max_iterations=15, diff --git a/tests/run_tests/driver_ground_tem_test.py b/tests/run_tests/driver_ground_tem_test.py index 68e2c4dc..0a95d65b 100644 --- a/tests/run_tests/driver_ground_tem_test.py +++ b/tests/run_tests/driver_ground_tem_test.py @@ -30,11 +30,7 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = { - "data_norm": 5.95181e-7, - "phi_d": 86.58, - "phi_m": 443.1, -} +target_run = {"data_norm": 8.806897e-07, "phi_d": 152.8, "phi_m": 12850} def test_tiling_ground_tem( @@ -89,6 +85,7 @@ def test_ground_tem_fwr_run( caplog, n_grid_points=4, refinement=(2,), + cell_size=(20.0, 20.0, 20.0), pytest=True, ): if pytest: @@ -103,6 +100,7 @@ def test_ground_tem_fwr_run( refinement=refinement, inversion_type="ground_tem", drape_height=5.0, + cell_size=cell_size, padding_distance=1000.0, flatten=True, ) @@ -229,7 +227,7 @@ def test_ground_tem_run(tmp_path: Path, max_iterations=1, pytest=True): assert driver.inversion_data.entity.tx_id_property.name == "tx_id" output["data"] = orig_dBzdt if pytest: - check_target(output, target_run, tolerance=0.5) + check_target(output, target_run, tolerance=0.1) nan_ind = np.isnan(run_ws.get_entity("Iteration_0_model")[0].values) inactive_ind = run_ws.get_entity("active_cells")[0].values == 0 assert np.all(nan_ind == inactive_ind) @@ -238,7 +236,12 @@ def test_ground_tem_run(tmp_path: Path, max_iterations=1, pytest=True): if __name__ == "__main__": # Full run test_ground_tem_fwr_run( - Path("./"), None, n_grid_points=5, refinement=(2, 2, 2), pytest=False + Path("./"), + None, + n_grid_points=5, + refinement=(2, 2, 2), + cell_size=(5.0, 5.0, 5.0), + pytest=False, ) test_ground_tem_run( Path("./"), diff --git a/tests/run_tests/driver_mt_test.py b/tests/run_tests/driver_mt_test.py index 80e40605..a99501be 100644 --- a/tests/run_tests/driver_mt_test.py +++ b/tests/run_tests/driver_mt_test.py @@ -31,13 +31,14 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = {"data_norm": 0.0042988, "phi_d": 50.2, "phi_m": 11.1} +target_run = {"data_norm": 0.032649770, "phi_d": 6.676, "phi_m": 212.3} def test_magnetotellurics_fwr_run( tmp_path: Path, n_grid_points=2, refinement=(2,), + cell_size=(20.0, 20.0, 20.0), ): # Run the forward geoh5, _, model, survey, topography = setup_inversion_workspace( @@ -47,6 +48,7 @@ def test_magnetotellurics_fwr_run( n_electrodes=n_grid_points, n_lines=n_grid_points, refinement=refinement, + cell_size=cell_size, drape_height=0.0, inversion_type="magnetotellurics", flatten=False, @@ -200,7 +202,9 @@ def test_magnetotellurics_run(tmp_path: Path, max_iterations=1, pytest=True): if __name__ == "__main__": # Full run - test_magnetotellurics_fwr_run(Path("./"), n_grid_points=8, refinement=(4, 8)) + test_magnetotellurics_fwr_run( + Path("./"), n_grid_points=8, cell_size=(5.0, 5.0, 5.0), refinement=(4, 8) + ) test_magnetotellurics_run( Path("./"), max_iterations=15, diff --git a/tests/run_tests/driver_tipper_test.py b/tests/run_tests/driver_tipper_test.py index e2230f5b..7812ed57 100644 --- a/tests/run_tests/driver_tipper_test.py +++ b/tests/run_tests/driver_tipper_test.py @@ -25,13 +25,14 @@ # To test the full run and validate the inversion. # Move this file out of the test directory and run. -target_run = {"data_norm": 0.0055932, "phi_d": 7.346, "phi_m": 472.2} +target_run = {"data_norm": 0.006549595043425509, "phi_d": 221.4, "phi_m": 270.5} def test_tipper_fwr_run( tmp_path: Path, n_grid_points=2, refinement=(2,), + cell_size=(20.0, 20.0, 20.0), ): # Run the forward geoh5, _, model, survey, topography = setup_inversion_workspace( @@ -41,6 +42,7 @@ def test_tipper_fwr_run( n_electrodes=n_grid_points, n_lines=n_grid_points, refinement=refinement, + cell_size=cell_size, inversion_type="tipper", drape_height=15.0, flatten=False, @@ -162,7 +164,7 @@ def test_tipper_run(tmp_path: Path, max_iterations=1, pytest=True): ) output["data"] = orig_tyz_real_1 if pytest: - check_target(output, target_run, tolerance=0.5) + check_target(output, target_run, tolerance=0.1) nan_ind = np.isnan(run_ws.get_entity("Iteration_0_model")[0].values) inactive_ind = run_ws.get_entity("active_cells")[0].values == 0 assert np.all(nan_ind == inactive_ind) @@ -170,7 +172,9 @@ def test_tipper_run(tmp_path: Path, max_iterations=1, pytest=True): if __name__ == "__main__": # Full run - test_tipper_fwr_run(Path("./"), n_grid_points=8, refinement=(4, 4)) + test_tipper_fwr_run( + Path("./"), n_grid_points=8, cell_size=(5.0, 5.0, 5.0), refinement=(4, 4) + ) test_tipper_run( Path("./"), max_iterations=15,