diff --git a/swash/.gitignore b/swash/.gitignore index 2677d7c..d4df5e8 100644 --- a/swash/.gitignore +++ b/swash/.gitignore @@ -1,2 +1,3 @@ +/inp* /out* /swash_buoytoartha diff --git a/swash/processing/post.py b/swash/processing/post.py index 8cead73..0de324e 100644 --- a/swash/processing/post.py +++ b/swash/processing/post.py @@ -27,25 +27,18 @@ root = pathlib.Path(config.get("swash", "out")) log.info(f"Reading bathymetry from '{cache}'") bathy = pd.read_hdf(cache.joinpath("bathy.h5"), "bathy") -n = bathy.index.size - -log.info(f"Reading swash output from '{root}'") -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) +data = np.load(pathlib.Path(config.get("post", "inp")).joinpath("sws.npz")) +x, t = data["x"], data["t"] # Cospectral calculations x0 = config.getint("post", "x0") -t0 = config.getint("post", "t0") +t0 = config.getfloat("post", "t0") +dt = config.getfloat("post", "dt") f = 1 / dt log.info(f"Computing reflection coefficient at x={x0}") -eta = (dep - botl)[t > t0, x0] -u = vel[t > t0, 0, x0] +eta = (data["dep"] - data["botl"])[t > t0, x0] +u = data["vel"][t > t0, 0, x0] phi_eta = np.abs(sgl.csd(eta, eta, f)) phi_u = np.abs(sgl.csd(u, u, f)) @@ -60,13 +53,13 @@ R = np.sqrt( log.info("Plotting results") fig, (ax_dep, ax_vel) = plt.subplots(2) -ax_dep.plot(t, (dep - botl)[:, x0], label="dep") +ax_dep.plot(t, data["dep"][:, x0] - data["botl"][x0], label="dep") ax_dep.set(xlabel="t (s)", ylabel="z (m)") ax_dep.autoscale(axis="x", tight=True) ax_dep.grid() ax_dep.axvline(t0, c="k", alpha=0.2) -ax_vel.plot(t, vel[:, 0, x0], label="vel") +ax_vel.plot(t, data["vel"][:, 0, x0], label="vel") ax_vel.set(xlabel="t (s)", ylabel="U (m/s)") ax_vel.autoscale(axis="x", tight=True) ax_vel.grid() @@ -82,8 +75,8 @@ ax_r.set(ylim=(0, 1), xlabel="f (Hz)", ylabel="R") ax_r.grid() fig_x, ax_x = plt.subplots() -ax_x.plot(-botl[0, :], color="k") -ax_x.plot((dep - botl)[t == t0, :].T) +ax_x.plot(-data["botl"], color="k") +ax_x.plot(data["dep"][t == 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)