30 lines
846 B
Python
30 lines
846 B
Python
import numpy as np
|
|
import pytest
|
|
|
|
import scgenerator as sc
|
|
|
|
|
|
def test_scaling():
|
|
period = 2
|
|
nt = 512
|
|
t = sc.tspace(period, nt)
|
|
w = sc.wspace(t)
|
|
dt = t[1] - t[0]
|
|
assert w[1] - w[0] == pytest.approx(2 * np.pi / (period + dt))
|
|
assert dt == pytest.approx(period / (nt - 1))
|
|
|
|
|
|
def test_wl_dispersion():
|
|
t = sc.tspace(t_num=1 << 15, dt=3.8e-15)
|
|
w = sc.wspace(t)
|
|
wl = sc.units.m.inv(w + sc.units.nm(1546))
|
|
wl_disp, ind_disp = sc.fiber.lambda_for_envelope_dispersion(wl, (950e-9, 4000e-9))
|
|
assert all(np.diff(wl_disp) > 0)
|
|
|
|
|
|
def test_iwspace():
|
|
t = sc.tspace(dt=15.6, t_num=512)
|
|
assert sc.math.iwspace(sc.wspace(t)) == pytest.approx(t)
|
|
assert sc.math.iwspace(sc.wspace(t) + 4564568456.4) != pytest.approx(t)
|
|
assert sc.math.iwspace(sc.wspace(t) + 4564568456.4) == pytest.approx(t, rel=1e-3)
|