73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
from __future__ import annotations
|
|
|
|
import numpy as np
|
|
|
|
from galileo_rx.signal_profiles import galileo_e1_profile
|
|
from galileo_rx.signals.code_provider import SyntheticCodeProvider
|
|
from galileo_rx.signals.e1_modulation import E1Modulation
|
|
from galileo_rx.signals.fullband_e1_generator import FullBandE1SignalGenerator
|
|
from galileo_rx.signals.signal_generator import ChannelModelConfig, SatelliteSignalConfig
|
|
|
|
|
|
def _generator() -> FullBandE1SignalGenerator:
|
|
return FullBandE1SignalGenerator(
|
|
galileo_e1_profile(),
|
|
SyntheticCodeProvider(),
|
|
32.736e6,
|
|
2.25e6,
|
|
satellites=[
|
|
SatelliteSignalConfig(
|
|
3,
|
|
"E1C",
|
|
code_delay_chips=7.25,
|
|
doppler_hz=1375.0,
|
|
modulation=E1Modulation.CBOC,
|
|
)
|
|
],
|
|
channel=ChannelModelConfig(add_awgn=False),
|
|
)
|
|
|
|
|
|
def test_fullband_generator_is_streaming_and_double_precision() -> None:
|
|
one_shot, truth = _generator().generate(4099)
|
|
chunked_generator = _generator()
|
|
chunked = np.concatenate([chunked_generator.generate(count)[0] for count in (1, 17, 1000, 3, 3078)])
|
|
assert one_shot.dtype == np.complex128
|
|
np.testing.assert_allclose(chunked, one_shot, atol=2e-13, rtol=0.0)
|
|
assert truth.satellites[0].initial_code_delay_samples == 7.25 * 32.0 + 32.0
|
|
|
|
|
|
def test_fullband_generator_supports_real_if_quantization() -> None:
|
|
generator = FullBandE1SignalGenerator(
|
|
galileo_e1_profile(),
|
|
SyntheticCodeProvider(),
|
|
32.736e6,
|
|
4.092e6,
|
|
True,
|
|
[SatelliteSignalConfig(1, "E1B", modulation=E1Modulation.CBOC)],
|
|
ChannelModelConfig(add_awgn=False, quantization_bits=8),
|
|
)
|
|
samples, _ = generator.generate(2048)
|
|
assert samples.dtype == np.float64
|
|
assert np.max(samples) <= 1.0 - 1.0 / 128.0
|
|
np.testing.assert_allclose(samples * 128.0, np.round(samples * 128.0), atol=1e-12)
|
|
|
|
|
|
def test_fullband_generator_exposes_independent_code_doppler_truth() -> None:
|
|
generator = FullBandE1SignalGenerator(
|
|
galileo_e1_profile(),
|
|
SyntheticCodeProvider(),
|
|
satellites=[
|
|
SatelliteSignalConfig(
|
|
1,
|
|
"E1C",
|
|
doppler_hz=1000.0,
|
|
code_doppler_hz=0.75,
|
|
modulation=E1Modulation.CBOC,
|
|
)
|
|
],
|
|
channel=ChannelModelConfig(add_awgn=False),
|
|
)
|
|
_, truth = generator.generate(128)
|
|
assert truth.satellites[0].initial_code_doppler_hz == 0.75
|