checkbox log det raw
This commit is contained in:
@ -6,7 +6,11 @@ import numpy as np
|
||||
import unittest
|
||||
|
||||
from rfg_adc_plotter.constants import FFT_LEN, SWEEP_FREQ_MAX_GHZ, SWEEP_FREQ_MIN_GHZ
|
||||
from rfg_adc_plotter.gui.pyqtgraph_backend import apply_working_range
|
||||
from rfg_adc_plotter.gui.pyqtgraph_backend import (
|
||||
apply_working_range,
|
||||
apply_working_range_to_aux_curves,
|
||||
resolve_visible_aux_curves,
|
||||
)
|
||||
from rfg_adc_plotter.processing.calibration import (
|
||||
build_calib_envelope,
|
||||
calibrate_freqs,
|
||||
@ -146,6 +150,36 @@ class ProcessingTests(unittest.TestCase):
|
||||
self.assertEqual(cropped_freqs.shape, (0,))
|
||||
self.assertEqual(cropped_sweep.shape, (0,))
|
||||
|
||||
def test_apply_working_range_to_aux_curves_uses_same_mask_as_raw_sweep(self):
|
||||
freqs = np.linspace(3.3, 14.3, 6, dtype=np.float64)
|
||||
sweep = np.asarray([0.0, 1.0, np.nan, 3.0, 4.0, 5.0], dtype=np.float32)
|
||||
aux = (
|
||||
np.asarray([10.0, 11.0, 12.0, 13.0, 14.0, 15.0], dtype=np.float32),
|
||||
np.asarray([20.0, 21.0, 22.0, 23.0, 24.0, 25.0], dtype=np.float32),
|
||||
)
|
||||
|
||||
cropped_freqs, cropped_sweep = apply_working_range(freqs, sweep, 4.0, 12.5)
|
||||
cropped_aux = apply_working_range_to_aux_curves(freqs, sweep, aux, 4.0, 12.5)
|
||||
|
||||
self.assertIsNotNone(cropped_aux)
|
||||
self.assertEqual(cropped_aux[0].shape, cropped_freqs.shape)
|
||||
self.assertEqual(cropped_aux[1].shape, cropped_freqs.shape)
|
||||
self.assertEqual(cropped_aux[0].shape, cropped_sweep.shape)
|
||||
self.assertTrue(np.allclose(cropped_aux[0], np.asarray([11.0, 13.0, 14.0], dtype=np.float32)))
|
||||
self.assertTrue(np.allclose(cropped_aux[1], np.asarray([21.0, 23.0, 24.0], dtype=np.float32)))
|
||||
|
||||
def test_resolve_visible_aux_curves_obeys_checkbox_state(self):
|
||||
aux = (
|
||||
np.asarray([1.0, 2.0], dtype=np.float32),
|
||||
np.asarray([3.0, 4.0], dtype=np.float32),
|
||||
)
|
||||
|
||||
self.assertIsNone(resolve_visible_aux_curves(aux, enabled=False))
|
||||
visible = resolve_visible_aux_curves(aux, enabled=True)
|
||||
self.assertIsNotNone(visible)
|
||||
self.assertTrue(np.allclose(visible[0], aux[0]))
|
||||
self.assertTrue(np.allclose(visible[1], aux[1]))
|
||||
|
||||
def test_fft_helpers_return_expected_shapes(self):
|
||||
sweep = np.sin(np.linspace(0.0, 4.0 * np.pi, 128)).astype(np.float32)
|
||||
freqs = np.linspace(3.3, 14.3, 128, dtype=np.float64)
|
||||
|
||||
Reference in New Issue
Block a user