Initial Galileo receiver and SignalSim integration
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from galileo_rx.signal_profiles import galileo_e1_profile
|
||||
from galileo_rx.signals.signalsim_codes import SignalSimCodeProvider
|
||||
|
||||
|
||||
def _checkout() -> Path:
|
||||
candidates = [Path("signalsim/SignalSim"), Path("../SignalSim"), Path("../signalsim/SignalSim")]
|
||||
for candidate in candidates:
|
||||
if (candidate / "src" / "MemoryCode.dat").is_file():
|
||||
return candidate.resolve()
|
||||
pytest.skip("local globsky/SignalSim checkout with src/MemoryCode.dat is unavailable")
|
||||
|
||||
|
||||
@pytest.mark.signalsim
|
||||
def test_signalsim_e1_code_table_unpacking_and_components() -> None:
|
||||
provider = SignalSimCodeProvider(_checkout())
|
||||
profile = galileo_e1_profile()
|
||||
e1b = provider.primary_code(profile, "E1B", 1)
|
||||
e1c = provider.primary_code(profile, "E1C", 1)
|
||||
assert e1b.dtype == np.int8 and e1b.size == 4092
|
||||
assert e1c.dtype == np.int8 and e1c.size == 4092
|
||||
assert set(e1b.tolist()) == {-1, 1}
|
||||
assert not np.array_equal(e1b, e1c)
|
||||
# First table word is 0xf5d71013 and SignalSim reads it MSB first.
|
||||
np.testing.assert_array_equal(e1b[:8], [-1, -1, -1, -1, 1, -1, 1, -1])
|
||||
# Every 32-word storage sector has one discarded padding bit. Chip 1023
|
||||
# is therefore word 32 bit 31, not word 31 bit 0.
|
||||
words = provider._e1_words[0] # executable check of the external table layout
|
||||
expected_chip_1023 = -1 if (int(words[32]) >> 31) & 1 else 1
|
||||
assert int(e1b[1023]) == expected_chip_1023
|
||||
|
||||
|
||||
@pytest.mark.signalsim
|
||||
def test_signalsim_e1c_secondary_is_25_symbols_lsb_first() -> None:
|
||||
provider = SignalSimCodeProvider(_checkout())
|
||||
secondary = provider.secondary_code(galileo_e1_profile(), "E1C", 1)
|
||||
assert secondary is not None and secondary.size == 25
|
||||
# 0x9b501c positions are addressed least-significant bit first.
|
||||
expected_bits = np.asarray([(0x9B501C >> index) & 1 for index in range(25)])
|
||||
np.testing.assert_array_equal(secondary, np.where(expected_bits == 0, 1, -1))
|
||||
assert provider.secondary_code(galileo_e1_profile(), "E1B", 1) is None
|
||||
Reference in New Issue
Block a user