2024-06-01 19:00:12 +00:00
|
|
|
"""Test for the LimeNQR quackseq implementation."""
|
|
|
|
|
2024-05-30 13:40:49 +00:00
|
|
|
import unittest
|
|
|
|
import logging
|
|
|
|
import matplotlib.pyplot as plt
|
2024-06-01 19:00:12 +00:00
|
|
|
import numpy as np
|
2024-05-30 13:40:49 +00:00
|
|
|
from quackseq.pulsesequence import QuackSequence
|
|
|
|
from quackseq.event import Event
|
2024-06-01 19:00:12 +00:00
|
|
|
from quackseq.functions import SincFunction
|
2024-05-30 13:40:49 +00:00
|
|
|
from quackseq_limenqr.limenqr import LimeNQR
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
|
2024-06-01 19:00:12 +00:00
|
|
|
# Mute matplotlib logs
|
|
|
|
logging.getLogger("matplotlib").setLevel(logging.WARNING)
|
|
|
|
|
2024-05-30 13:40:49 +00:00
|
|
|
|
2024-06-01 19:00:12 +00:00
|
|
|
class TestQuackSequence(unittest.TestCase):
|
|
|
|
"""Test the LimeNQR quackseq implementation."""
|
|
|
|
def test_loopback(self):
|
|
|
|
"""Tests a loopback sequence."""
|
|
|
|
# Loopback sequence
|
2024-05-30 13:40:49 +00:00
|
|
|
seq = QuackSequence("test - simulation run sequence")
|
|
|
|
|
2024-06-01 19:00:12 +00:00
|
|
|
loopback = Event("tx", "20u", seq)
|
2024-05-30 13:40:49 +00:00
|
|
|
seq.add_event(loopback)
|
2024-06-01 19:00:12 +00:00
|
|
|
seq.set_tx_amplitude(loopback, 100)
|
2024-05-30 13:40:49 +00:00
|
|
|
seq.set_tx_phase(loopback, 0)
|
|
|
|
|
|
|
|
rect = SincFunction()
|
|
|
|
seq.set_tx_shape(loopback, rect)
|
|
|
|
|
|
|
|
seq.set_rx(loopback, True)
|
|
|
|
|
|
|
|
TR = Event("TR", "1m", seq)
|
|
|
|
seq.add_event(TR)
|
|
|
|
|
2024-06-01 19:00:12 +00:00
|
|
|
print(seq.to_json())
|
|
|
|
|
2024-05-30 13:40:49 +00:00
|
|
|
lime = LimeNQR()
|
|
|
|
lime.set_averages(1000)
|
|
|
|
lime.set_frequency(100e6)
|
|
|
|
lime.settings.channel = "0"
|
|
|
|
lime.settings.tx_gain = 30
|
|
|
|
|
|
|
|
result = lime.run_sequence(seq)
|
|
|
|
|
2024-06-01 19:00:12 +00:00
|
|
|
plt.plot(result.tdx, result.tdy.imag)
|
|
|
|
plt.plot(result.tdx, result.tdy.real)
|
|
|
|
plt.plot(result.tdx, np.abs(result.tdy))
|
|
|
|
plt.show()
|
|
|
|
|
2024-05-30 13:40:49 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-06-01 19:00:12 +00:00
|
|
|
unittest.main()
|