|
15 | 15 |
|
16 | 16 | import numpy as np |
17 | 17 | from geoapps_utils.utils.importing import GeoAppsError |
18 | | -from geoh5py.groups import PropertyGroup |
19 | 18 | from geoh5py.workspace import Workspace |
20 | 19 | from pytest import raises |
21 | 20 |
|
|
35 | 34 | # To test the full run and validate the inversion. |
36 | 35 | # Move this file out of the test directory and run. |
37 | 36 |
|
38 | | -target_run = {"data_norm": 0.0028055269276044915, "phi_d": 8.32e-05, "phi_m": 0.00333} |
| 37 | +target_run = {"data_norm": 0.0028055269276044915, "phi_d": 8.32e-05, "phi_m": 0.0038} |
39 | 38 |
|
40 | 39 |
|
41 | 40 | def test_gravity_fwr_run( |
@@ -189,75 +188,6 @@ def test_gravity_run( |
189 | 188 | assert np.all(nan_ind == inactive_ind) |
190 | 189 |
|
191 | 190 |
|
192 | | -def test_rotated_gradient( |
193 | | - tmp_path: Path, |
194 | | - max_iterations=1, |
195 | | - pytest=True, |
196 | | -): |
197 | | - workpath = tmp_path / "inversion_test.ui.geoh5" |
198 | | - if pytest: |
199 | | - workpath = tmp_path.parent / "test_gravity_fwr_run0" / "inversion_test.ui.geoh5" |
200 | | - |
201 | | - with Workspace(workpath) as geoh5: |
202 | | - gz = geoh5.get_entity("Iteration_0_gz")[0] |
203 | | - mesh = geoh5.get_entity("mesh")[0] |
204 | | - |
205 | | - inds = (mesh.centroids[:, 0] > -35) & (mesh.centroids[:, 0] < 35) |
206 | | - norms = np.ones(mesh.n_cells) * 2 |
207 | | - norms[inds] = 0 |
208 | | - gradient_norms = mesh.add_data({"norms": {"values": norms}}) |
209 | | - |
210 | | - topography = geoh5.get_entity("topography")[0] |
211 | | - |
212 | | - # Turn some values to nan |
213 | | - values = gz.values.copy() |
214 | | - values[0] = np.nan |
215 | | - gz.values = values |
216 | | - |
217 | | - # Rotate the gradients |
218 | | - |
219 | | - direction, dip = mesh.add_data( |
220 | | - { |
221 | | - "gradient_direction": {"values": 90 * np.ones(mesh.n_cells)}, |
222 | | - "gradient_dip": {"values": 45 * np.ones(mesh.n_cells)}, |
223 | | - } |
224 | | - ) |
225 | | - gradient_rotation = PropertyGroup( |
226 | | - parent=mesh, |
227 | | - name="gradient_rotation", |
228 | | - property_group_type="Dip direction & dip", |
229 | | - properties=[direction, dip], |
230 | | - ) |
231 | | - |
232 | | - # Run the inverse |
233 | | - active_cells = ActiveCellsOptions(topography_object=topography) |
234 | | - params = GravityInversionOptions( |
235 | | - geoh5=geoh5, |
236 | | - mesh=mesh, |
237 | | - active_cells=active_cells, |
238 | | - data_object=gz.parent, |
239 | | - starting_model=1e-4, |
240 | | - reference_model=0.0, |
241 | | - gradient_rotation=gradient_rotation, |
242 | | - s_norm=0.0, |
243 | | - x_norm=gradient_norms, |
244 | | - y_norm=gradient_norms, |
245 | | - z_norm=gradient_norms, |
246 | | - gradient_type="components", |
247 | | - gz_channel=gz, |
248 | | - gz_uncertainty=2e-3, |
249 | | - lower_bound=0.0, |
250 | | - max_global_iterations=max_iterations, |
251 | | - initial_beta_ratio=1e-2, |
252 | | - percentile=100, |
253 | | - store_sensitivities="ram", |
254 | | - save_sensitivities=True, |
255 | | - ) |
256 | | - params.write_ui_json(path=tmp_path / "Inv_run.ui.json") |
257 | | - |
258 | | - _ = GravityInversionDriver.start(str(tmp_path / "Inv_run.ui.json")) |
259 | | - |
260 | | - |
261 | 191 | if __name__ == "__main__": |
262 | 192 | # Full run |
263 | 193 | test_gravity_fwr_run( |
|
0 commit comments