Skip to content

Commit 9b2d526

Browse files
committed
Allow to set the number of maxima in same contour
Add method to iterate on group of observation Add method to align two dataset Allow to load a slice instead of whole file Add function to get bins statistic
1 parent 54a25c2 commit 9b2d526

File tree

6 files changed

+225
-84
lines changed

6 files changed

+225
-84
lines changed

src/py_eddy_tracker/dataset/grid.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
uniform_resample,
5454
coordinates_to_local,
5555
local_to_coordinates,
56-
get_pixel_in_regular,
5756
nearest_grd_indice,
5857
bbox_indice_regular,
5958
)
@@ -63,6 +62,7 @@
6362
create_vertice,
6463
poly_area,
6564
fit_circle,
65+
get_pixel_in_regular,
6666
)
6767

6868
logger = logging.getLogger("pet")
@@ -577,6 +577,7 @@ def eddy_identification(
577577
precision=None,
578578
force_height_unit=None,
579579
force_speed_unit=None,
580+
mle=1,
580581
):
581582
"""
582583
Compute eddy identification on specified grid
@@ -743,6 +744,7 @@ def eddy_identification(
743744
anticyclonic_search=anticyclonic_search,
744745
level=self.contours.levels[corrected_coll_index],
745746
step=step,
747+
mle=mle,
746748
)
747749
# If we have a valid amplitude
748750
if (not amp.within_amplitude_limits()) or (amp.amplitude == 0):
@@ -971,7 +973,13 @@ def _gaussian_filter(data, sigma, mode="reflect"):
971973

972974
@staticmethod
973975
def get_amplitude(
974-
contour, contour_height, data, anticyclonic_search=True, level=None, step=None
976+
contour,
977+
contour_height,
978+
data,
979+
anticyclonic_search=True,
980+
level=None,
981+
step=None,
982+
mle=1,
975983
):
976984
# Instantiate Amplitude object
977985
amp = Amplitude(
@@ -983,6 +991,8 @@ def get_amplitude(
983991
data=data,
984992
# Step by level
985993
interval=step,
994+
# Set number max of local maxima
995+
mle=mle,
986996
)
987997

988998
if anticyclonic_search:
@@ -1821,7 +1831,9 @@ def regrid(self, other, grid_name, new_name=None):
18211831
new_name = grid_name
18221832
x, y = meshgrid(self.x_c, self.y_c)
18231833
# interp and reshape
1824-
v_interp = other.interp(grid_name, x.reshape(-1), y.reshape(-1)).reshape(x.shape).T
1834+
v_interp = (
1835+
other.interp(grid_name, x.reshape(-1), y.reshape(-1)).reshape(x.shape).T
1836+
)
18251837
v_interp = ma.array(v_interp, mask=isnan(v_interp))
18261838
# and add it to self
18271839
self.add_grid(new_name, v_interp)

src/py_eddy_tracker/eddy_feature.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Amplitude(object):
6161
"mle",
6262
)
6363

64-
def __init__(self, contour, contour_height, data, interval):
64+
def __init__(self, contour, contour_height, data, interval, mle=1):
6565
# Height of the contour
6666
self.h_0 = contour_height
6767
# Step minimal to consider amplitude
@@ -97,7 +97,7 @@ def __init__(self, contour, contour_height, data, interval):
9797
# Amplitude which will be provide
9898
self.amplitude = 0
9999
# Maximum local extrema accepted
100-
self.mle = 1
100+
self.mle = mle
101101

102102
def within_amplitude_limits(self):
103103
"""Need update

src/py_eddy_tracker/generic.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@
3737
zeros,
3838
isnan,
3939
bool_,
40-
concatenate,
4140
radians,
4241
histogram,
4342
)
4443
from numba import njit, prange, types as numba_types
45-
from .poly import winding_number_grid_in_poly
4644

4745

4846
@njit(cache=True)
@@ -500,47 +498,6 @@ def bbox_indice_regular(vertices, x0, y0, xstep, ystep, N, circular, x_size):
500498
return slice_x, slice_y
501499

502500

503-
@njit(cache=True, fastmath=True)
504-
def get_pixel_in_regular(vertices, x_c, y_c, x_start, x_stop, y_start, y_stop):
505-
"""
506-
Get a pixel list of a regular grid contain in a contour.
507-
508-
:param array_like vertices: contour vertice (N,2)
509-
:param array_like x_c: longitude coordinate of grid
510-
:param array_like y_c: latitude coordinate of grid
511-
:param int x_start: west index of contour
512-
:param int y_start: east index of contour
513-
:param int x_stop: south index of contour
514-
:param int y_stop: north index of contour
515-
"""
516-
if x_stop < x_start:
517-
x_ref = vertices[0, 0]
518-
x_array = (
519-
(concatenate((x_c[x_start:], x_c[:x_stop])) - x_ref + 180) % 360
520-
+ x_ref
521-
- 180
522-
)
523-
return winding_number_grid_in_poly(
524-
x_array,
525-
y_c[y_start:y_stop],
526-
x_start,
527-
x_stop,
528-
x_c.shape[0],
529-
y_start,
530-
vertices,
531-
)
532-
else:
533-
return winding_number_grid_in_poly(
534-
x_c[x_start:x_stop],
535-
y_c[y_start:y_stop],
536-
x_start,
537-
x_stop,
538-
x_c.shape[0],
539-
y_start,
540-
vertices,
541-
)
542-
543-
544501
def build_circle(x0, y0, r):
545502
"""
546503
Build circle from center coordinates.

0 commit comments

Comments
 (0)