1
Fork 0

Fixed post processing for new data format

This commit is contained in:
Edgar P. Burkhart 2022-03-25 10:25:17 +01:00
parent be4a18165f
commit c7a1b2a62c
Signed by: edpibu
GPG Key ID: 9833D3C5A25BD227
2 changed files with 18 additions and 15 deletions

View File

@ -19,11 +19,10 @@ out=out_sws
mpi=4
[post]
inp=inp_post_test
#case=sws_spec_buoy.npz
#compare=sws_spec_buoy_nb.npz
inp=inp_post
#compare=inp_post_2
out=out_post
#nperseg=1024
dt=0.25
x0=-1000
x0=-1250
t0=180

View File

@ -25,8 +25,12 @@ inp = pathlib.Path(config.get("post", "inp"))
root = pathlib.Path(config.get("swash", "out"))
log.info(f"Reading data from '{inp}'")
data = np.load(inp.joinpath(config.get("post", "case")))
x, t = data["x"], data["t"]
x = np.load(inp.joinpath("xp.npy"))
t = np.load(inp.joinpath("tsec.npy"))
botl = np.load(inp.joinpath("botl.npy"))
watl = np.load(inp.joinpath("watl.npy"))
vel = np.load(inp.joinpath("vel.npy"))
# Cospectral calculations
x0 = config.getint("post", "x0")
@ -38,8 +42,8 @@ f = 1 / dt
nperseg = config.getint("post", "nperseg", fallback=None)
log.info(f"Computing reflection coefficient at x={x0}")
eta = data["watl"][t > t0, arg_x0]
u = data["vel"][t > t0, 0, arg_x0]
eta = watl[t > t0, arg_x0]
u = vel[t > t0, 0, arg_x0]
phi_eta = sgl.welch(eta, f, nperseg=nperseg)
phi_u = sgl.welch(u, f, nperseg=nperseg)
@ -87,13 +91,13 @@ if config.has_option("post", "compare"):
log.info("Plotting results")
fig, (ax_watl, ax_vel) = plt.subplots(2)
ax_watl.plot(t, data["watl"][:, arg_x0], lw=1, label="watl")
ax_watl.plot(t, watl[:, arg_x0], lw=1, label="watl")
ax_watl.set(xlabel="t (s)", ylabel="z (m)")
ax_watl.autoscale(axis="x", tight=True)
ax_watl.grid()
ax_watl.axvline(t0, c="k", alpha=0.2)
ax_vel.plot(t, data["vel"][:, 0, arg_x0], lw=1, label="vel")
ax_vel.plot(t, vel[:, 0, arg_x0], lw=1, label="vel")
ax_vel.set(xlabel="t (s)", ylabel="U (m/s)")
ax_vel.autoscale(axis="x", tight=True)
ax_vel.grid()
@ -129,15 +133,15 @@ ax_fft.legend(loc="upper right")
fig_r.tight_layout()
fig_x, ax_x = plt.subplots(figsize=(10, 1))
ax_x.plot(data["x"], -data["botl"], color="k")
ax_x.plot(x, -botl, color="k")
ax_x.plot(
data["x"],
np.maximum(data["watl"][arg_t0, :], -data["botl"]),
x,
np.maximum(watl[arg_t0, :], -botl),
)
if config.has_option("post", "compare"):
ax_x.plot(data["x"], -data_comp["botl"], color="k", ls="-.")
ax_x.plot(x, -data_comp["botl"], color="k", ls="-.")
ax_x.plot(
data["x"],
x,
np.maximum(data_comp["watl"][arg_t0, :], -data_comp["botl"]),
ls="-.",
)