From 87e108c8dca096c48d84c53602d05e7aaed0c0c0 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Thu, 3 Mar 2022 15:15:53 +0100 Subject: [PATCH] Added time scale to plots --- swash/processing/post.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/swash/processing/post.py b/swash/processing/post.py index 080c98a..5b5dd7a 100644 --- a/swash/processing/post.py +++ b/swash/processing/post.py @@ -34,11 +34,13 @@ botl = read_nohead_scalar(root.joinpath("botl.dat"), n) dep = np.maximum(0, read_nohead_scalar(root.joinpath("dep.dat"), n)) vel = read_nohead_vect(root.joinpath("vel.dat"), n) +dt = config.getfloat("post", "dt") n_t = botl.shape[0] +t = np.arange(0, n_t*dt, dt) # Cospectral calculations pos_x = config.getint("post", "x0") -f = 1 / config.getfloat("post", "dt") +f = 1 / dt log.info(f"Computing reflection coefficient at x={pos_x}") eta = (dep - botl)[n_t // 2 :, pos_x] @@ -57,12 +59,12 @@ R = np.sqrt( log.info("Plotting results") fig, (ax_dep, ax_vel) = plt.subplots(2) -ax_dep.plot((dep - botl)[:, pos_x], label="dep", color="#0066ff") +ax_dep.plot(t, (dep - botl)[:, pos_x], label="dep", color="#0066ff") ax_dep.set(xlabel="t (s)", ylabel="z (m)") ax_dep.autoscale(axis="x", tight=True) ax_dep.grid() -ax_vel.plot(vel[:, 0, pos_x], label="vel") +ax_vel.plot(t, vel[:, 0, pos_x], label="vel") ax_vel.set(xlabel="t (s)", ylabel="U (m/s)") ax_vel.autoscale(axis="x", tight=True) ax_vel.grid()