Пример #1
0
                                                      alpha=0.1)
    return fig, ax.text(21, 32.1, ""), ax.plot([], [], "k", **kw)[0], t


def update(i_frame, t_step):
    global t
    x, y = p.__next__()
    t += t_step
    l.set_data(x, y)
    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)
Пример #2
0

def update(i_frame, t_step):
    global t
    x, y = p.__next__()
    t += t_step
    l.set_data(x, y)
    txt.set_text(f"T0 + {t:.1f} days")


# %%
# 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)