Updated colorbars for animation
This commit is contained in:
parent
f7261d2e6b
commit
d2ca94b798
1 changed files with 23 additions and 12 deletions
|
@ -8,6 +8,7 @@ import pickle
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import matplotlib.animation as animation
|
import matplotlib.animation as animation
|
||||||
|
from matplotlib.gridspec import GridSpec
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy import interpolate
|
from scipy import interpolate
|
||||||
|
|
||||||
|
@ -52,7 +53,11 @@ AW[:, idz0, idx0] = model.fields["alpha.water"]
|
||||||
U = np.full((model.t.size, *X.shape), np.nan)
|
U = np.full((model.t.size, *X.shape), np.nan)
|
||||||
U[:, idz0, idx0] = np.linalg.norm(model.fields["U"], axis=1)
|
U[:, idz0, idx0] = np.linalg.norm(model.fields["U"], axis=1)
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(19.2, 10.8), dpi=100)
|
fig = plt.figure(figsize=(19.2, 10.8), dpi=100)
|
||||||
|
gs = GridSpec(3, 1, figure=fig, height_ratios=[1, .05, .05])
|
||||||
|
ax = fig.add_subplot(gs[0])
|
||||||
|
cax1 = fig.add_subplot(gs[1])
|
||||||
|
cax2 = fig.add_subplot(gs[2])
|
||||||
tit = ax.text(
|
tit = ax.text(
|
||||||
0.5,
|
0.5,
|
||||||
0.95,
|
0.95,
|
||||||
|
@ -62,7 +67,7 @@ tit = ax.text(
|
||||||
transform=ax.transAxes,
|
transform=ax.transAxes,
|
||||||
)
|
)
|
||||||
aw_m = ax.pcolormesh(X, Z, AW[0], vmin=0, vmax=1, cmap="Blues", zorder=1)
|
aw_m = ax.pcolormesh(X, Z, AW[0], vmin=0, vmax=1, cmap="Blues", zorder=1)
|
||||||
ax.pcolormesh(
|
p_m = ax.pcolormesh(
|
||||||
X,
|
X,
|
||||||
Z,
|
Z,
|
||||||
P[1],
|
P[1],
|
||||||
|
@ -75,8 +80,9 @@ ax.pcolormesh(
|
||||||
ax.axhline(4.5, ls="-.", lw=1, c="k", alpha=0.2, zorder=1.2)
|
ax.axhline(4.5, ls="-.", lw=1, c="k", alpha=0.2, zorder=1.2)
|
||||||
|
|
||||||
|
|
||||||
fig.colorbar(aw_m)
|
fig.colorbar(aw_m, label=r"$\alpha_w$", cax=cax1, shrink=0.6, orientation="horizontal")
|
||||||
ax.set(xlabel="x (m)", ylabel="z (m)", aspect="equal", facecolor="#bebebe")
|
fig.colorbar(p_m, label=r"Porosity", cax=cax2, shrink=0.6, orientation="horizontal")
|
||||||
|
ax.set(xlabel="x (m)", ylabel="z (m)", aspect="equal", facecolor="#000000")
|
||||||
ax.grid(c="k", alpha=0.2)
|
ax.grid(c="k", alpha=0.2)
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,7 +91,11 @@ def anim(i):
|
||||||
aw_m.set_array(AW[i])
|
aw_m.set_array(AW[i])
|
||||||
|
|
||||||
|
|
||||||
figU, axU = plt.subplots(figsize=(19.2, 10.8), dpi=100)
|
figU = plt.figure(figsize=(19.2, 10.8), dpi=100)
|
||||||
|
gsU = GridSpec(3, 1, figure=figU, height_ratios=[1, .05, .05])
|
||||||
|
axU = figU.add_subplot(gsU[0])
|
||||||
|
caxu1 = figU.add_subplot(gsU[1])
|
||||||
|
caxu2 = figU.add_subplot(gsU[2])
|
||||||
u_m = axU.pcolormesh(
|
u_m = axU.pcolormesh(
|
||||||
X,
|
X,
|
||||||
Z,
|
Z,
|
||||||
|
@ -107,7 +117,6 @@ ur_m = axU.pcolormesh(
|
||||||
alpha=1 - np.nan_to_num(AW[0]).clip(0, 1),
|
alpha=1 - np.nan_to_num(AW[0]).clip(0, 1),
|
||||||
)
|
)
|
||||||
# aw_u = axU.contour(X, Z, AW[0], levels=(.5,))
|
# aw_u = axU.contour(X, Z, AW[0], levels=(.5,))
|
||||||
figU.colorbar(u_m)
|
|
||||||
axU.set(xlabel="x (m)", ylabel="z (m)", aspect="equal", facecolor="#bebebe")
|
axU.set(xlabel="x (m)", ylabel="z (m)", aspect="equal", facecolor="#bebebe")
|
||||||
axU.grid(c="k", alpha=0.2)
|
axU.grid(c="k", alpha=0.2)
|
||||||
titU = axU.text(
|
titU = axU.text(
|
||||||
|
@ -119,6 +128,9 @@ titU = axU.text(
|
||||||
transform=axU.transAxes,
|
transform=axU.transAxes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
figU.colorbar(u_m, label=r"$U_w$", cax=caxu1, shrink=0.6, orientation="horizontal")
|
||||||
|
figU.colorbar(ur_m, label=r"$U_a$", cax=caxu2, shrink=0.6, orientation="horizontal")
|
||||||
|
|
||||||
|
|
||||||
def animU(i):
|
def animU(i):
|
||||||
titU.set_text(f"t={model.t[i]}s")
|
titU.set_text(f"t={model.t[i]}s")
|
||||||
|
@ -127,10 +139,9 @@ def animU(i):
|
||||||
ur_m.set_array(U[i])
|
ur_m.set_array(U[i])
|
||||||
ur_m.set_alpha(1 - np.nan_to_num(AW[i]).clip(0, 1))
|
ur_m.set_alpha(1 - np.nan_to_num(AW[i]).clip(0, 1))
|
||||||
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
#ani = animation.FuncAnimation(fig, anim, frames=model.t.size, interval=1/24)
|
ani = animation.FuncAnimation(fig, anim, frames=model.t.size, interval=1/24)
|
||||||
#aniU = animation.FuncAnimation(figU, animU, frames=model.t.size, interval=1/24)
|
aniU = animation.FuncAnimation(figU, animU, frames=model.t.size, interval=1/24)
|
||||||
#
|
|
||||||
#ani.save(out.joinpath("anim.mp4"), fps=24)
|
ani.save(out.joinpath("anim.mp4"), fps=24)
|
||||||
#aniU.save(out.joinpath("animU.mp4"), fps=24)
|
aniU.save(out.joinpath("animU.mp4"), fps=24)
|
||||||
|
|
Loading…
Reference in a new issue