@@ -711,16 +711,14 @@ def eddy_identification(
711
711
i_x_in , i_y_in = contour .pixels_in (self )
712
712
713
713
# Check if pixels in contour are masked
714
- if data .mask [ i_x_in , i_y_in ]. any ( ):
714
+ if has_masked_value ( data .mask , i_x_in , i_y_in ):
715
715
continue
716
716
717
717
# Test to know cyclone or anticyclone
718
- if anticyclonic_search :
719
- if (data [i_x_in , i_y_in ] < cvalues ).any ():
720
- continue
721
- else :
722
- if (data [i_x_in , i_y_in ] > cvalues ).any ():
723
- continue
718
+ if has_value (
719
+ data , i_x_in , i_y_in , cvalues , below = anticyclonic_search
720
+ ):
721
+ continue
724
722
725
723
# FIXME : Maybe limit max must be replace with a maximum of surface
726
724
if (
@@ -1857,3 +1855,23 @@ def _nearest_grd_indice(x, y, x0, y0, xstep, ystep):
1857
1855
numba_types .int32 (round (((x - x0 [0 ]) % 360.0 ) / xstep )),
1858
1856
numba_types .int32 (round ((y - y0 [0 ]) / ystep )),
1859
1857
)
1858
+
1859
+
1860
+ @njit (cache = True )
1861
+ def has_masked_value (grid , i_x , i_y ):
1862
+ for i , j in zip (i_x , i_y ):
1863
+ if grid [i , j ]:
1864
+ return True
1865
+ return False
1866
+
1867
+
1868
+ @njit (cache = True )
1869
+ def has_value (grid , i_x , i_y , value , below = False ):
1870
+ for i , j in zip (i_x , i_y ):
1871
+ if below :
1872
+ if grid [i , j ] < value :
1873
+ return True
1874
+ else :
1875
+ if grid [i , j ] > value :
1876
+ return True
1877
+ return False
0 commit comments