Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
adding function keep_tracks_by_date
  • Loading branch information
ludwigVonKoopa committed Mar 11, 2021
commit 0aa8302cdae37079ec0831b3a63cba3a8cf54c73
27 changes: 26 additions & 1 deletion src/py_eddy_tracker/observations/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,29 @@ def insert_virtual(self):
new_TEO.filled_by_interpolation(mask)
new_TEO.virtual[:] = mask
new_TEO.fix_next_previous_obs()
return new_TEO
return new_TEO

def keep_tracks_by_date(self, date, nb_days):
"""
find tracks which exist at date `date` and lasted at least `nb_days` after.

if nb_days is negative, it search a tracks which exist at the date,
but existed at least `nb_days` before the date


:param int,float date : date where the tracks must exist
:param int,float nb_days: number of time where the tracks must exist. Can be negative

"""

time = self.time

mask = zeros(time.shape, dtype=bool)

for i, b0, b1 in self.iter_on(self.tracks):
_time = time[i]

if date in _time and (date + nb_days) in _time:
mask[i] = True

return self.extract_with_mask(mask)