Skip to content

Commit 89e6488

Browse files
ludwigVonKoopaAntSimi
authored andcommitted
adding function keep_tracks_by_date
1 parent a63344f commit 89e6488

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/py_eddy_tracker/observations/groups.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,29 @@ def insert_virtual(self):
124124
new_TEO.filled_by_interpolation(mask)
125125
new_TEO.virtual[:] = mask
126126
new_TEO.fix_next_previous_obs()
127-
return new_TEO
127+
return new_TEO
128+
129+
def keep_tracks_by_date(self, date, nb_days):
130+
"""
131+
find tracks which exist at date `date` and lasted at least `nb_days` after.
132+
133+
if nb_days is negative, it search a tracks which exist at the date,
134+
but existed at least `nb_days` before the date
135+
136+
137+
:param int,float date : date where the tracks must exist
138+
:param int,float nb_days: number of time where the tracks must exist. Can be negative
139+
140+
"""
141+
142+
time = self.time
143+
144+
mask = zeros(time.shape, dtype=bool)
145+
146+
for i, b0, b1 in self.iter_on(self.tracks):
147+
_time = time[i]
148+
149+
if date in _time and (date + nb_days) in _time:
150+
mask[i] = True
151+
152+
return self.extract_with_mask(mask)

0 commit comments

Comments
 (0)