Skip to content

Commit 81ab295

Browse files
committed
update simpeg drivers for new plate reference (top center)
1 parent a52ba43 commit 81ab295

7 files changed

Lines changed: 77 additions & 75 deletions

File tree

simpeg_drivers/plate_simulation/models/options.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import numpy as np
1414
from geoapps_utils.modelling.plates import PlateModel
15+
from geoapps_utils.utils.locations import topo_drape_elevation
1516
from geoh5py.objects import Points
1617
from pydantic import (
1718
AliasChoices,
@@ -22,6 +23,7 @@
2223
field_validator,
2324
model_validator,
2425
)
26+
from scipy.spatial import cKDTree
2527

2628

2729
T = TypeVar("T")
@@ -64,16 +66,20 @@ def center(
6466
6567
:param survey: geoh5py survey object for plate simulation.
6668
:param surface: Points-like object to reference plate depth from.
67-
:param depth_offset: Additional offset to be added to the depth of the plate.
6869
"""
6970

70-
xy = (
71-
survey.vertices[:, 0].mean() + self.geometry.origin[0],
72-
survey.vertices[:, 1].mean() + self.geometry.origin[1],
71+
xyz = np.atleast_2d(
72+
[
73+
survey.vertices[:, 0].mean(),
74+
survey.vertices[:, 1].mean(),
75+
0,
76+
]
77+
)
78+
topo_at_center = topo_drape_elevation(
79+
xyz, surface.vertices, method="linear", triangulation=surface.cells
7380
)
74-
z_topo = topography_above_point(topography=surface, point=xy) # TODO
7581

76-
return xy + (z_topo - self.geometry.elevation,)
82+
return xyz[0, 0], xyz[0, 1], topo_at_center[0, 2] - self.geometry.elevation
7783

7884

7985
class OverburdenOptions(BaseModel):

simpeg_drivers/utils/synthetics/options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ class ModelOptions(BaseModel):
141141
width=40.0,
142142
easting=0.0,
143143
northing=0.0,
144-
elevation=10.0,
144+
elevation=0.0,
145+
dip=90.0,
146+
direction=0.0,
145147
)
146148
name: str = "model"
147149

tests/plate_simulation/models/params_test.py

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,44 @@
1414
from geoh5py.objects import Points, Surface
1515

1616
from simpeg_drivers.plate_simulation.models.options import PlateOptions
17+
from simpeg_drivers.utils.synthetics.driver import SyntheticsComponents
18+
from simpeg_drivers.utils.synthetics.options import (
19+
SurveyOptions,
20+
SyntheticsComponentsOptions,
21+
)
22+
23+
24+
def test_plate_options_center(tmp_path):
25+
with Workspace(tmp_path / "test.geoh5") as workspace:
26+
components = SyntheticsComponents(
27+
geoh5=workspace,
28+
options=SyntheticsComponentsOptions(
29+
method="gravity",
30+
refine_plate=True,
31+
survey=SurveyOptions(
32+
center=(0.0, 0.0), n_stations=10, n_lines=10, drape=15.0
33+
),
34+
),
35+
)
36+
37+
params = PlateOptions(
38+
name="my plate",
39+
plate_property=1.0,
40+
geometry=PlateModel(
41+
strike_length=40.0,
42+
dip_length=80.0,
43+
width=5.0,
44+
easting=10.0,
45+
northing=-10.0,
46+
elevation=30.0,
47+
direction=0.0,
48+
dip=90.0,
49+
),
50+
number=1,
51+
spacing=10.0,
52+
)
53+
center = params.center(components.survey, components.topography)
54+
assert np.allclose(center, [0.0, 0.0, 20], atol=7e-1)
1755

1856

1957
def test_plate_params(tmp_path):
@@ -27,16 +65,12 @@ def test_plate_params(tmp_path):
2765
width=20.0,
2866
easting=10.0,
2967
northing=10.0,
30-
elevation=-100.0,
68+
elevation=100.0,
3169
direction=0.0,
3270
dip=90.0,
3371
),
34-
reference="center",
3572
number=1,
3673
spacing=10.0,
37-
relative_locations=True,
38-
reference_surface="topography",
39-
reference_type="mean",
4074
)
4175
assert params.spacing == 0.0
4276

@@ -53,33 +87,4 @@ def test_plate_params(tmp_path):
5387
)
5488

5589
center = params.center(survey, topography)
56-
assert np.allclose(center, [0, 0, -300])
57-
58-
params.relative_locations = False
59-
center = params.center(survey, topography)
60-
assert np.allclose(center, [10, 10, -100])
61-
62-
63-
def test_plate_params_empty_reference():
64-
params = PlateOptions(
65-
name="my plate",
66-
plate_property=1.0,
67-
geometry=PlateModel(
68-
strike_length=1500.0,
69-
dip_length=400.0,
70-
width=20.0,
71-
easting=10.0,
72-
northing=10.0,
73-
elevation=-100.0,
74-
direction=0.0,
75-
dip=90.0,
76-
),
77-
reference="center",
78-
number=1,
79-
spacing=10.0,
80-
relative_locations=True,
81-
reference_surface=None,
82-
reference_type=None,
83-
)
84-
assert params.reference_surface == "topography"
85-
assert params.reference_type == "mean"
90+
assert np.allclose(center, [-10.0, -10.0, -100])

tests/plate_simulation/models/plates_test.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,17 @@ def test_vertical_east_striking_plate(tmp_path):
5858
vertical_east_striking.extent[1, 2] - vertical_east_striking.extent[0, 2],
5959
500.0,
6060
)
61-
assert (
62-
vertical_east_striking.vertices[:, 0].mean() == 0.0 # pylint: disable=no-member
61+
assert np.isclose(
62+
vertical_east_striking.vertices[:, 0].mean(),
63+
0.0, # pylint: disable=no-member
6364
)
64-
assert (
65-
vertical_east_striking.vertices[:, 1].mean() == 0.0 # pylint: disable=no-member
65+
assert np.isclose(
66+
vertical_east_striking.vertices[:, 1].mean(),
67+
0.0, # pylint: disable=no-member
6668
)
67-
assert (
68-
vertical_east_striking.vertices[:, 2].mean() == 0.0 # pylint: disable=no-member
69+
assert np.isclose(
70+
vertical_east_striking.vertices[:, 2].mean(),
71+
-250.0, # pylint: disable=no-member
6972
)
7073

7174

@@ -88,7 +91,9 @@ def test_dipping_plates_all_quadrants(tmp_path):
8891
)
8992

9093
plate = Plate(params)
91-
surface = plate.surface(workspace)
94+
surface = plate.surface(
95+
workspace, name=f"Plate (dip: {dip}, dir: {dip_direction}"
96+
)
9297
locs = rotate_xyz(surface.vertices, [0.0, 0.0, 0.0], dip_direction, 0.0)
9398
locs = rotate_xyz(locs, [0.0, 0.0, 0.0], 0.0, dip - 90.0)
9499
assert np.allclose(locs, reference.vertices)
@@ -97,13 +102,13 @@ def test_dipping_plates_all_quadrants(tmp_path):
97102
def test_replicate_even(tmp_path):
98103
with Workspace(tmp_path / "test.geoh5") as workspace:
99104
options = PlateModel(
100-
strike_length=1.0,
101-
dip_length=1.0,
102-
width=1.0,
105+
strike_length=2.0,
106+
dip_length=2.0,
107+
width=2.0,
103108
direction=0.0,
104109
dip=0.0,
105110
easting=0.0,
106-
northing=0.0,
111+
northing=-1.0,
107112
elevation=0.0,
108113
)
109114
plate = Plate(options)
@@ -123,13 +128,13 @@ def test_replicate_even(tmp_path):
123128
def test_replicate_odd(tmp_path):
124129
with Workspace(tmp_path / "test.geoh5") as workspace:
125130
options = PlateModel(
126-
strike_length=1.0,
127-
dip_length=1.0,
128-
width=1.0,
131+
strike_length=2.0,
132+
dip_length=2.0,
133+
width=2.0,
129134
direction=0.0,
130135
dip=0.0,
131136
easting=0.0,
132-
northing=0.0,
137+
northing=-1.0,
133138
elevation=0.0,
134139
)
135140
plate = Plate(options)

tests/plate_simulation/runtest/driver_test.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ def test_plate_simulation_params_from_input_file(tmp_path):
8585
ifile.data["dip_direction"] = 0.0
8686
ifile.data["number"] = 9
8787
ifile.data["spacing"] = 10.0
88-
ifile.data["relative_locations"] = True
89-
ifile.data["easting"] = 10.0
90-
ifile.data["northing"] = 10.0
9188
ifile.data["elevation"] = -250
92-
ifile.data["reference_surface"] = "topography"
93-
ifile.data["reference_type"] = "mean"
9489

9590
params = PlateSimulationOptions.build(ifile)
9691
assert isinstance(params.simulation, SimPEGGroup)
@@ -130,7 +125,4 @@ def test_plate_simulation_params_from_input_file(tmp_path):
130125

131126
assert params.model.plate_options.number == 9
132127
assert params.model.plate_options.spacing == 10.0
133-
assert params.model.plate_options.relative_locations
134-
assert params.model.plate_options.geometry.easting == 10.0
135-
assert params.model.plate_options.geometry.northing == 10.0
136128
assert params.model.plate_options.geometry.elevation == -250.0

tests/plate_simulation/runtest/gravity_test.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,14 @@ def test_gravity_plate_simulation(tmp_path):
6060
plate_params = PlateOptions(
6161
name="plate",
6262
geometry=PlateModel(
63-
easting=0.0,
64-
northing=0.0,
65-
elevation=-250.0,
63+
elevation=100.0,
6664
width=100.0,
6765
strike_length=100.0,
6866
dip_length=100.0,
6967
dip=0.0,
7068
direction=0.0,
7169
),
7270
plate_property=0.5,
73-
reference="center",
7471
)
7572

7673
model_params = ModelOptions(

tests/plate_simulation/runtest/sweep_test.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ def setup_plate_sweep(workspace) -> SimPEGGroup:
5656
options_dict["padding_distance"]["value"] = 1500.0
5757
options_dict["dip_direction"]["value"] = 0.0
5858
options_dict["number"]["value"] = 1
59-
options_dict["relative_locations"]["value"] = True
60-
options_dict["easting"]["value"] = 10.0
61-
options_dict["northing"]["value"] = 10.0
62-
options_dict["elevation"]["value"] = -250.0
63-
options_dict["reference_surface"]["value"] = "topography"
64-
options_dict["reference_type"]["value"] = "mean"
59+
options_dict["elevation"]["value"] = 100.0
6560
options_dict["out_group"]["value"] = str(simulation.uid)
6661
simulation.options = options_dict
6762

0 commit comments

Comments
 (0)