1313from geoh5py .objects import DrapeModel , Octree , Surface
1414from scipy .spatial import Delaunay
1515
16- from simpeg_drivers .utils .synthetics .options import SurveyOptions
16+ from simpeg_drivers .utils .synthetics .options import (
17+ MeshOptions ,
18+ SurveyOptions ,
19+ SyntheticsComponentsOptions ,
20+ )
1721from simpeg_drivers .utils .synthetics .surveys .factory import grid_layout
1822from simpeg_drivers .utils .utils import active_from_xyz
1923
2024
21- def get_topography_surface (geoh5 : Workspace , options : SurveyOptions ) -> Surface :
25+ def get_topography_surface (
26+ geoh5 : Workspace , options : SyntheticsComponentsOptions
27+ ) -> Surface :
2228 """
23- Returns a topography surface with 2x the limits of the survey.
29+ Returns topography with same limits as the mesh and 2x resolution of the survey.
2430
2531 :param geoh5: Geoh5 workspace.
26- :param options: Survey options. Extents will be 2x the survey extents .
32+ :param options: Options containing survey and mesh specifications .
2733 """
2834
35+ width , height = compute_mesh_extents (options .survey , options .mesh )
2936 X , Y , Z = grid_layout (
30- limits = [4 * k for k in options .limits ], # type: ignore
31- station_spacing = int (np .ceil ((options .limits [1 ] - options .limits [0 ]) / 16 )),
32- line_spacing = int (np .ceil ((options .limits [3 ] - options .limits [2 ]) / 16 )),
33- topography = options .topography ,
37+ limits = [
38+ options .survey .center [0 ] - width / 2 ,
39+ options .survey .center [0 ] + width / 2 ,
40+ options .survey .center [1 ] - height / 2 ,
41+ options .survey .center [1 ] + height / 2 ,
42+ ],
43+ n_stations = int (2 * width / (options .survey .width / options .survey .n_stations )),
44+ n_lines = int (2 * height / (options .survey .height / options .survey .n_lines )),
45+ topography = options .survey .topography ,
3446 )
3547
3648 vertices = np .column_stack (
@@ -45,6 +57,32 @@ def get_topography_surface(geoh5: Workspace, options: SurveyOptions) -> Surface:
4557 )
4658
4759
60+ def compute_mesh_extents (
61+ survey_options : SurveyOptions , mesh_options : MeshOptions
62+ ) -> tuple [float , float ]:
63+ """
64+ Estimates the extent of the mesh from survey and mesh options.
65+
66+ :param survey_options: Survey options.
67+ :param mesh_options: Mesh options.
68+
69+ :return: mesh width including padding.
70+ :return: mesh height including padding.
71+ """
72+ width = survey_options .width
73+ height = survey_options .height
74+ cell_size = mesh_options .cell_size
75+ padding = mesh_options .padding_distance
76+
77+ def next_pow2_cells (span , cell_size , padding ):
78+ return 2 ** np .ceil (np .log2 ((span + 2 * padding ) / cell_size ))
79+
80+ return (
81+ cell_size [0 ] * next_pow2_cells (width , cell_size [0 ], padding ),
82+ cell_size [1 ] * next_pow2_cells (height , cell_size [1 ], padding ),
83+ )
84+
85+
4886def get_active (
4987 mesh : Octree | DrapeModel , topography : Surface , name : str = "active_cells"
5088):
0 commit comments