PUV method test (with/out noise)
This commit is contained in:
parent
1362c8765d
commit
873cc73c84
2 changed files with 51 additions and 1 deletions
50
swash/processing/r_test.py
Normal file
50
swash/processing/r_test.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from numpy import random
|
||||
import scipy.signal as sgl
|
||||
|
||||
yi = random.normal(size=2**20)
|
||||
yr = 0.3 * np.roll(yi, -(2**10))
|
||||
|
||||
figy, axy = plt.subplots()
|
||||
axy.plot(np.arange(2**10, 2**11), yi[2**10 : 2**11])
|
||||
axy.plot(np.arange(2**10, 2**11), yr[2**10 : 2**11])
|
||||
|
||||
figf, axf = plt.subplots()
|
||||
axf.plot(*sgl.welch(yi))
|
||||
axf.plot(*sgl.welch(yr))
|
||||
|
||||
eta = yi + yr
|
||||
u = -yi + yr
|
||||
|
||||
|
||||
def puv(eta, u):
|
||||
f, phi_eta = sgl.welch(eta)
|
||||
phi_u = sgl.welch(u)[1]
|
||||
phi_eta_u = np.abs(sgl.csd(eta, u)[1].real)
|
||||
|
||||
return f, np.sqrt(
|
||||
(phi_eta + phi_u - 2 * phi_eta_u) / (phi_eta + phi_u + 2 * phi_eta_u)
|
||||
)
|
||||
|
||||
|
||||
figr, axr = plt.subplots()
|
||||
|
||||
axr.plot(*puv(eta, u), label="Without noise")
|
||||
axr.plot(
|
||||
*puv(
|
||||
eta + 0.4 * random.normal(size=2**20), u + 0.4 * random.normal(size=2**20)
|
||||
),
|
||||
label="With noise"
|
||||
)
|
||||
axr.grid()
|
||||
axr.autoscale(True, "x", tight=True)
|
||||
axr.set(ylim=(0, 1), ylabel="R", xlabel="f")
|
||||
axr.legend(loc="lower left")
|
||||
|
||||
axpsd = axr.twinx()
|
||||
axpsd.plot(*sgl.welch(eta), label=r"PSD ($\eta$)", c="k", alpha=0.2, lw=1)
|
||||
axpsd.legend(loc="lower right")
|
||||
axpsd.set(ylabel="PSD")
|
||||
|
||||
plt.show()
|
2
tasks.md
2
tasks.md
|
@ -1,4 +1,4 @@
|
|||
Vérification méthodes calcul réflection avec données forcées en Python
|
||||
* Vérification méthodes calcul réflection avec données forcées en Python
|
||||
|
||||
|
||||
Vérification vague incidente possible avec digue et sans digue sur temps long (4h) avec spectre Jonswap
|
||||
|
|
Loading…
Reference in a new issue