34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
import numpy as np
|
|
|
|
from galileo_rx.fixed_point.bittrue_pipeline import compare_acquisition, sweep_acquisition_word_lengths
|
|
from galileo_rx.fixed_point.fixed_acquisition import FixedPcpsAcquisition
|
|
|
|
|
|
def test_fixed_acquisition_peak_agrees_with_float() -> None:
|
|
rng = np.random.default_rng(4)
|
|
count = 256
|
|
fs = 1.024e6
|
|
replica = np.where(rng.integers(0, 2, count), 1.0, -1.0)
|
|
delay = 73
|
|
doppler = 4000.0
|
|
time_s = np.arange(count) / fs
|
|
samples = np.roll(replica, delay) * np.exp(2j * np.pi * doppler * time_s)
|
|
bins = np.asarray([-4000.0, 0.0, 4000.0])
|
|
reference = np.asarray([
|
|
np.abs(np.fft.ifft(np.fft.fft(samples * np.exp(-2j * np.pi * frequency * time_s)) * np.conjugate(np.fft.fft(replica)))) ** 2
|
|
for frequency in bins
|
|
])
|
|
fixed = FixedPcpsAcquisition().search(samples, replica, fs, bins)
|
|
comparison = compare_acquisition(reference / count**2, fixed, threshold=2.5)
|
|
assert comparison.doppler_bin_agreement
|
|
assert comparison.code_phase_agreement
|
|
assert comparison.acquisition_decision_agreement
|
|
|
|
|
|
def test_word_length_sweep_reports_each_width() -> None:
|
|
rng = np.random.default_rng(7)
|
|
replica = np.where(rng.integers(0, 2, 64), 1.0, -1.0)
|
|
reports = sweep_acquisition_word_lengths(np.roll(replica, 9).astype(complex), replica, 1e6, np.asarray([0.0]), [6, 8])
|
|
assert [item["input_bits"] for item in reports] == [6, 8]
|
|
assert all(item["code_phase_agreement"] for item in reports)
|