diff --git a/test/dma_tests.py b/test/dma_tests.py index 54e42fe8e..4b23bcffd 100644 --- a/test/dma_tests.py +++ b/test/dma_tests.py @@ -256,6 +256,7 @@ def dds_loopback( peak_min, use_obs=False, use_rx2=False, + useWindow=False, ): """dds_loopback: Test DDS loopback with connected loopback cables. This test requires a devices with TX and RX onboard where the transmit @@ -320,7 +321,9 @@ def dds_loopback( del sdr raise Exception(e) del sdr - tone_peaks, tone_freqs = spec.spec_est(data, fs=RXFS, ref=2 ** 15, plot=False) + tone_peaks, tone_freqs = spec.spec_est( + data, fs=RXFS, ref=2 ** 15, plot=False, useWindow=useWindow + ) indx = np.argmax(tone_peaks) diff = np.abs(tone_freqs[indx] - frequency) s = "Peak: " + str(tone_peaks[indx]) + "@" + str(tone_freqs[indx]) diff --git a/test/rf/spec.py b/test/rf/spec.py index c0c7c6967..f6d078e3d 100644 --- a/test/rf/spec.py +++ b/test/rf/spec.py @@ -18,13 +18,14 @@ from scipy.signal import find_peaks -def spec_est(x, fs, ref=2 ** 15, plot=False): +def spec_est(x, fs, ref=2 ** 15, plot=False, useWindow=False): N = len(x) # Apply window - window = signal.kaiser(N, beta=38) - # x = multiply(x, window) + if useWindow: + window = signal.kaiser(N, beta=8.6) + x = multiply(x, window) # Use FFT to get the amplitude of the spectrum ampl = 1 / N * absolute(fft(x)) diff --git a/test/test_daq2_p.py b/test/test_daq2_p.py index f274d9f13..3706212b3 100644 --- a/test/test_daq2_p.py +++ b/test/test_daq2_p.py @@ -26,17 +26,16 @@ def test_daq2_rx_data(test_dma_rx, iio_uri, classname, channel): @pytest.mark.parametrize("channel", [0]) @pytest.mark.parametrize("param_set", [dict()]) @pytest.mark.parametrize( - "frequency, scale", + "frequency, scale, peak_min", [ - (5000000, 0.12), - (10000000, 0.06), - (10000000, 0.12), - (15000000, 0.12), - (15000000, 0.5), - (200000000, 0.5), + (5000000, 0.12, -55), + (10000000, 0.06, -61), + (10000000, 0.12, -55), + (15000000, 0.12, -61), + (15000000, 0.5, -42), + (200000000, 0.5, -42), ], ) -@pytest.mark.parametrize("peak_min", [-45]) def test_daq2_dds_loopback( test_dds_loopback, iio_uri, @@ -48,7 +47,14 @@ def test_daq2_dds_loopback( peak_min, ): test_dds_loopback( - iio_uri, classname, param_set, channel, frequency, scale, peak_min + iio_uri, + classname, + param_set, + channel, + frequency, + scale, + peak_min, + useWindow=True, ) diff --git a/test/test_daq3_p.py b/test/test_daq3_p.py index 7fc5348ca..134039a95 100644 --- a/test/test_daq3_p.py +++ b/test/test_daq3_p.py @@ -26,17 +26,16 @@ def test_daq3_rx_data(test_dma_rx, iio_uri, classname, channel): @pytest.mark.parametrize("channel", [0, 1]) @pytest.mark.parametrize("param_set", [dict()]) @pytest.mark.parametrize( - "frequency, scale", + "frequency, scale, peak_min", [ - (5000000, 0.12), - (10000000, 0.06), - (10000000, 0.12), - (15000000, 0.12), - (15000000, 0.5), - (200000000, 0.5), + (5000000, 0.12, -55), + (10000000, 0.06, -61), + (10000000, 0.12, -55), + (15000000, 0.12, -55), + (15000000, 0.5, -42), + (200000000, 0.5, -42), ], ) -@pytest.mark.parametrize("peak_min", [-50]) def test_daq3_dds_loopback( test_dds_loopback, iio_uri, @@ -48,7 +47,14 @@ def test_daq3_dds_loopback( peak_min, ): test_dds_loopback( - iio_uri, classname, param_set, channel, frequency, scale, peak_min + iio_uri, + classname, + param_set, + channel, + frequency, + scale, + peak_min, + useWindow=True, )