示例#1
0

# %%
# Filament forward
# ^^^^^^^^^^^^^^^^
# Draw 3 last position in one path for each particles.,
# it could be run backward with `backward=True` option in filament method
p = g.filament(x, y, "u", "v", **kw_p, filament_size=3)
fig, txt, l, t = anim_ax(lw=0.5)
_ = VideoAnimation(fig, update, **kwargs, fargs=(frame_t, ))

# %%
# Particle forward
# ^^^^^^^^^^^^^^^^^
# Forward advection of particles
p = g.advect(x, y, "u", "v", **kw_p)
fig, txt, l, t = anim_ax(ls="", marker=".", markersize=1)
_ = VideoAnimation(fig, update, **kwargs, fargs=(frame_t, ))

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

# %%
# Particles stat
# --------------

# %%
# Time_step settings
示例#2
0
    txt.set_text(f"T0 + {t:.1f} days")


# %%
# Filament forward
# ^^^^^^^^^^^^^^^^
p = g.filament(x, y, "u", "v", **kw_p, filament_size=4, rk4=True)
fig, txt, l, t = anim_ax(p, lw=0.5)
ani = VideoAnimation(fig, update, **kwargs, fargs=(frame_t, ))

# %%
# Filament backward
# ^^^^^^^^^^^^^^^^^
p = g.filament(x,
               y,
               "u",
               "v",
               **kw_p,
               filament_size=4,
               backward=True,
               rk4=True)
fig, txt, l, t = anim_ax(p, lw=0.5)
ani = VideoAnimation(fig, update, **kwargs, fargs=(-frame_t, ))

# %%
# Particule forward
# ^^^^^^^^^^^^^^^^^
p = g.advect(x, y, "u", "v", **kw_p, rk4=True)
fig, txt, l, t = anim_ax(p, ls="", marker=".", markersize=1)
ani = VideoAnimation(fig, update, **kwargs, fargs=(frame_t, ))
示例#3
0
# Particles
# ---------
# Particles specification
step = 1 / 32
x_g, y_g = arange(0, 36, step), arange(28, 46, step)
x, y = meshgrid(x_g, y_g)
original_shape = x.shape
x, y = x.reshape(-1), y.reshape(-1)
print(f"{len(x)} particles advected")
# A frame every 8h
step_by_day = 3
# Compute step of advection every 4h
nb_step = 2
kw_p = dict(nb_step=nb_step, time_step=86400 / step_by_day / nb_step)
# Start a generator which at each iteration return new position at next time step
particule = g.advect(x, y, "u", "v", **kw_p, rk4=True)

# %%
# LAVD
# ----
lavd = zeros(original_shape)
# Advection time
nb_days = 8
# Nb frame
nb_time = step_by_day * nb_days
i = 0.0


# %%
# Anim
# ^^^^