Skip to content

Commit f1260a0

Browse files
committed
modify advect option
1 parent 38b223a commit f1260a0

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

examples/06_grid_manipulation/pet_advect.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def save(self, *args, **kwargs):
7373
# %%
7474
# Movie properties
7575
kwargs = dict(frames=arange(51), interval=100)
76-
kw_p = dict(nb_step=2, time_step=21600)
76+
kw_p = dict(u_name="u", v_name="v", nb_step=2, time_step=21600)
7777
frame_t = kw_p["nb_step"] * kw_p["time_step"] / 86400.0
7878

7979

@@ -102,21 +102,21 @@ def update(i_frame, t_step):
102102
# ^^^^^^^^^^^^^^^^
103103
# Draw 3 last position in one path for each particles.,
104104
# it could be run backward with `backward=True` option in filament method
105-
p = g.filament(x, y, "u", "v", **kw_p, filament_size=3)
105+
p = g.filament(x, y, **kw_p, filament_size=3)
106106
fig, txt, l, t = anim_ax(lw=0.5)
107107
_ = VideoAnimation(fig, update, **kwargs, fargs=(frame_t,))
108108

109109
# %%
110110
# Particle forward
111111
# ^^^^^^^^^^^^^^^^^
112112
# Forward advection of particles
113-
p = g.advect(x, y, "u", "v", **kw_p)
113+
p = g.advect(x, y, **kw_p)
114114
fig, txt, l, t = anim_ax(ls="", marker=".", markersize=1)
115115
_ = VideoAnimation(fig, update, **kwargs, fargs=(frame_t,))
116116

117117
# %%
118118
# We get last position and run backward until original position
119-
p = g.advect(x, y, "u", "v", **kw_p, backward=True)
119+
p = g.advect(x, y, **kw_p, backward=True)
120120
fig, txt, l, _ = anim_ax(ls="", marker=".", markersize=1)
121121
_ = VideoAnimation(fig, update, **kwargs, fargs=(-frame_t,))
122122

@@ -139,9 +139,9 @@ def update(i_frame, t_step):
139139
)
140140
for time_step in (10800, 21600, 43200, 86400):
141141
x, y = x0.copy(), y0.copy()
142-
kw_advect = dict(nb_step=int(50 * 86400 / time_step), time_step=time_step)
143-
g.advect(x, y, "u", "v", **kw_advect).__next__()
144-
g.advect(x, y, "u", "v", **kw_advect, backward=True).__next__()
142+
kw_advect = dict(nb_step=int(50 * 86400 / time_step), time_step=time_step, u_name="u", v_name="v")
143+
g.advect(x, y, **kw_advect).__next__()
144+
g.advect(x, y, **kw_advect, backward=True).__next__()
145145
d = ((x - x0) ** 2 + (y - y0) ** 2) ** 0.5
146146
ax.hist(d, **kw, label=f"{86400. / time_step:.0f} time step by day")
147147
ax.set_xlim(0, 0.25), ax.set_ylim(0, 100), ax.legend(loc="lower right"), ax.grid()
@@ -158,9 +158,9 @@ def update(i_frame, t_step):
158158
time_step = 10800
159159
for duration in (5, 50, 100):
160160
x, y = x0.copy(), y0.copy()
161-
kw_advect = dict(nb_step=int(duration * 86400 / time_step), time_step=time_step)
162-
g.advect(x, y, "u", "v", **kw_advect).__next__()
163-
g.advect(x, y, "u", "v", **kw_advect, backward=True).__next__()
161+
kw_advect = dict(nb_step=int(duration * 86400 / time_step), time_step=time_step, u_name="u", v_name="v")
162+
g.advect(x, y, **kw_advect).__next__()
163+
g.advect(x, y, **kw_advect, backward=True).__next__()
164164
d = ((x - x0) ** 2 + (y - y0) ** 2) ** 0.5
165165
ax.hist(d, **kw, label=f"Time duration {duration} days")
166166
ax.set_xlim(0, 0.25), ax.set_ylim(0, 100), ax.legend(loc="lower right"), ax.grid()

examples/06_grid_manipulation/pet_lavd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def save(self, *args, **kwargs):
110110
step_by_day = 3
111111
# Compute step of advection every 4h
112112
nb_step = 2
113-
kw_p = dict(nb_step=nb_step, time_step=86400 / step_by_day / nb_step)
113+
kw_p = dict(nb_step=nb_step, time_step=86400 / step_by_day / nb_step, u_name="u", v_name="v")
114114
# Start a generator which at each iteration return new position at next time step
115-
particule = g.advect(x, y, "u", "v", **kw_p, rk4=True)
115+
particule = g.advect(x, y, **kw_p, rk4=True)
116116

117117
# %%
118118
# LAVD

examples/07_cube_manipulation/pet_fsle_med.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ def build_triplet(x, y, step=0.02):
142142
used = zeros(x.shape[0], dtype="bool")
143143

144144
# advection generator
145-
kw = dict(t_init=t0, nb_step=1, backward=backward, mask_particule=used)
146-
p = c.advect(x, y, "u", "v", time_step=86400 / time_step_by_days, **kw)
145+
kw = dict(t_init=t0, nb_step=1, backward=backward, mask_particule=used, u_name="u", v_name="v")
146+
p = c.advect(x, y, time_step=86400 / time_step_by_days, **kw)
147147

148148
# We check at each step of advection if particle distance is over `dist_max`
149149
for i in range(time_step_by_days * nb_days):

examples/07_cube_manipulation/pet_lavd_detection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def update_axes(ax, mappable=None):
9393
# Time properties, for example with advection only 25 days
9494
nb_days, step_by_day = 25, 6
9595
nb_time = step_by_day * nb_days
96-
kw_p = dict(nb_step=1, time_step=86400 / step_by_day)
96+
kw_p = dict(nb_step=1, time_step=86400 / step_by_day, u_name="u", v_name="v")
9797
t0 = 20236
9898
t0_grid = c[t0]
9999
# Geographic properties, we use a coarser resolution for time consuming reasons
@@ -114,7 +114,7 @@ def update_axes(ax, mappable=None):
114114
# ----------------------------
115115
lavd = zeros(original_shape)
116116
lavd_ = lavd[m]
117-
p = c.advect(x0.copy(), y0.copy(), "u", "v", t_init=t0, **kw_p)
117+
p = c.advect(x0.copy(), y0.copy(), t_init=t0, **kw_p)
118118
for _ in range(nb_time):
119119
t, x, y = p.__next__()
120120
lavd_ += abs(c.interp("vort", t / 86400.0, x, y))
@@ -131,7 +131,7 @@ def update_axes(ax, mappable=None):
131131
# -----------------------------
132132
lavd = zeros(original_shape)
133133
lavd_ = lavd[m]
134-
p = c.advect(x0.copy(), y0.copy(), "u", "v", t_init=t0, backward=True, **kw_p)
134+
p = c.advect(x0.copy(), y0.copy(), t_init=t0, backward=True, **kw_p)
135135
for i in range(nb_time):
136136
t, x, y = p.__next__()
137137
lavd_ += abs(c.interp("vort", t / 86400.0, x, y))
@@ -148,7 +148,7 @@ def update_axes(ax, mappable=None):
148148
# ---------------------------
149149
lavd = zeros(original_shape)
150150
lavd_ = lavd[m]
151-
p = t0_grid.advect(x0.copy(), y0.copy(), "u", "v", **kw_p)
151+
p = t0_grid.advect(x0.copy(), y0.copy(), **kw_p)
152152
for _ in range(nb_time):
153153
x, y = p.__next__()
154154
lavd_ += abs(t0_grid.interp("vort", x, y))
@@ -165,7 +165,7 @@ def update_axes(ax, mappable=None):
165165
# ----------------------------
166166
lavd = zeros(original_shape)
167167
lavd_ = lavd[m]
168-
p = t0_grid.advect(x0.copy(), y0.copy(), "u", "v", backward=True, **kw_p)
168+
p = t0_grid.advect(x0.copy(), y0.copy(), backward=True, **kw_p)
169169
for i in range(nb_time):
170170
x, y = p.__next__()
171171
lavd_ += abs(t0_grid.interp("vort", x, y))

examples/16_network/pet_follow_particle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def save(self, *args, **kwargs):
9595
a.txt.set_position((25, 31))
9696

9797
step = 0.25
98-
kw_p = dict(nb_step=2, time_step=86400 * step * 0.5, t_init=t_snapshot - 2 * step)
98+
kw_p = dict(nb_step=2, time_step=86400 * step * 0.5, t_init=t_snapshot - 2 * step, u_name="u", v_name="v")
9999

100100
mappables = dict()
101-
particules = c.advect(x, y, "u", "v", **kw_p)
102-
filament = c.filament(x_f, y_f, "u", "v", **kw_p, filament_size=3)
101+
particules = c.advect(x, y, **kw_p)
102+
filament = c.filament(x_f, y_f, **kw_p, filament_size=3)
103103
kw = dict(ls="", marker=".", markersize=0.25)
104104
for k in index_:
105105
m = k == index

0 commit comments

Comments
 (0)