@@ -12,7 +12,7 @@ class NearestSurfacePointsSearcher(enum.Enum):
12
12
13
13
14
14
def select_nearest_surfaces_points (surface_points_xyz : np .ndarray , searchcrit : Optional [int | float ] = 3 ,
15
- search_type : NearestSurfacePointsSearcher = NearestSurfacePointsSearcher .KNN
15
+ search_type : NearestSurfacePointsSearcher = NearestSurfacePointsSearcher .KNN
16
16
) -> np .ndarray :
17
17
match search_type :
18
18
case NearestSurfacePointsSearcher .KNN :
@@ -26,121 +26,4 @@ def select_nearest_surfaces_points(surface_points_xyz: np.ndarray, searchcrit: O
26
26
case _:
27
27
raise ValueError (f"Invalid search type: { search_type } " )
28
28
29
- return neighbours_surfaces
30
-
31
-
32
- def _select_nearest_surfaces_points (geo_model , surface_points , searchcrit ):
33
- """
34
- Find the neighbour points of the same surface
35
- by given radius (radius-search) or fix number (knn).
36
-
37
- Parameters
38
- ----------
39
- geo_model : geo_model
40
- GemPy-model.
41
- surface_points: Pandas-dataframe
42
- Contains the dataframe of the (point-)data from the GemPy-model.
43
- searchcrit : int or float
44
- if is int: uses knn-search.
45
- if is float: uses radius-search.
46
- """
47
-
48
- # extract surface names
49
- surfaces = np .unique (surface_points ['surface' ])
50
- neighbours = []
51
- # for each surface
52
- if isinstance (searchcrit , int ): # in case knn-search
53
- searchcrit = searchcrit + 1 # because the point itself is also found
54
- for s in range (surfaces .size ):
55
- # extract point-ids
56
- i_surfaces = surface_points ['surface' ] == surfaces [s ]
57
- # extract point coordinates
58
- p_surfaces = surface_points [i_surfaces ][['X' , 'Y' , 'Z' ]]
59
- # create search-tree
60
- Tree = NearestNeighbors (n_neighbors = searchcrit )
61
- # add data to tree
62
- Tree .fit (p_surfaces )
63
- # find neighbours
64
- neighbours_surfaces = Tree .kneighbors (p_surfaces , n_neighbors = searchcrit ,
65
- return_distance = False )
66
- # add neighbours with initial index to total list
67
- for n in neighbours_surfaces :
68
- neighbours .append (p_surfaces .index [n ])
69
- else : # in case radius-search
70
- for s in range (surfaces .size ):
71
- # extract point-ids
72
- i_surfaces = surface_points ['surface' ] == surfaces [s ]
73
- # extract point coordinates
74
- p_surfaces = surface_points [i_surfaces ][['X' , 'Y' , 'Z' ]]
75
- # create search-tree
76
- Tree = NearestNeighbors (radius = searchcrit )
77
- # add data to tree
78
- Tree .fit (p_surfaces )
79
- # find neighbours (attention: relativ index!)
80
- neighbours_surfaces = Tree .radius_neighbors (p_surfaces ,
81
- radius = searchcrit ,
82
- return_distance = False )
83
- # add neighbours with initial index to total list
84
- for n in neighbours_surfaces :
85
- neighbours .append (p_surfaces .index [n ])
86
- return neighbours
87
-
88
-
89
- def set_orientation_from_neighbours (geo_model , neighbours ):
90
- """
91
- Calculates the orientation of one point with its neighbour points
92
- of the same surface.
93
- Parameters
94
- ----------
95
- geo_model : geo_model
96
- GemPy-model.
97
- neighbours : Int64Index
98
- point-neighbours-id, first id is the point itself.
99
- """
100
-
101
- # compute normal vector for the point
102
- if neighbours .size > 2 :
103
- # extract point coordinates
104
- coo = geo_model ._surface_points .df .loc [neighbours ][['X' , 'Y' , 'Z' ]]
105
- # calculates covariance matrix
106
- cov = np .cov (coo .T )
107
- # calculate normalized normal vector
108
- normvec = normalize (np .cross (cov [0 ].T , cov [1 ].T ).reshape (1 , - 1 ))[0 ]
109
- # check orientation of normal vector (has to be oriented to sky)
110
- if normvec [2 ] < 0 :
111
- normvec = normvec * (- 1 )
112
- # append to the GemPy-model
113
- geo_model .add_orientations (geo_model ._surface_points .df ['X' ][neighbours [0 ]],
114
- geo_model ._surface_points .df ['Y' ][neighbours [0 ]],
115
- geo_model ._surface_points .df ['Z' ][neighbours [0 ]],
116
- geo_model ._surface_points .df ['surface' ][neighbours [0 ]],
117
- normvec .tolist ())
118
- # if computation is impossible set normal vector to default orientation
119
- else :
120
- print ("orientation calculation of point" + str (neighbours [0 ]) + "is impossible" )
121
- print ("-> default vector is set [0,0,1]" )
122
- geo_model .add_orientations (geo_model ._surface_points .df ['X' ][neighbours [0 ]],
123
- geo_model ._surface_points .df ['Y' ][neighbours [0 ]],
124
- geo_model ._surface_points .df ['Z' ][neighbours [0 ]],
125
- geo_model ._surface_points .df ['surface' ][neighbours [0 ]],
126
- orientation = [0 , 0 , 1 ])
127
- return geo_model ._orientations
128
-
129
-
130
- def set_orientation_from_neighbours_all (geo_model , neighbours ):
131
- """
132
- Calculates the orientations for all points with given neighbours.
133
- Parameters
134
- ----------
135
- geo_model : geo_model
136
- GemPy-model.
137
- neighbours : list of Int64Index
138
- point-neighbours-IDs, the first id is the id of the point
139
- for which the orientation is calculated.
140
- """
141
-
142
- # compute normal vector for the points
143
- for n in neighbours :
144
- set_orientation_from_neighbours (geo_model , n )
145
-
146
- return geo_model ._orientations
29
+ return neighbours_surfaces
0 commit comments