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 b59a2716a7
commit f905d20c81
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 mpi=4
[post] [post]
inp=inp_post_test inp=inp_post
#case=sws_spec_buoy.npz #compare=inp_post_2
#compare=sws_spec_buoy_nb.npz
out=out_post out=out_post
#nperseg=1024 #nperseg=1024
dt=0.25 dt=0.25
x0=-1000 x0=-1250
t0=180 t0=180

View file

@ -25,8 +25,12 @@ 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}'")
data = np.load(inp.joinpath(config.get("post", "case"))) x = np.load(inp.joinpath("xp.npy"))
x, t = data["x"], data["t"] 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 # Cospectral calculations
x0 = config.getint("post", "x0") x0 = config.getint("post", "x0")
@ -38,8 +42,8 @@ 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 = data["watl"][t > t0, arg_x0] eta = watl[t > t0, arg_x0]
u = data["vel"][t > t0, 0, arg_x0] u = vel[t > t0, 0, 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)
@ -87,13 +91,13 @@ 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, 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.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, 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.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()
@ -129,15 +133,15 @@ ax_fft.legend(loc="upper right")
fig_r.tight_layout() fig_r.tight_layout()
fig_x, ax_x = plt.subplots(figsize=(10, 1)) 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( ax_x.plot(
data["x"], x,
np.maximum(data["watl"][arg_t0, :], -data["botl"]), np.maximum(watl[arg_t0, :], -botl),
) )
if config.has_option("post", "compare"): 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( ax_x.plot(
data["x"], x,
np.maximum(data_comp["watl"][arg_t0, :], -data_comp["botl"]), np.maximum(data_comp["watl"][arg_t0, :], -data_comp["botl"]),
ls="-.", ls="-.",
) )