Unknown signals¶
rp.analysis stands outside the data path: it says what a capture holds and what each signal is, so a receiver (often a
profile) can be built for it. survey(source) finds the signals in a capture: where, how wide, how strong, roughly what
symbol rate. profile(source) takes each one through the receive chain step by step and says which steps process it,
which profile decodes it, and what is still unsolved.
"""What is in a capture: find the signals, then work out the steps that process each one
python examples/unknown_signal.py
`rp.analysis` stands outside the data path. `survey(source)` finds the signals in a capture: where, how wide, how
strong, roughly what symbol rate. `profile(source)` then takes each one through the receive chain step by step
(channel, acquisition, timing, carrier, the bit map, codes, framing, scrambling), trying the shipped definitions at
each step. A signal whose every step is known names the profile that receives it; where nothing fits, the profile ends
with an UNSOLVED step and what it might be. `blind=True` also runs the blind tools there (codes, scramblers and frames
that are in no definition, as a `Guess` you can save as one), which takes tens of seconds a signal.
For a live radio, examples/live_profile.py does the same on a capture taken into memory first (the analysis
runs slower than the radio).
Here: an 8 MS/s capture holding a DVB-S carrier (the shipped dvbs/qpsk_3_4 transmitter: convolutional code 3/4,
Reed-Solomon, interleaver, energy dispersal) and an uncoded BPSK carrier, which no definition can explain.
"""
import time
import numpy as np
import rpps as rp
Fs = 8e6
def capture():
rng = np.random.default_rng(0)
# DVB-S: MPEG transport stream packets (0x47 sync byte, 187 bytes) at 1 MBd, 8 samples a symbol, 1.7 MHz up
ts = np.zeros((900, 188), np.uint8)
ts[:, 0] = 0x47
ts[:, 1:] = rng.integers(0, 256, (900, 187))
dvbs = rp.profile.load("dvbs/qpsk_3_4", sps=8).tx()(rp.Data(np.unpackbits(ts.reshape(-1)).astype(bool), Fs=1e6, sps=1,
flush=True))
n = len(dvbs)
# BPSK at 250 kBd, 2 MHz down
bpsk = rp.Data(rng.integers(0, 2, n//32 + 1).astype(bool), Fs=Fs/32, sps=1) * rp.symbol.load("psk/bpsk")
bpsk = bpsk + rp.wave.Shape(32, rp.signal.filters.load("pulse/rrc/0p35"))
a = (rp.Data(dvbs.data, Fs=Fs) + rp.signal.channel.CFO(1.7e6)).data
b = (rp.Data(bpsk.data[:n], Fs=Fs) + rp.signal.channel.CFO(-2.0e6)).data
x = a/np.sqrt(np.mean(np.abs(a)**2)) + 0.5*b/np.sqrt(np.mean(np.abs(b)**2))
x = x + 0.1*(rng.standard_normal(n) + 1j*rng.standard_normal(n))
return rp.source.Memory(x.astype(np.complex64), Fs=Fs, cf=1.2e9)
def main():
mem = capture()
print(f"{mem}\n")
survey = rp.analysis.survey(mem)
for i, s in enumerate(survey):
print(f" {i}: {s.describe()}")
assert len(survey) == 2
t = time.perf_counter()
profiles = rp.analysis.profile(mem, survey=survey, blind=False)
for p in profiles:
print(f"\n{p}")
print(f"\n({time.perf_counter() - t:.0f} s)")
named = {p.profile_name for p in profiles if p.solved}
assert named == {"dvbs/qpsk_3_4"}, named
assert sum(not p.solved for p in profiles) == 1 # the BPSK carrier: no code fits
# The profile it named receives the signal from here on: p.rx() (or `python -m rpps rx dvbs/qpsk_3_4 ...`)
dvbs = next(p for p in profiles if p.solved)
print(f"receive it with: {dvbs.rx()}")
if __name__ == "__main__":
main()
From the shell: python -m rpps survey capture.cf32 --fs ..., python -m rpps profile ..., python -m rpps solve ...
(-h on each). On a live radio: examples/live_profile.py.
Boxes on the signals¶
find_signals (which survey runs) is the box on each signal alone: edges, SNR over what the signal stands on, and
when it is on. Its false boxes are set by a false-alarm rate (pfa), not a threshold in dB. Finder does the same
block by block for a display, keeping each signal's id; with about a second of frames held, an update costs a few
milliseconds and its boxes hardly change from one to the next. A signal it no longer finds stays, stale, for its
hold.
"""Boxes on the signals in a capture, at once or block by block for a display
python examples/finding_signals.py
`rp.analysis.find_signals(x, Fs)` gives each signal's box: its edges (`lo`, `hi`, from the centre frequency), its SNR
over what it stands on, and when it is on (`t0`, `t1`, and `bursts` for one that comes and goes). The false-alarm rate
is the setting (`pfa`: expected false boxes in a capture of pure noise), not a threshold in dB. A narrower signal on a
wider one (a jammer on a carrier, carriers on a transponder's pedestal) is a box of its own, `over` the wider one,
which `holds` it.
`rp.analysis.spectrum.find.Finder` does the same on a stream, one block at a time, for a display: ids stay with
their signals from block to block, and what it finds does not depend on how the stream is cut into blocks. Effort
levels choose how hard it looks (`rp.effort("fast")` for a display, a few milliseconds a block). A signal not found
again stays, `stale`, for the Finder's `hold` [s] (-1, the default: for good). A signal on part of the time is a
`rp.analysis.Burst` (its `duty`, `last` burst, `period`).
Here: three RRC carriers at different levels, a narrow one jamming the widest, and a TDMA burst train.
"""
import numpy as np
import rpps as rp
from rpps.analysis.spectrum.find import Finder
Fs, N = 10e6, 1 << 20
def carrier(rng, baud, f, snr_db):
"""QPSK at `baud`, RRC 0.35, `f` from the centre, `snr_db` over the noise in its band"""
sps = int(Fs//baud)
d = rp.Data(rng.integers(0, 2, 2*(N//sps + 1)).astype(bool), Fs=baud, sps=1) * rp.symbol.load("psk/qpsk")
d = d + rp.wave.Shape(sps, rp.signal.filters.load("pulse/rrc/0p35"))
x = np.asarray(d.data)[:N]
x = x/np.sqrt(np.mean(np.abs(x)**2))*np.sqrt(10**(snr_db/10)*1.35*baud/Fs)
return x*np.exp(2j*np.pi*f/Fs*np.arange(N))
def capture():
rng = np.random.default_rng(1)
x = (rng.standard_normal(N) + 1j*rng.standard_normal(N))/np.sqrt(2)
x = x + carrier(rng, 1e6, -2.5e6, 15) + carrier(rng, 500e3, 0.0, 10) + carrier(rng, 1.25e6, 2.6e6, 20)
x = x + carrier(rng, 100e3, 2.8e6, 30) # jamming the 1.25 MBd carrier
gate = (np.arange(N)//(N//8)) % 2 == 1 # on half the time: four bursts
x = x + carrier(rng, 250e3, -4e6, 15)*gate
return x.astype(np.complex64)
def main():
x = capture()
sv = rp.analysis.find_signals(x, Fs, cf=2.4e9)
for s in sv:
print(f" {s.id}: {s.describe()}")
wide = {round(s.mid/1e5)/10: s for s in sv} # (by centre, MHz to 0.1)
assert set(wide) == {-4.0, -2.5, 0.0, 2.6, 2.8}, set(wide)
jammer, jammed = wide[2.8], wide[2.6]
assert jammer.over is jammed and jammed.holds == 1
assert len(wide[-4.0].bursts) == 4 # the burst train: a time box per burst
assert abs(wide[-2.5].width/1e6 - 1.17) < 0.1 # an RRC carrier's box: about 1.17 x its baud
# Block by block, as a display would: the same boxes once it holds enough frames, ids kept
with rp.effort("fast"):
f = Finder(Fs, nfft=4096, cf=2.4e9)
ids, bursts = [], set()
for i in range(0, N, 65536):
live = f.step(x[i:i + 65536])
if live is not None:
ids.append({round(s.mid/1e5)/10: s.id for s in live if s.mid > -3.5e6 and not s.stale})
bursts |= {s.id for s in live if isinstance(s, rp.analysis.Burst)}
print(f"\nlast block: {len(live)} signals; {', '.join(f'{m:+.1f} MHz' for m in sorted(ids[-1]))} (steady ones)")
assert set(ids[-1]) == {-2.5, 0.0, 2.6, 2.8}, ids[-1]
assert all(d == ids[-1] for d in ids[-4:]) # a steady signal keeps its id
assert len(bursts) >= 1 # the burst train, while the frames held see it come and go
if __name__ == "__main__":
main()
How it works (the floor, the detector, the levels it reads signals at) is in
rpps.analysis.spectrum.find.
The blind tools¶
Each blind tool states its statistic and chance level, so "nothing found" is an answer. Which tool answers which question
(symbol rate, constellation, FSK index, OFDM pilots, convolutional and block codes, scramblers, interleavers, frame
markers) is tabled in rpps.analysis. What they find can be saved as a definition
(Guess.save), and rp.sync.AcquireFEC finds a configured code on a live stream.