Skip to content

Commit 16438f2

Browse files
committed
Option for network segmentation
1 parent 0a0b061 commit 16438f2

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/py_eddy_tracker/appli/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def divide_network():
5050
args.input,
5151
include_vars=("time", "track", "latitude", "longitude", *contour_name),
5252
)
53-
ids = e.split_network(intern=args.intern, window=args.window)
53+
ids = e.split_network(intern=args.intern, window=args.window, minimal_area=False)
5454
e = e.add_fields(("sub_track",))
5555
e.sub_track[:] = ids["track"]
5656
e.write_file(filename=args.out)

src/py_eddy_tracker/observations/tracking.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ def split_network(self, intern=True, **kwargs):
626626
local_ids["next_obs"][m] += i_s
627627
return ids
628628

629-
def set_tracks(self, x, y, ids, window):
629+
def set_tracks(self, x, y, ids, window, **kwargs):
630630
"""
631631
Will split one group in tracks
632632
@@ -645,20 +645,20 @@ def set_tracks(self, x, y, ids, window):
645645
# If observation already in one track, we go to the next one
646646
if used[i]:
647647
continue
648-
self.follow_obs(i, track_id, used, ids, x, y, *time_index, window)
648+
self.follow_obs(i, track_id, used, ids, x, y, *time_index, window, **kwargs)
649649
track_id += 1
650650
# Search a possible ancestor
651-
self.previous_obs(i, ids, x, y, *time_index, window)
651+
self.previous_obs(i, ids, x, y, *time_index, window, **kwargs)
652652

653653
@classmethod
654-
def follow_obs(cls, i_next, track_id, used, ids, *args):
654+
def follow_obs(cls, i_next, track_id, used, ids, *args, **kwargs):
655655
while i_next != -1:
656656
# Flag
657657
used[i_next] = True
658658
# Assign id
659659
ids["track"][i_next] = track_id
660660
# Search next
661-
i_next_ = cls.next_obs(i_next, ids, *args)
661+
i_next_ = cls.next_obs(i_next, ids, *args, **kwargs)
662662
if i_next_ == -1:
663663
break
664664
ids["next_obs"][i_next] = i_next_
@@ -674,7 +674,7 @@ def follow_obs(cls, i_next, track_id, used, ids, *args):
674674
i_next = i_next_
675675

676676
@staticmethod
677-
def previous_obs(i_current, ids, x, y, time_s, time_e, time_ref, window):
677+
def previous_obs(i_current, ids, x, y, time_s, time_e, time_ref, window, **kwargs):
678678
time_cur = ids["time"][i_current]
679679
t0, t1 = time_cur - 1 - time_ref, max(time_cur - window - time_ref, 0)
680680
for t_step in range(t0, t1 - 1, -1):
@@ -688,9 +688,9 @@ def previous_obs(i_current, ids, x, y, time_s, time_e, time_ref, window):
688688
if len(ii) == 0:
689689
continue
690690
c = zeros(len(xj))
691-
c[ij] = vertice_overlap(xi[ii], yi[ii], xj[ij], yj[ij], minimal_area=True)
691+
c[ij] = vertice_overlap(xi[ii], yi[ii], xj[ij], yj[ij], **kwargs)
692692
# We remove low overlap
693-
c[c < 0.1] = 0
693+
c[c < 0.01] = 0
694694
# We get index of maximal overlap
695695
i = c.argmax()
696696
c_i = c[i]
@@ -702,7 +702,7 @@ def previous_obs(i_current, ids, x, y, time_s, time_e, time_ref, window):
702702
break
703703

704704
@staticmethod
705-
def next_obs(i_current, ids, x, y, time_s, time_e, time_ref, window):
705+
def next_obs(i_current, ids, x, y, time_s, time_e, time_ref, window, **kwargs):
706706
time_max = time_e.shape[0] - 1
707707
time_cur = ids["time"][i_current]
708708
t0, t1 = time_cur + 1 - time_ref, min(time_cur + window - time_ref, time_max)
@@ -719,9 +719,9 @@ def next_obs(i_current, ids, x, y, time_s, time_e, time_ref, window):
719719
if len(ii) == 0:
720720
continue
721721
c = zeros(len(xj))
722-
c[ij] = vertice_overlap(xi[ii], yi[ii], xj[ij], yj[ij], minimal_area=True)
722+
c[ij] = vertice_overlap(xi[ii], yi[ii], xj[ij], yj[ij], **kwargs)
723723
# We remove low overlap
724-
c[c < 0.1] = 0
724+
c[c < 0.01] = 0
725725
# We get index of maximal overlap
726726
i = c.argmax()
727727
c_i = c[i]

0 commit comments

Comments
 (0)