Skip to content

Commit 896694b

Browse files
committed
Reset of poly_indexs due to an unknown segmentation fault
1 parent 32f6b36 commit 896694b

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/py_eddy_tracker/poly.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ def box_indexes(x, y, step):
815815

816816

817817
@njit(cache=True)
818-
def poly_indexs(x_p, y_p, x_c, y_c):
818+
def poly_indexs_(x_p, y_p, x_c, y_c):
819819
"""
820820
Index of contour for each postion inside a contour, -1 in case of no contour
821821
@@ -873,6 +873,34 @@ def poly_indexs(x_p, y_p, x_c, y_c):
873873
return indexs
874874

875875

876+
@njit(cache=True)
877+
def poly_indexs(x_p, y_p, x_c, y_c):
878+
"""
879+
index of contour for each postion inside a contour, -1 in case of no contour
880+
881+
:param array x_p: longitude to test
882+
:param array y_p: latitude to test
883+
:param array x_c: longitude of contours
884+
:param array y_c: latitude of contours
885+
"""
886+
nb_p = x_p.shape[0]
887+
nb_c = x_c.shape[0]
888+
indexs = -ones(nb_p, dtype=numba_types.int32)
889+
for i in range(nb_c):
890+
x_, y_ = reduce_size(x_c[i], y_c[i])
891+
x_c_min, y_c_min = x_.min(), y_.min()
892+
x_c_max, y_c_max = x_.max(), y_.max()
893+
v = create_vertice(x_, y_)
894+
for j in range(nb_p):
895+
if indexs[j] != -1:
896+
continue
897+
x, y = x_p[j], y_p[j]
898+
if x > x_c_min and x < x_c_max and y > y_c_min and y < y_c_max:
899+
if winding_number_poly(x, y, v) != 0:
900+
indexs[j] = i
901+
return indexs
902+
903+
876904
@njit(cache=True)
877905
def insidepoly(x_p, y_p, x_c, y_c):
878906
"""

0 commit comments

Comments
 (0)