test wl masking
This commit is contained in:
@@ -3,6 +3,7 @@ import pytest
|
||||
|
||||
from scgenerator.math import abs2, wspace
|
||||
from scgenerator.physics.units import m_rads
|
||||
from scgenerator.physics.pulse import find_lobe_limits
|
||||
from scgenerator.spectra import Spectrum
|
||||
|
||||
|
||||
@@ -90,10 +91,10 @@ def test_energy():
|
||||
def test_mask():
|
||||
wl = 800e-9
|
||||
bw = 50e-9
|
||||
t = np.linspace(-1e-12, 1e-12, 4096)
|
||||
n = 8192
|
||||
t = np.linspace(-1e-12, 1e-12, n)
|
||||
w = wspace(t) + m_rads(wl)
|
||||
spec = Spectrum(np.ones(4096) + 0j, w, t)
|
||||
spec = Spectrum(np.ones(n) + 0j, w, t)
|
||||
mased = spec.mask_wl(wl, bw)
|
||||
above = mased.wl_int / mased.wl_int.max() - 0.5 >= 0
|
||||
diff = spec.wl_disp[above].max() - spec.wl_disp[above].min()
|
||||
assert diff == bw
|
||||
l, r = find_lobe_limits(mased.wl_disp, mased.wl_int)[1]
|
||||
assert r - l == pytest.approx(bw, rel=1e-2, abs=1e-10)
|
||||
|
||||
Reference in New Issue
Block a user