28 lines
779 B
Python
28 lines
779 B
Python
import numpy as np
|
|
|
|
from galileo_rx.acquisition.detector import parabolic_offset
|
|
from galileo_rx.acquisition.metrics import calculate_metrics, circular_guard_mask
|
|
|
|
|
|
def test_circular_peak_exclusion_wraparound() -> None:
|
|
mask = circular_guard_mask(10, 0, 2)
|
|
assert not mask[0] and not mask[1] and not mask[2]
|
|
assert not mask[8] and not mask[9]
|
|
assert mask[3]
|
|
|
|
|
|
def test_second_peak_ignores_guard() -> None:
|
|
power = np.ones(20)
|
|
power[0] = 100
|
|
power[19] = 80
|
|
power[8] = 10
|
|
metrics = calculate_metrics(power, 0, 1)
|
|
assert metrics["second_peak"] == 10
|
|
assert metrics["peak_to_second"] == 10
|
|
|
|
|
|
def test_parabolic_peak_interpolation() -> None:
|
|
assert parabolic_offset(3.0, 4.0, 3.0) == 0.0
|
|
assert parabolic_offset(2.0, 4.0, 3.0) > 0
|
|
|