Post-processing using mat output
This commit is contained in:
parent
d05a80d98d
commit
2eea373e79
2 changed files with 14 additions and 14 deletions
|
@ -29,8 +29,8 @@ def data(var):
|
||||||
return np.load(inp.joinpath(f"{var}.npy"))
|
return np.load(inp.joinpath(f"{var}.npy"))
|
||||||
|
|
||||||
|
|
||||||
x = data("xp")
|
x = data("x")
|
||||||
t = data("tsec")
|
#t = data("t")
|
||||||
|
|
||||||
watl = data("watl")
|
watl = data("watl")
|
||||||
botl = data("botl")
|
botl = data("botl")
|
||||||
|
|
|
@ -25,25 +25,25 @@ inp = pathlib.Path(config.get("post", "inp"))
|
||||||
root = pathlib.Path(config.get("swash", "out"))
|
root = pathlib.Path(config.get("swash", "out"))
|
||||||
|
|
||||||
log.info(f"Reading data from '{inp}'")
|
log.info(f"Reading data from '{inp}'")
|
||||||
x = np.load(inp.joinpath("xp.npy"))
|
x = np.load(inp.joinpath("x.npy"))
|
||||||
t = np.load(inp.joinpath("tsec.npy"))
|
t = np.load(inp.joinpath("t.npy"))
|
||||||
|
|
||||||
botl = np.load(inp.joinpath("botl.npy"))
|
botl = np.load(inp.joinpath("botl.npy"))
|
||||||
watl = np.load(inp.joinpath("watl.npy"))
|
watl = np.load(inp.joinpath("watl.npy"))
|
||||||
vel = np.load(inp.joinpath("vel.npy"))
|
vel = np.load(inp.joinpath("vel_x.npy"))
|
||||||
|
|
||||||
# Cospectral calculations
|
# Cospectral calculations
|
||||||
x0 = config.getint("post", "x0")
|
x0 = config.getint("post", "x0")
|
||||||
arg_x0 = np.abs(x - x0).argmin()
|
arg_x0 = np.abs(x - x0).argmin()
|
||||||
t0 = config.getfloat("post", "t0")
|
t0 = int(config.getfloat("post", "t0")*1e3)
|
||||||
arg_t0 = np.abs(t - t0).argmin()
|
arg_t0 = np.abs(t - t0).argmin()
|
||||||
dt = np.diff(t).mean()
|
dt = np.diff(t).mean()*1e-3
|
||||||
f = 1 / dt
|
f = 1 / dt
|
||||||
nperseg = config.getint("post", "nperseg", fallback=None)
|
nperseg = config.getint("post", "nperseg", fallback=None)
|
||||||
log.info(f"Computing reflection coefficient at x={x0}")
|
log.info(f"Computing reflection coefficient at x={x0}")
|
||||||
|
|
||||||
eta = watl[t > t0, arg_x0]
|
eta = watl[t > t0, arg_x0]
|
||||||
u = vel[t > t0, 0, arg_x0]
|
u = vel[t > t0, arg_x0]
|
||||||
|
|
||||||
phi_eta = sgl.welch(eta, f, nperseg=nperseg)
|
phi_eta = sgl.welch(eta, f, nperseg=nperseg)
|
||||||
phi_u = sgl.welch(u, f, nperseg=nperseg)
|
phi_u = sgl.welch(u, f, nperseg=nperseg)
|
||||||
|
@ -70,13 +70,13 @@ if config.has_option("post", "compare"):
|
||||||
|
|
||||||
botl_ = np.load(inp_comp.joinpath("botl.npy"))
|
botl_ = np.load(inp_comp.joinpath("botl.npy"))
|
||||||
watl_ = np.load(inp_comp.joinpath("watl.npy"))
|
watl_ = np.load(inp_comp.joinpath("watl.npy"))
|
||||||
vel_ = np.load(inp_comp.joinpath("vel.npy"))
|
vel_ = np.load(inp_comp.joinpath("vel_x.npy"))
|
||||||
|
|
||||||
arg_x0_ = np.abs(x_ - x0).argmin()
|
arg_x0_ = np.abs(x_ - x0).argmin()
|
||||||
arg_t0_ = np.abs(t_ - t0).argmin()
|
arg_t0_ = np.abs(t_ - t0).argmin()
|
||||||
|
|
||||||
eta_ = watl_[t_ > t0, arg_x0_]
|
eta_ = watl_[t_ > t0, arg_x0_]
|
||||||
u_ = vel_[t_ > t0, 0, arg_x0_]
|
u_ = vel_[t_ > t0, arg_x0_]
|
||||||
|
|
||||||
phi_eta_ = sgl.welch(eta_, f, nperseg=nperseg)
|
phi_eta_ = sgl.welch(eta_, f, nperseg=nperseg)
|
||||||
phi_u_ = sgl.welch(u_, f, nperseg=nperseg)
|
phi_u_ = sgl.welch(u_, f, nperseg=nperseg)
|
||||||
|
@ -101,17 +101,17 @@ if config.has_option("post", "compare"):
|
||||||
log.info("Plotting results")
|
log.info("Plotting results")
|
||||||
fig, (ax_watl, ax_vel) = plt.subplots(2)
|
fig, (ax_watl, ax_vel) = plt.subplots(2)
|
||||||
|
|
||||||
ax_watl.plot(t, watl[:, arg_x0], lw=1, label="watl")
|
ax_watl.plot(t*1e-3, watl[:, arg_x0], lw=1, label="watl")
|
||||||
ax_watl.set(xlabel="t (s)", ylabel="z (m)")
|
ax_watl.set(xlabel="t (s)", ylabel="z (m)")
|
||||||
ax_watl.autoscale(axis="x", tight=True)
|
ax_watl.autoscale(axis="x", tight=True)
|
||||||
ax_watl.grid()
|
ax_watl.grid()
|
||||||
ax_watl.axvline(t0, c="k", alpha=0.2)
|
ax_watl.axvline(t0*1e-3, c="k", alpha=0.2)
|
||||||
|
|
||||||
ax_vel.plot(t, vel[:, 0, arg_x0], lw=1, label="vel")
|
ax_vel.plot(t*1e-3, vel[:, arg_x0], lw=1, label="vel")
|
||||||
ax_vel.set(xlabel="t (s)", ylabel="U (m/s)")
|
ax_vel.set(xlabel="t (s)", ylabel="U (m/s)")
|
||||||
ax_vel.autoscale(axis="x", tight=True)
|
ax_vel.autoscale(axis="x", tight=True)
|
||||||
ax_vel.grid()
|
ax_vel.grid()
|
||||||
ax_vel.axvline(t0, c="k", alpha=0.2)
|
ax_vel.axvline(t0*1e-3, c="k", alpha=0.2)
|
||||||
|
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue