1111import numpy as np
1212import scipy .sparse as ssp
1313from discretize import TreeMesh
14- from geoapps_utils .utils .transformations import normal_to_direction_and_dip
14+ from geoapps_utils .utils .transformations import (
15+ cartesian_normal_to_direction_and_dip ,
16+ x_rotation_matrix ,
17+ z_rotation_matrix ,
18+ )
1519from geoh5py .groups import PropertyGroup
1620from geoh5py .groups .property_group_type import GroupTypeEnum
1721from simpeg .regularization import SparseSmoothness
@@ -194,18 +198,11 @@ def rotate_yz_3d(mesh: TreeMesh, theta: np.ndarray) -> ssp.csr_matrix:
194198 :param theta: Angle in radians for clockwise rotation about the
195199 x-axis (yz plane).
196200 """
197-
198- n_cells = len (theta )
199201 hy = mesh .h_gridded [:, 1 ]
200202 hz = mesh .h_gridded [:, 2 ]
201203 theta = - np .arctan2 ((np .sin (theta ) / hz ), (np .cos (theta ) / hy ))
202204
203- rxa = mkvc (np .c_ [np .ones (n_cells ), np .cos (theta ), np .cos (theta )].T )
204- rxb = mkvc (np .c_ [np .zeros (n_cells ), np .sin (theta ), np .zeros (n_cells )].T )
205- rxc = mkvc (np .c_ [np .zeros (n_cells ), - np .sin (theta ), np .zeros (n_cells )].T )
206- Rx = ssp .diags ([rxb [:- 1 ], rxa , rxc [:- 1 ]], [- 1 , 0 , 1 ])
207-
208- return Rx
205+ return x_rotation_matrix (theta )
209206
210207
211208def rotate_xy_3d (mesh : TreeMesh , phi : np .ndarray ) -> ssp .csr_matrix :
@@ -217,17 +214,11 @@ def rotate_xy_3d(mesh: TreeMesh, phi: np.ndarray) -> ssp.csr_matrix:
217214 :param phi: Angle in radians for clockwise rotation about the
218215 z-axis (xy plane).
219216 """
220- n_cells = len (phi )
221217 hx = mesh .h_gridded [:, 0 ]
222218 hy = mesh .h_gridded [:, 1 ]
223219 phi = - np .arctan2 ((np .sin (phi ) / hy ), (np .cos (phi ) / hx ))
224220
225- rza = mkvc (np .c_ [np .cos (phi ), np .cos (phi ), np .ones (n_cells )].T )
226- rzb = mkvc (np .c_ [np .sin (phi ), np .zeros (n_cells ), np .zeros (n_cells )].T )
227- rzc = mkvc (np .c_ [- np .sin (phi ), np .zeros (n_cells ), np .zeros (n_cells )].T )
228- Rz = ssp .diags ([rzb [:- 1 ], rza , rzc [:- 1 ]], [- 1 , 0 , 1 ])
229-
230- return Rz
221+ return z_rotation_matrix (phi )
231222
232223
233224def get_cell_normals (n_cells : int , axis : str , outward : bool ) -> np .ndarray :
@@ -408,7 +399,7 @@ def ensure_dip_direction_convention(
408399 """
409400
410401 if group_type == GroupTypeEnum .VECTOR :
411- orientations = np .rad2deg (normal_to_direction_and_dip (orientations ))
402+ orientations = np .rad2deg (cartesian_normal_to_direction_and_dip (orientations ))
412403
413404 if group_type in [GroupTypeEnum .STRIKEDIP ]:
414405 orientations [:, 0 ] = 90.0 + orientations [:, 0 ]
0 commit comments