From 0bdd73da194d7db151ac39ceddaeebfa87a495ee Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Fri, 4 Mar 2022 11:01:01 +0100 Subject: [PATCH] Add real x support to post --- swash/config.ini | 2 +- swash/processing/post.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/swash/config.ini b/swash/config.ini index a39acf8..08df32a 100644 --- a/swash/config.ini +++ b/swash/config.ini @@ -20,5 +20,5 @@ mpi=4 inp=inp_post out=out_post dt=0.25 -x0=125 +x0=-1000 t0=180 diff --git a/swash/processing/post.py b/swash/processing/post.py index f3ed9e9..9032879 100644 --- a/swash/processing/post.py +++ b/swash/processing/post.py @@ -31,13 +31,15 @@ x, t = data["x"], data["t"] # Cospectral calculations x0 = config.getint("post", "x0") +arg_x0 = (x - x0).abs().argmin() t0 = config.getfloat("post", "t0") +arg_t0 = (t - t0).abs().argmin() dt = config.getfloat("post", "dt") f = 1 / dt log.info(f"Computing reflection coefficient at x={x0}") -eta = data["watl"][t > t0, x0] -u = data["vel"][t > t0, 0, x0] +eta = data["watl"][t > t0, arg_x0] +u = data["vel"][t > t0, 0, arg_x0] phi_eta = np.abs(sgl.csd(eta, eta, f)) phi_u = np.abs(sgl.csd(u, u, f)) @@ -52,13 +54,13 @@ R = np.sqrt( log.info("Plotting results") fig, (ax_watl, ax_vel) = plt.subplots(2) -ax_watl.plot(t, data["watl"][:, x0], label="watl") +ax_watl.plot(t, data["watl"][:, arg_x0], 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, x0], label="vel") +ax_vel.plot(t, data["vel"][:, 0, arg_x0], label="vel") ax_vel.set(xlabel="t (s)", ylabel="U (m/s)") ax_vel.autoscale(axis="x", tight=True) ax_vel.grid() @@ -74,8 +76,8 @@ ax_r.set(ylim=(0, 1), xlabel="f (Hz)", ylabel="R") ax_r.grid() fig_x, ax_x = plt.subplots() -ax_x.plot(-data["botl"], color="k") -ax_x.plot(data["watl"][np.argmin(np.abs(t - t0)), :]) +ax_x.plot(data["x"], -data["botl"], color="k") +ax_x.plot(data["x"], np.maximum(data["watl"][arg_t0, :], -data["botl"])) ax_x.axvline(x0, c="k", alpha=0.2) ax_x.set(xlabel="x (m)", ylabel="z (m)") ax_x.autoscale(axis="x", tight=True)