new adc
This commit is contained in:
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import numpy as np
|
||||
import unittest
|
||||
|
||||
from rfg_adc_plotter.processing.fft import compute_fft_mag_row
|
||||
from rfg_adc_plotter.state.ring_buffer import RingBuffer
|
||||
|
||||
|
||||
@ -72,6 +73,19 @@ class RingBufferTests(unittest.TestCase):
|
||||
self.assertEqual(ring.last_fft_db.shape, (ring.fft_bins,))
|
||||
self.assertIsNotNone(ring.distance_axis)
|
||||
|
||||
def test_ring_buffer_rebuilds_fft_from_complex_input(self):
|
||||
ring = RingBuffer(max_sweeps=2)
|
||||
freqs = np.linspace(3.3, 14.3, 64, dtype=np.float64)
|
||||
complex_input = np.exp(1j * np.linspace(0.0, 2.0 * np.pi, 64)).astype(np.complex64)
|
||||
display_sweep = np.abs(complex_input).astype(np.float32)
|
||||
ring.push(display_sweep, freqs, fft_input=complex_input)
|
||||
|
||||
ring.set_fft_mode("direct")
|
||||
|
||||
expected = compute_fft_mag_row(complex_input, freqs, ring.fft_bins, mode="direct")
|
||||
self.assertTrue(np.allclose(ring.get_last_fft_linear(), expected))
|
||||
self.assertTrue(np.allclose(ring.get_display_raw()[: display_sweep.size, -1], display_sweep))
|
||||
|
||||
def test_ring_buffer_reset_clears_cached_history(self):
|
||||
ring = RingBuffer(max_sweeps=2)
|
||||
ring.push(np.linspace(0.0, 1.0, 64, dtype=np.float32), np.linspace(4.0, 10.0, 64))
|
||||
|
||||
Reference in New Issue
Block a user