Skip to content

Commit e31d0a7

Browse files
committed
add option to choose time step in particle candidate
1 parent 3acf1ab commit e31d0a7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/py_eddy_tracker/observations/groups.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def advect(x, y, c, t0, n_days, u_name="u", v_name="v"):
9191

9292

9393
def particle_candidate_step(
94-
t_start, contours_start, contours_end, space_step, dt, c, **kwargs
94+
t_start, contours_start, contours_end, space_step, dt, c, day_fraction=6, **kwargs
9595
):
9696
"""Select particles within eddies, advect them, return target observation and associated percentages.
9797
For one time step.
@@ -102,13 +102,17 @@ def particle_candidate_step(
102102
:param float space_step: step between 2 particles
103103
:param int dt: duration of advection
104104
:param `~py_eddy_tracker.dataset.grid.GridCollection` c: GridCollection with speed for particles
105+
:param int day_fraction: fraction of day
105106
:params dict kwargs: dict of params given to advection
106107
:return (np.array,np.array): return target index and percent associate
107108
"""
109+
# In case of zarr array
110+
contours_start = [i[:] for i in contours_start]
111+
contours_end = [i[:] for i in contours_end]
108112
# Create particles in start contour
109113
x, y, i_start = create_meshed_particles(*contours_start, space_step)
110114
# Advect particles
111-
kw = dict(nb_step=6, time_step=86400 / 6)
115+
kw = dict(nb_step=day_fraction, time_step=86400 / day_fraction)
112116
p = c.advect(x, y, t_init=t_start, **kwargs, **kw)
113117
for _ in range(dt):
114118
_, x, y = p.__next__()

0 commit comments

Comments
 (0)