Skip to content

Commit

Permalink
Vary peak_min according to scale
Browse files Browse the repository at this point in the history
Signed-off-by: Julia Pineda <Julia.Pineda@analog.com>
  • Loading branch information
jpineda3 committed Apr 4, 2024
1 parent a17a959 commit 723374f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
5 changes: 4 additions & 1 deletion test/dma_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down
7 changes: 4 additions & 3 deletions test/rf/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
24 changes: 15 additions & 9 deletions test/test_daq2_p.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
)


Expand Down
24 changes: 15 additions & 9 deletions test/test_daq3_p.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
)


Expand Down

0 comments on commit 723374f

Please sign in to comment.