diff --git a/swash/processing/animate.py b/swash/processing/animate.py index fd0b565..473df88 100644 --- a/swash/processing/animate.py +++ b/swash/processing/animate.py @@ -30,7 +30,7 @@ def data(var): x = data("x") -#t = data("t") +# t = data("t") watl = data("watl") botl = data("botl") diff --git a/swash/processing/layers.py b/swash/processing/layers.py index f1090ee..e1554ee 100644 --- a/swash/processing/layers.py +++ b/swash/processing/layers.py @@ -55,7 +55,7 @@ vk = np.sqrt((velk[n] ** 2).sum(axis=1)) lines = ax.plot(x, zk[n].T, c="#0066cc") quiv = [] -for i in range(len(lines)-1): +for i in range(len(lines) - 1): quiv.append( ax.quiver( x[::50], diff --git a/swash/processing/pa/PUV.py b/swash/processing/pa/PUV.py index 858bb0f..b571377 100644 --- a/swash/processing/pa/PUV.py +++ b/swash/processing/pa/PUV.py @@ -70,28 +70,46 @@ def PUV_dam(u, p, h, fs, zmesP, zmesU): ccs.append(cs) cccp.append(ccp) # calcul des amplitudes des ondes incidentes a partir de uhoriz et p - aincident13.append(0.5 * np.sqrt( - a1 * a1 / (cc * cc) - + a3 - * a3 - * g - * g - * xf[ii] - * xf[ii] - / (omega[ii] * omega[ii] * ccp * ccp) - + 2 * a1 * a3 * g * k_xb[ii] * np.cos(phi3 - phi1) / (cc * ccp * omega[ii]) - )) - areflechi13.append(0.5 * np.sqrt( - a1 * a1 / (cc * cc) - + a3 - * a3 - * g - * g - * k_xb[ii] - * k_xb[ii] - / (omega[ii] * omega[ii] * ccp * ccp) - - 2 * a1 * a3 * g * xf[ii] * np.cos(phi3 - phi1) / (cc * ccp * omega[ii]) - )) + aincident13.append( + 0.5 + * np.sqrt( + a1 * a1 / (cc * cc) + + a3 + * a3 + * g + * g + * xf[ii] + * xf[ii] + / (omega[ii] * omega[ii] * ccp * ccp) + + 2 + * a1 + * a3 + * g + * k_xb[ii] + * np.cos(phi3 - phi1) + / (cc * ccp * omega[ii]) + ) + ) + areflechi13.append( + 0.5 + * np.sqrt( + a1 * a1 / (cc * cc) + + a3 + * a3 + * g + * g + * k_xb[ii] + * k_xb[ii] + / (omega[ii] * omega[ii] * ccp * ccp) + - 2 + * a1 + * a3 + * g + * xf[ii] + * np.cos(phi3 - phi1) + / (cc * ccp * omega[ii]) + ) + ) cv = g * xf[ii] / (omega[ii] * ccp) cp = 1 / cc aprog.append(a3 / (g * xf[ii] / (omega[ii] * ccp))) diff --git a/swash/processing/post.py b/swash/processing/post.py index 3315721..92f31eb 100644 --- a/swash/processing/post.py +++ b/swash/processing/post.py @@ -35,9 +35,9 @@ vel = np.load(inp.joinpath("vel_x.npy")) # Cospectral calculations x0 = config.getint("post", "x0") arg_x0 = np.abs(x - x0).argmin() -t0 = int(config.getfloat("post", "t0")*1e3) +t0 = int(config.getfloat("post", "t0") * 1e3) arg_t0 = np.abs(t - t0).argmin() -dt = np.diff(t).mean()*1e-3 +dt = np.diff(t).mean() * 1e-3 f = 1 / dt nperseg = config.getint("post", "nperseg", fallback=None) log.info(f"Computing reflection coefficient at x={x0}") @@ -58,10 +58,10 @@ R = np.sqrt( (np.abs(phi_eta[1]) + np.abs(phi_u[1]) - 2 * phi_eta_u[1].real) / (np.abs(phi_eta[1]) + np.abs(phi_u[1]) + 2 * phi_eta_u[1].real) ) -#R = np.sqrt( +# R = np.sqrt( # (1 + G**2 - 2 * G * np.cos(th_eta_u)) # / (1 + G**2 + 2 * G * np.cos(th_eta_u)) -#) +# ) if config.has_option("post", "compare"): inp_comp = pathlib.Path(config.get("post", "compare")) @@ -91,27 +91,27 @@ if config.has_option("post", "compare"): (np.abs(phi_eta_[1]) + np.abs(phi_u_[1]) - 2 * phi_eta_u_[1].real) / (np.abs(phi_eta_[1]) + np.abs(phi_u_[1]) + 2 * phi_eta_u_[1].real) ) - #R_ = np.sqrt( + # R_ = np.sqrt( # (1 + G_**2 - 2 * G_ * np.cos(th_eta_u_)) # / (1 + G_**2 + 2 * G_ * np.cos(th_eta_u_)) - #) + # ) # Plotting log.info("Plotting results") fig, (ax_watl, ax_vel) = plt.subplots(2) -ax_watl.plot(t*1e-3, watl[:, arg_x0], lw=1, label="watl") +ax_watl.plot(t * 1e-3, watl[:, arg_x0], lw=1, 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*1e-3, c="k", alpha=0.2) +ax_watl.axvline(t0 * 1e-3, c="k", alpha=0.2) -ax_vel.plot(t*1e-3, vel[:, arg_x0], lw=1, label="vel") +ax_vel.plot(t * 1e-3, vel[:, arg_x0], lw=1, label="vel") ax_vel.set(xlabel="t (s)", ylabel="U (m/s)") ax_vel.autoscale(axis="x", tight=True) ax_vel.grid() -ax_vel.axvline(t0*1e-3, c="k", alpha=0.2) +ax_vel.axvline(t0 * 1e-3, c="k", alpha=0.2) fig.tight_layout() diff --git a/swash/processing/r_test.py b/swash/processing/r_test.py index ec7b23f..dd93f5f 100644 --- a/swash/processing/r_test.py +++ b/swash/processing/r_test.py @@ -40,7 +40,9 @@ for r in np.arange(0, 1.1, 0.1): *Rn, c="#ff6600", ) - axr.annotate(f"{r=:.1f}", (Rn[0][0], Rn[1][0]), bbox={"boxstyle": "square", "facecolor": "w"}) + axr.annotate( + f"{r=:.1f}", (Rn[0][0], Rn[1][0]), bbox={"boxstyle": "square", "facecolor": "w"} + ) axr.grid() axr.autoscale(True, "x", tight=True) axr.set(ylim=(0, 1), ylabel="R", xlabel="f") diff --git a/swash/processing/read_swash.py b/swash/processing/read_swash.py index 4f7a178..6a4e5dc 100644 --- a/swash/processing/read_swash.py +++ b/swash/processing/read_swash.py @@ -7,6 +7,7 @@ import numpy as np log = logging.getLogger("read_swash") + class ReadSwash: def __init__(self): self._n_x = None diff --git a/swash/processing/sws_npz.py b/swash/processing/sws_npz.py index 3bf6c0c..99caabd 100644 --- a/swash/processing/sws_npz.py +++ b/swash/processing/sws_npz.py @@ -30,14 +30,14 @@ np.save(inp.joinpath("tsec"), rsws.read_time(sws_out.joinpath("tsec.dat"))) np.save(inp.joinpath("xp"), rsws.read_x(sws_out.joinpath("xp.dat"))) var = { - #"dep": rsws.read_scalar, + # "dep": rsws.read_scalar, "botl": rsws.read_const, "watl": rsws.read_scalar, - #"pressk": rsws.read_scalar_lay, - #"nhprsk": rsws.read_scalar_lay, - #"zk": rsws.read_scalar_lay, - #"velk": rsws.read_vector_lay, - #"vz": rsws.read_scalar_lay, + # "pressk": rsws.read_scalar_lay, + # "nhprsk": rsws.read_scalar_lay, + # "zk": rsws.read_scalar_lay, + # "velk": rsws.read_vector_lay, + # "vz": rsws.read_scalar_lay, "vel": rsws.read_vector, }