Use npz in post
This commit is contained in:
parent
a51c727349
commit
1a789ced40
2 changed files with 11 additions and 17 deletions
1
swash/.gitignore
vendored
1
swash/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
|
/inp*
|
||||||
/out*
|
/out*
|
||||||
/swash_buoytoartha
|
/swash_buoytoartha
|
||||||
|
|
|
@ -27,25 +27,18 @@ root = pathlib.Path(config.get("swash", "out"))
|
||||||
|
|
||||||
log.info(f"Reading bathymetry from '{cache}'")
|
log.info(f"Reading bathymetry from '{cache}'")
|
||||||
bathy = pd.read_hdf(cache.joinpath("bathy.h5"), "bathy")
|
bathy = pd.read_hdf(cache.joinpath("bathy.h5"), "bathy")
|
||||||
n = bathy.index.size
|
data = np.load(pathlib.Path(config.get("post", "inp")).joinpath("sws.npz"))
|
||||||
|
x, t = data["x"], data["t"]
|
||||||
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)
|
|
||||||
|
|
||||||
# Cospectral calculations
|
# Cospectral calculations
|
||||||
x0 = config.getint("post", "x0")
|
x0 = config.getint("post", "x0")
|
||||||
t0 = config.getint("post", "t0")
|
t0 = config.getfloat("post", "t0")
|
||||||
|
dt = config.getfloat("post", "dt")
|
||||||
f = 1 / dt
|
f = 1 / dt
|
||||||
log.info(f"Computing reflection coefficient at x={x0}")
|
log.info(f"Computing reflection coefficient at x={x0}")
|
||||||
|
|
||||||
eta = (dep - botl)[t > t0, x0]
|
eta = (data["dep"] - data["botl"])[t > t0, x0]
|
||||||
u = vel[t > t0, 0, x0]
|
u = data["vel"][t > t0, 0, x0]
|
||||||
|
|
||||||
phi_eta = np.abs(sgl.csd(eta, eta, f))
|
phi_eta = np.abs(sgl.csd(eta, eta, f))
|
||||||
phi_u = np.abs(sgl.csd(u, u, f))
|
phi_u = np.abs(sgl.csd(u, u, f))
|
||||||
|
@ -60,13 +53,13 @@ R = np.sqrt(
|
||||||
log.info("Plotting results")
|
log.info("Plotting results")
|
||||||
fig, (ax_dep, ax_vel) = plt.subplots(2)
|
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.set(xlabel="t (s)", ylabel="z (m)")
|
||||||
ax_dep.autoscale(axis="x", tight=True)
|
ax_dep.autoscale(axis="x", tight=True)
|
||||||
ax_dep.grid()
|
ax_dep.grid()
|
||||||
ax_dep.axvline(t0, c="k", alpha=0.2)
|
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.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()
|
||||||
|
@ -82,8 +75,8 @@ ax_r.set(ylim=(0, 1), xlabel="f (Hz)", ylabel="R")
|
||||||
ax_r.grid()
|
ax_r.grid()
|
||||||
|
|
||||||
fig_x, ax_x = plt.subplots()
|
fig_x, ax_x = plt.subplots()
|
||||||
ax_x.plot(-botl[0, :], color="k")
|
ax_x.plot(-data["botl"], color="k")
|
||||||
ax_x.plot((dep - botl)[t == t0, :].T)
|
ax_x.plot(data["dep"][t == t0, :] - data["botl"])
|
||||||
ax_x.axvline(x0, c="k", alpha=0.2)
|
ax_x.axvline(x0, c="k", alpha=0.2)
|
||||||
ax_x.set(xlabel="x (m)", ylabel="z (m)")
|
ax_x.set(xlabel="x (m)", ylabel="z (m)")
|
||||||
ax_x.autoscale(axis="x", tight=True)
|
ax_x.autoscale(axis="x", tight=True)
|
||||||
|
|
Loading…
Reference in a new issue