Skip to content

Commit 64b92c0

Browse files
committed
Could specify mask to be able to inactiv some particle
1 parent 938e279 commit 64b92c0

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/py_eddy_tracker/dataset/grid.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,6 +2369,7 @@ def advect(
23692369
u_name,
23702370
v_name,
23712371
t_init,
2372+
mask_particule=None,
23722373
nb_step=10,
23732374
time_step=600,
23742375
rk4=True,
@@ -2391,7 +2392,10 @@ def advect(
23912392
t1 = t1 * 86400
23922393
t = t_init * 86400
23932394
advect_ = advect_t_rk4 if rk4 else advect_t
2394-
mp = isnan(x) + isnan(y)
2395+
if mask_particule is None:
2396+
mask_particule = isnan(x) + isnan(y)
2397+
else:
2398+
mask_particule += isnan(x) + isnan(y)
23952399
while True:
23962400
if (backward and t <= t1) or (not backward and t >= t1):
23972401
t0, u0, v0, m0 = t1, u1, v1, m1
@@ -2400,7 +2404,21 @@ def advect(
24002404
u1, v1, m1 = d1.uv_for_advection(u_name, v_name, time_step, **kw)
24012405
w = 1 - (arange(t, t + dt, t_step) - t0) / (t1 - t0)
24022406
half_w = t_step / 2.0 / (t1 - t0)
2403-
advect_(d0.x_c, d0.y_c, u0, v0, m0, u1, v1, m1, x, y, mp, w, half_w=half_w)
2407+
advect_(
2408+
d0.x_c,
2409+
d0.y_c,
2410+
u0,
2411+
v0,
2412+
m0,
2413+
u1,
2414+
v1,
2415+
m1,
2416+
x,
2417+
y,
2418+
mask_particule,
2419+
w,
2420+
half_w=half_w,
2421+
)
24042422
t += dt
24052423
yield t, x, y
24062424

0 commit comments

Comments
 (0)