12
12
13
13
14
14
def interpolation_input_from_structural_frame (structural_frame : StructuralFrame , grid : Grid ,
15
- transform : Transform ) -> InterpolationInput :
15
+ input_transform : Transform ) -> InterpolationInput :
16
16
_legacy_factor = 0
17
17
18
18
if LEGACY_COORDS := False :
19
19
_legacy_factor = 0.5
20
20
21
+ total_transform : Transform = input_transform + grid .dense_grid .transform
22
+
21
23
surface_points_copy = structural_frame .surface_points_copy
22
24
surface_points : SurfacePoints = SurfacePoints (
23
- sp_coords = transform .apply (surface_points_copy .xyz ) + _legacy_factor ,
25
+ sp_coords = total_transform .apply (surface_points_copy .xyz ) + _legacy_factor ,
24
26
nugget_effect_scalar = surface_points_copy .nugget
25
27
)
26
28
27
29
orientations_copy = structural_frame .orientations_copy
28
30
orientations : Orientations = Orientations (
29
- dip_positions = transform .apply (orientations_copy .xyz ) + _legacy_factor ,
30
- dip_gradients = transform .transform_gradient (orientations_copy .grads ),
31
+ dip_positions = total_transform .apply (orientations_copy .xyz ) + _legacy_factor ,
32
+ dip_gradients = total_transform .transform_gradient (orientations_copy .grads ),
31
33
nugget_effect_grad = orientations_copy .nugget
32
34
)
33
35
34
- # region Transforming the grid
36
+ grid : engine_grid .EngineGrid = _apply_input_transform_to_grids (grid , input_transform )
37
+
35
38
36
- transformed = transform .apply (grid .bounding_box ) # ? isn't this making the regular grid not optional?
39
+ interpolation_input : InterpolationInput = InterpolationInput (
40
+ surface_points = surface_points ,
41
+ orientations = orientations ,
42
+ grid = grid ,
43
+ unit_values = structural_frame .elements_ids # TODO: Here we will need to pass densities etc.
44
+ )
45
+
46
+ return interpolation_input
47
+
48
+
49
+ def _apply_input_transform_to_grids (grid : Grid , input_transform : Transform ) -> engine_grid .EngineGrid :
50
+ transformed = input_transform .apply (grid .bounding_box ) # ! grid already has the grid transform applied
37
51
new_extents = np .array ([transformed [:, 0 ].min (), transformed [:, 0 ].max (),
38
52
transformed [:, 1 ].min (), transformed [:, 1 ].max (),
39
53
transformed [:, 2 ].min (), transformed [:, 2 ].max ()])
40
-
54
+
41
55
# Initialize all variables to None
42
56
octree_grid : Optional [engine_grid .RegularGrid ] = None
43
57
regular_grid : Optional [engine_grid .RegularGrid ] = None
44
58
custom_values : Optional [engine_grid .GenericGrid ] = None
45
59
topography_values : Optional [engine_grid .GenericGrid ] = None
46
60
section_values : Optional [engine_grid .GenericGrid ] = None
47
61
centered_grid : Optional [engine_grid .CenteredGrid ] = None
48
-
62
+
49
63
if grid .GridTypes .DENSE in grid .active_grids :
50
64
regular_grid = engine_grid .RegularGrid (
51
- extent = new_extents ,
65
+ orthogonal_extent = new_extents ,
52
66
regular_grid_shape = grid .dense_grid .resolution ,
53
- transform = grid .dense_grid .transform
54
67
)
55
-
56
68
if grid .GridTypes .CUSTOM in grid .active_grids and grid .custom_grid is not None :
57
- custom_values = engine_grid .GenericGrid (values = transform .apply (grid .custom_grid .values ))
58
-
69
+ custom_values = engine_grid .GenericGrid (values = input_transform .apply (grid .custom_grid .values ))
59
70
if grid .GridTypes .TOPOGRAPHY in grid .active_grids and grid .topography is not None :
60
- topography_values = engine_grid .GenericGrid (values = transform .apply (grid .topography .values ))
61
-
71
+ topography_values = engine_grid .GenericGrid (values = input_transform .apply (grid .topography .values ))
62
72
if grid .GridTypes .SECTIONS in grid .active_grids and grid .sections is not None :
63
- section_values = engine_grid .GenericGrid (values = transform .apply (grid .sections .values ))
64
-
73
+ section_values = engine_grid .GenericGrid (values = input_transform .apply (grid .sections .values ))
65
74
if grid .GridTypes .CENTERED in grid .active_grids and grid .centered_grid is not None :
66
75
centered_grid = engine_grid .CenteredGrid (
67
- centers = transform .apply (grid .centered_grid .centers ),
68
- radius = transform .scale_points (np .atleast_2d (grid .centered_grid .radius ))[0 ],
76
+ centers = input_transform .apply (grid .centered_grid .centers ),
77
+ radius = input_transform .scale_points (np .atleast_2d (grid .centered_grid .radius ))[0 ],
69
78
resolution = grid .centered_grid .resolution
70
79
)
71
-
72
80
octree_grid = engine_grid .RegularGrid (
73
- extent = new_extents ,
74
- regular_grid_shape = np .array ([2 , 2 , 2 ]),
75
- transform = grid .dense_grid .transform # ! That here we need to grab the dense grid smells
81
+ orthogonal_extent = new_extents ,
82
+ regular_grid_shape = np .array ([2 , 2 , 2 ])
76
83
)
77
-
78
84
grid : engine_grid .EngineGrid = engine_grid .EngineGrid ( # * Here we convert the GemPy grid to the
79
85
octree_grid = octree_grid , # BUG: Adapt the engine to deal with this
80
86
dense_grid = regular_grid ,
@@ -83,14 +89,4 @@ def interpolation_input_from_structural_frame(structural_frame: StructuralFrame,
83
89
custom_grid = custom_values ,
84
90
geophysics_grid = centered_grid
85
91
)
86
-
87
- # endregion
88
-
89
- interpolation_input : InterpolationInput = InterpolationInput (
90
- surface_points = surface_points ,
91
- orientations = orientations ,
92
- grid = grid ,
93
- unit_values = structural_frame .elements_ids # TODO: Here we will need to pass densities etc.
94
- )
95
-
96
- return interpolation_input
92
+ return grid
0 commit comments