1
Fork 0

Add compare and info to wave siz

This commit is contained in:
Edgar P. Burkhart 2022-05-25 10:27:36 +02:00
parent 97c856a73c
commit fd15259134
Signed by: edpibu
GPG Key ID: 9833D3C5A25BD227
1 changed files with 30 additions and 2 deletions

View File

@ -19,6 +19,7 @@ config = configparser.ConfigParser()
config.read(args.config)
inp = pathlib.Path(config.get("post", "inp"))
inp_comp = pathlib.Path(config.get("post", "compare"))
root = pathlib.Path(config.get("swash", "out"))
log.info(f"Reading data from '{inp}'")
@ -26,13 +27,16 @@ x = np.load(inp.joinpath("x.npy"))
t = np.load(inp.joinpath("t.npy"))
watl = np.load(inp.joinpath("watl.npy"))
watl_comp = np.load(inp_comp.joinpath("watl.npy"))
# Cospectral calculations
x0 = config.getint("post", "x0")
arg_x0 = np.abs(x - x0).argmin()
w0 = watl[:, arg_x0]
w0_comp = watl_comp[:, arg_x0]
cr0 = np.where(np.diff(np.sign(w0)))[0]
cr0_comp = np.where(np.diff(np.sign(w0_comp)))[0]
wave = np.fromiter(
(
@ -44,6 +48,16 @@ wave = np.fromiter(
),
dtype=np.single,
)
wave_comp = np.fromiter(
(
np.abs(
np.max(np.abs(w0_comp[cr0_comp[i - 1] : cr0_comp[i]]))
+ np.max(np.abs(w0_comp[cr0_comp[i] : cr0_comp[i + 1]]))
)
for i in range(1, len(cr0) - 1)
),
dtype=np.single,
)
i0 = np.argmax(wave)
@ -53,8 +67,22 @@ out.mkdir(parents=True, exist_ok=True)
fig, ax = plt.subplots()
ax.plot(t[cr0[1:-1]] * 1e-3, wave)
ax.set(xlabel="t (s)", ylabel="z (m)")
ax.autoscale(True, "x", True)
ax.grid()
fig.savefig(out.joinpath("wsize.pdf"))
fig2, ax2 = plt.subplots()
ax2.plot(t[cr0[i0 - 5] : cr0[i0 + 7]], w0[cr0[i0 - 5] : cr0[i0 + 7]])
fig2, ax2 = plt.subplots(figsize=(10/2.54, 2/3*10/2.54), constrained_layout=True)
ax2.plot(t[cr0[i0 - 5] : cr0[i0 + 7]] * 1e-3, w0[cr0[i0 - 5] : cr0[i0 + 7]], color="k", label="Case 1")
ax2.plot(t[cr0[i0 - 5] : cr0[i0 + 7]] * 1e-3, w0_comp[cr0[i0 - 5] : cr0[i0 + 7]], color="k", ls="-.", label="Case 2")
ax2.set(xlabel="t (s)", ylabel="z (m)")
ax2.autoscale(True, "x", True)
ax2.grid()
ax2.legend()
fig2.savefig(out.joinpath("maxw.pdf"))
fig2.savefig(out.joinpath("maxw.jpg"), dpi=200)
log.info(f"RMS difference: {np.sqrt(np.mean((w0_comp-w0)**2))}m ; {np.sqrt(np.mean((w0_comp-w0)**2))/(w0.max()-w0.min()):%}")
log.info(f"Bias: {np.mean(w0_comp-w0)}m")
log.info(f"Maximum wave size: {wave.max()}m ; {wave_comp.max()}m")
log.info(f"Maximum wave size difference: {abs(wave_comp.max()-wave.max())/wave.max():%}")