added diagnostics
This commit is contained in:
@@ -135,41 +135,6 @@ class SweepProcessorTest(unittest.TestCase):
|
||||
np.testing.assert_allclose(result.real, expected, atol=1e-3)
|
||||
np.testing.assert_allclose(result.imag, 0.0, atol=1e-3)
|
||||
|
||||
def test_recovers_sweep_offset_by_a_full_branch(self) -> None:
|
||||
"""A stray +/-2*pi branch jump on the unwrap anchor must be snapped back.
|
||||
|
||||
The same physical sweep, offset by one full turn (as happens when trigger
|
||||
jitter carries sample 0 across the +/-pi cut), must map to the SAME frequency
|
||||
axis as the unshifted sweep instead of sliding ~one branch off the band.
|
||||
"""
|
||||
processor = self._processor()
|
||||
phase = np.linspace(0.0, 100.0, 401) # freq [2.0, 4.0] GHz, spans the band
|
||||
baseline = processor.reference_frequency_axis(_reference(phase))
|
||||
for turns in (+1, -1, +2):
|
||||
shifted = processor.reference_frequency_axis(_reference(phase + turns * 2.0 * np.pi))
|
||||
np.testing.assert_allclose(shifted, baseline, atol=1e-3)
|
||||
|
||||
def test_branch_recovery_keeps_a_glitched_sweep_usable(self) -> None:
|
||||
"""A branch-jumped sweep is pulled back onto the band, not rejected."""
|
||||
processor = self._processor()
|
||||
phase = np.linspace(0.0, 100.0, 401) + 2.0 * np.pi # one full turn off
|
||||
ref = _reference(phase)
|
||||
result = processor.process(np.abs(ref).astype(np.complex128), ref)
|
||||
self.assertIsNotNone(result)
|
||||
np.testing.assert_allclose(np.abs(result), 1.0, atol=1e-3)
|
||||
|
||||
def test_leaves_genuine_sub_branch_float_untouched(self) -> None:
|
||||
"""A real <pi sweep-to-sweep float must NOT be mistaken for a branch jump."""
|
||||
processor = self._processor()
|
||||
phase = np.linspace(0.0, 100.0, 401)
|
||||
baseline = processor.reference_frequency_axis(_reference(phase))
|
||||
for float_rad in (0.5, -0.5, 2.0, -2.0):
|
||||
floated = processor.reference_frequency_axis(_reference(phase + float_rad))
|
||||
# The float shifts the axis by float_rad * hz_per_rad and is preserved,
|
||||
# i.e. it is not snapped away as if it were a 2*pi branch error.
|
||||
expected = baseline + float_rad * processor.params.hz_per_rad
|
||||
np.testing.assert_allclose(floated, expected, atol=1e-3)
|
||||
|
||||
def test_handles_descending_phase_direction(self) -> None:
|
||||
# phase 0 -> 2 GHz, phase -100 -> 4 GHz (negative slope). Phase ramp
|
||||
# 0 -> -100 therefore sweeps frequency UP across the band.
|
||||
|
||||
Reference in New Issue
Block a user