We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5e78201 commit d6e3304Copy full SHA for d6e3304
src/anemoi/datasets/grids.py
@@ -151,7 +151,6 @@ def cutout_mask(
151
):
152
"""Return a mask for the points in [global_lats, global_lons] that are inside of [lats, lons]"""
153
from scipy.spatial import KDTree
154
- from scipy.spatial import distance_matrix
155
156
# TODO: transform min_distance from lat/lon to xyz
157
@@ -198,9 +197,8 @@ def cutout_mask(
198
197
if min_distance_km is not None:
199
min_distance = min_distance_km / 6371.0
200
else:
201
- min_distance = 0
202
- dm = distance_matrix(global_points, global_points)
203
- min_distance = np.min(dm[dm > 0])
+ distances, _ = KDTree(global_points).query(global_points, k=2)
+ min_distance = np.min(distances[:, 1])
204
205
LOG.debug(f"cutout_mask using min_distance = {min_distance * 6371.0} km")
206
0 commit comments