new mode --bin24
This commit is contained in:
@@ -13,6 +13,7 @@ from rfg_adc_plotter.gui.pyqtgraph_backend import (
|
||||
build_logdet_voltage_fft_input,
|
||||
build_main_window_layout,
|
||||
coalesce_packets_for_ui,
|
||||
TTY_CODE_SCALE_DENOM_24,
|
||||
compute_background_subtracted_bscan_levels,
|
||||
compute_aux_phase_curve,
|
||||
compute_do1_tagged_aggregate,
|
||||
@@ -87,6 +88,26 @@ class ProcessingTests(unittest.TestCase):
|
||||
self.assertTrue(np.all(volts >= -5.0))
|
||||
self.assertTrue(np.all(volts <= 5.0))
|
||||
|
||||
def test_convert_tty_i16_to_voltage_int24_denominator_maps_full_scale(self):
|
||||
full_scale = float(TTY_CODE_SCALE_DENOM_24)
|
||||
codes = np.asarray([-full_scale - 1.0, 0.0, full_scale], dtype=np.float32)
|
||||
volts = convert_tty_i16_to_voltage(codes, 5.0, denom=TTY_CODE_SCALE_DENOM_24)
|
||||
|
||||
self.assertAlmostEqual(float(volts[0]), -5.0, places=4)
|
||||
self.assertAlmostEqual(float(volts[1]), 0.0, places=6)
|
||||
self.assertAlmostEqual(float(volts[2]), 5.0, places=4)
|
||||
|
||||
# A quarter-scale 24-bit code must yield ~1.25 V with the int24 denom, but the
|
||||
# default int16 denom over-scales it ~256x and clips to the ±5 V range. This
|
||||
# guards that --bin24 uses the wider full-scale rather than the int16 one.
|
||||
quarter = np.asarray([full_scale / 4.0], dtype=np.float32)
|
||||
self.assertAlmostEqual(
|
||||
float(convert_tty_i16_to_voltage(quarter, 5.0, denom=TTY_CODE_SCALE_DENOM_24)[0]),
|
||||
1.25,
|
||||
places=4,
|
||||
)
|
||||
self.assertAlmostEqual(float(convert_tty_i16_to_voltage(quarter, 5.0)[0]), 5.0, places=6)
|
||||
|
||||
def test_build_logdet_voltage_fft_input_converts_codes_and_exponentiates(self):
|
||||
codes = np.asarray([-32768.0, 0.0, 32767.0], dtype=np.float32)
|
||||
volts, fft_input = build_logdet_voltage_fft_input(codes, 5.0)
|
||||
|
||||
Reference in New Issue
Block a user