|
12 | 12 |
|
13 | 13 | import numpy as np |
14 | 14 | from geoh5py import Workspace |
15 | | -from geoh5py.objects import Points |
| 15 | +from geoh5py.objects import CurrentElectrode, Points, PotentialElectrode |
16 | 16 |
|
17 | | -from simpeg_drivers.utils.surveys import counter_clockwise_sort, station_spacing |
| 17 | +from simpeg_drivers.options import DrapeModelOptions |
| 18 | +from simpeg_drivers.utils.surveys import ( |
| 19 | + counter_clockwise_sort, |
| 20 | + create_mesh_by_line_id, |
| 21 | + get_parts_from_electrodes, |
| 22 | + station_spacing, |
| 23 | +) |
18 | 24 |
|
19 | 25 |
|
20 | 26 | def create_test_survey( |
@@ -83,3 +89,46 @@ def test_counterclockwise_sort(): |
83 | 89 | ccw_sorted = counter_clockwise_sort(segments, vertices) |
84 | 90 |
|
85 | 91 | np.testing.assert_equal(ccw_sorted[0, :], [0, 5]) |
| 92 | + |
| 93 | + |
| 94 | +def get_dc_survey(workspace): |
| 95 | + """ |
| 96 | + Create a DC survey with 4 current electrodes and 10 potential electrodes. |
| 97 | + """ |
| 98 | + vertices = np.random.randn(4, 3) |
| 99 | + currents = CurrentElectrode.create(workspace, vertices=vertices, parts=[0, 0, 1, 1]) |
| 100 | + currents.ab_cell_id = np.repeat([1, 2], 2) |
| 101 | + |
| 102 | + rx_vertices = np.random.randn(12, 3) |
| 103 | + mn_pairs = np.c_[np.arange(11), np.arange(1, 12)] # Remove connection |
| 104 | + mn_pairs = np.delete(mn_pairs, 5, axis=0) |
| 105 | + potentials = PotentialElectrode.create( |
| 106 | + workspace, |
| 107 | + vertices=rx_vertices, |
| 108 | + cells=mn_pairs, |
| 109 | + ) |
| 110 | + potentials.ab_cell_id = np.repeat([1, 2], 5) |
| 111 | + |
| 112 | + potentials.current_electrodes = currents |
| 113 | + return potentials |
| 114 | + |
| 115 | + |
| 116 | +def test_parts_from_electrodes(): |
| 117 | + workspace = Workspace() |
| 118 | + survey = get_dc_survey(workspace) |
| 119 | + |
| 120 | + line_ids = get_parts_from_electrodes(survey) |
| 121 | + assert len(np.unique(line_ids)) == 2 |
| 122 | + assert np.all(line_ids[:5] == 0) |
| 123 | + assert np.all(line_ids[5:] == 1) |
| 124 | + |
| 125 | + |
| 126 | +def test_drape_from_line_id(tmp_path): |
| 127 | + |
| 128 | + with Workspace.create(tmp_path / f"{__name__}.geoh5") as ws: |
| 129 | + survey = get_dc_survey(ws) |
| 130 | + drape = create_mesh_by_line_id( |
| 131 | + ws, survey.ab_cell_id, DrapeModelOptions(), name="test_drape" |
| 132 | + ) |
| 133 | + |
| 134 | + assert drape.name == "test_drape" |
0 commit comments