def test_with_points_slopes(): from copy import copy # test the new fi = np.array([1e4, 1e9]) ldbc_fi = np.array([-40, -150]) slopes = np.array([-30, -20]) pnoise_model = Pnoise.with_points_slopes(fi, ldbc_fi, slopes) fm = np.logspace(3, 9, 20) pnoise_extrapolated = copy(pnoise_model) pnoise_extrapolated.fm = fm
def test_with_points_slopes(): from copy import copy # test the new fi = np.array([1e4, 1e9]) ldbc_fi = np.array([-40, -150]) slopes = np.array([-30, -20]) pnoise_model = Pnoise.with_points_slopes(fi, ldbc_fi, slopes) fm = np.logspace(3, 9, 20) pnoise_extrapolated = copy(pnoise_model) pnoise_extrapolated.fm = fm
def test_generate_samples(): pnobj = Pnoise.with_points_slopes([1e5, 1e6, 1e9], [-80, -100, -120], [-30, -20, 0]) npoints = 2**16 fs = 500e6 phi_t = pnobj.generate_samples(npoints, fs) f, pxx = sig.welch(phi_t, fs, window='blackman', nperseg=2**8) ldbc_noise = 10 * np.log10(pxx / 2) pnobj.fm = f[1:] error = np.max(np.abs((pnobj.ldbc - ldbc_noise[1:]) / pnobj.ldbc * 100)) assert error < 2.5
def test_generate_samples(): pnobj = Pnoise.with_points_slopes([1e5, 1e6, 1e9], [-80,-100,-120], [-30,-20,0]) npoints = 2 ** 16 fs = 500e6 phi_t = pnobj.generate_samples(npoints, fs) f, pxx = sig.welch(phi_t, fs, window='blackman', nperseg=2**8) ldbc_noise = 10 * np.log10(pxx / 2) pnobj.fm = f[1:] error = np.max(np.abs((pnobj.ldbc - ldbc_noise[1:]) / pnobj.ldbc * 100)) assert error < 2.5