Sync
rpps.sync ¶
Sync: estimate something unknown about the data and correct or align it, at whatever representation it can be separated
Its estimates go to stream.est[name], never into the data. Block estimation and block-rate tracking are first
class; per-sample loops are second class.
First class: block estimation, tracked across windows¶
Estimate from a window with block operations (FFTs, correlation, least squares), then a slow loop run once per window
(track: critically damped second order, wide while it pulls in, coasting through gated windows) carries each parameter
and its rate across windows and gates outliers; the correction is evaluated per item.
| Estimates | Operator | Profile method |
|---|---|---|
| symbol timing | time.OerderMeyr: square-law, cubic interpolation; follows a clock 200 ppm off |
timing: oerder_meyr (default) |
| symbol timing, the matched filter fused in | time.MatTrack: the matched filter's energy maximum (MatRRC), read only at the instants; on a GPU too |
timing: mat |
| carrier frequency and phase | phase.MPower: M-th power of the phase, FFT acquisition |
carrier: mpower (default) |
| channel | equalize.BlockLS: least squares per window against decisions; blind=True: constant modulus by least squares until the eye opens |
equalize: ls (default), "blind": true |
| OFDM timing and frequency | CPSync: from the cyclic prefix |
|
| carrier phase per frame | PilotPhase (pilot blocks), phase.FFCarrier (Viterbi & Viterbi) |
carrier: pilots, carrier: ff |
| spectral inversion | Inversion, inversion.sense (known symbols turning backwards) |
inversion |
| frame starts | FrameSync (a preamble and the best word of a header code; or named alternatives, Zadoff-Chu sets, a word mid-burst, real levels, what the match says: word, scale, cfo, esn0, modulation), Delimiter (a word among bits) |
frame, delimit |
| alignment on bits | Align (markers, patterns, polarity), Puncture (puncture phase) |
align, puncture |
| modulation (PSK, QAM, APSK), rate, roll-off, offset | Acquire (detect once; roll-off: rate.find_rolloff), Lock (a snapshot: Lock.find, lock.update; contiguous blocks joined: lock.follow); code phase and Doppler: acquire_code |
|
| channel code, bit map, alignment | AcquireFEC |
|
| bursts | Burst splits a stream into bursts, BurstTx places them; Bursts on many carriers, placed in a burst time plan (rpps.plan) whose origin it acquires and tracks, PlanTx places them by one; Preamble finds each one's preamble (attach_tx(): its PreambleTx) |
burst, preamble |
| a pilot tone | ToneLock (FM stereo's 19 kHz, ATSC's pilot) |
Rules for feedforward estimators:
- Windows sit at absolute stream positions (
[k*W, k*W + L), history carried between blocks), so output does not depend on how the stream is cut. - Drifting parameters are tracked across windows, not held per window (a free-running SDR is 10-20 ppm off and wanders), and the correction is evaluated per sample.
- Windows are set in time, not symbols: oscillator phase wanders in time (cycle slips at 8 ms windows, none at 2 ms).
- Latency is declared in
stream.est[name]["latency"](seconds), not added tometa.delay, the group delay.
A profile's sync steps name what is estimated (carrier, timing, equalize, frame) and get the first-class
method; another is chosen by name in defaults: {"timing": {"method": "mat"}}. A new estimator is registered with
rp.profile.steps.register_sync_method.
Second class: per-sample loops¶
loops (rpps.sync.loops) holds them, for signals and conditions block estimation does not suit, as references and for
comparison: loops.MM (Mueller & Muller, Gardner), loops.TLL (a timing locked loop around a detector from
loops.ted: ted="zx" zero crossing, "el" early-late), loops.Costas (M-PSK, or any constellation's points),
loops.AGC, loops.PeakAGC, loops.Squelch, the adaptive equalizers loops.LMS and loops.CMA. Profiles reach them
by name (timing: mm, gardner, timing: {"method": "tll", "ted": "el"}, carrier: costas, agc: loop,
equalize: lms, cma). Their loop filter is loops.pll.PILoop (gains from a bandwidth: loops.pll.loop_gains).
Known, measured, detected¶
time.Known: timing that is given, not estimated (a loopback, a source whose timing is known); fuses the matched filter before it (timing: known).- On a GPU (
rpps._accel.device(), CUDA or ROCm/HIP; numpy without one), by"device": truein a step's sync settings:time.MatTrack(timing: mat: the held samples filtered and read at the instants on the device, windows measured a group at a time) andFrameSync(frame: the preamble metric, and the header words ranked in one matrix product). Both agree with their numpy paths to single-precision rounding: the same frames, the same symbols to 1e-4. detect,Detection,rate.find_baud: the feed-forward estimatesAcquireruns (rate, timing, modulation, offset, phase); blind analysis uses them too.quality: Es/N0, Eb/N0 and EVM of locked symbols, once (measure), over a window (Track) or on the stream (Monitor,{"sync": "quality"}); each symbol's error (errors) and an analyser's error summary (summary: EVM, MER, magnitude and phase error, IQ offset, gain imbalance, quadrature error).
AcquireFEC does for the code what Acquire does for the modulation: on timed, carrier-corrected symbols it finds
the configured code, bit map and alignment (analysis.identify: convolutional codes, RS behind a Forney interleaver,
HDLC, block codes), names the profile that decodes it, then tracks by re-encoding once per window and putting carrier
turns and symbol slips right; est["fec"].rx() decodes. With blind=True the blind tools (rpps.analysis) run when no
definition fits; what they find is a Guess, a definition that decodes once saved.
Modules:
| Name | Description |
|---|---|
acquire |
Acquisition: symbol rate, timing, modulation, frequency offset and phase from baseband samples: once ( |
acquire_fec |
AcquireFEC: which code timed symbols carry, found as the stream arrives (the scans are in rpps.analysis.identify) |
agc |
Automatic gain control, with no loop over samples |
align |
|
burst |
Per-burst acquisition: cut a stream of samples into the bursts that rise out of its noise floor |
code_acquire |
|
equalize |
Equalizers: |
frame |
Frame sync: where frames start (rpps.sync) |
inversion |
Spectral inversion (a stream conjugated) found by known symbols turning backwards, and undone (rpps.sync) |
kernels |
Batch kernels of the sync operators: |
ofdm |
OFDM symbol timing and fractional carrier frequency from the cyclic prefix (van de Beek, Sandell & Borjesson 1997) |
pilots |
|
plan |
Bursts on many carriers, placed in a burst time plan (rpps.plan): the return link of an MF-TDMA network |
preamble |
A preamble at the start of a burst: where it is, and the carrier offset its repetition gives |
puncture |
|
quality |
Signal quality of recovered symbols: Es/N0, Eb/N0, EVM, measured once ( |
rate |
Symbol rate estimates: the |x|^2 cyclostationary line on samples ( |
squelch |
Squelch: detects that a signal is present, and gates the stream on it |
tone |
A phase-locked tone: the oscillator a pilot sets (FM stereo's 19 kHz, ATSC's pilot), and the signal mixed with it |
track |
Block-rate tracking (rpps.sync): a slow loop run once per window over the window estimates |
acquire ¶
Acquisition: symbol rate, timing, modulation, frequency offset and phase from baseband samples: once (detect), as
snapshots of separate blocks (Lock: a display that seeks, pauses and retunes) and as the stream arrives (Acquire)
Everything here is feed-forward: symbol rate and timing from the matrix matched filter, frequency/phase from the M-th power of the symbols, modulation from the likelihood of the corrected symbols under each candidate constellation.
The likelihood needs the noise. Fitted per candidate (each its own variance, the points at the symbols' rms, noise
included), a denser constellation explains noise better, so at low SNR the densest candidate won (noise alone was named
32APSK, QPSK at 4 dB 64QAM): the generalised likelihood's known bias to higher orders. So each candidate is scored at
its own Es/N0 from the symbols' moments (rpps.sync.quality.m2m4: what that candidate's kurtosis says the signal and
noise are; the quasi-hybrid likelihood test), unless the fit's own winner reads over FIT_MIN dB: there the fit is
right and M2M4 fades (for QAM), so the fit; at the caller's Es/N0 when it gives one (esn0=, from a known sequence: rpps.sync.quality.from_sequence
on a Zadoff-Chu). It needs nothing but the symbols. With the rate given, BPSK is named 7 dB lower, QPSK from 1.75 dB
(it was 4.75), 32QAM and the APSKs 1.75 dB lower; 64QAM's 10 dB is honest now (tools/modclass_bench.py).
min_evidence makes detect say it doesn't know (mod None, the leader in best) rather than name a guess: when the
leader doesn't beat Gaussian noise of the same power by NULL_MARGIN nats in all (Detection.over_noise: is there a
constellation at all), or doesn't lead the runner-up by min_evidence nats (Detection.evidence: which one). 10 nats
never named noise; it named 8PSK as 16PSK and 16QAM as 64QAM now and then at 8 dB, and at 0-4 dB names 9-22%.
Classes:
| Name | Description |
|---|---|
Detection |
Result of |
Lock |
A signal's symbols, as a snapshot: found once by a full search ( |
Acquire |
Detect as soon as the signal is there, then keep refining as the stream grows |
Functions:
| Name | Description |
|---|---|
symmetry |
Order M of the rotational symmetry of a point set (the M-th power removes the modulation) |
candidates |
Load candidate constellations from config/constellation: {name: unit-rms points}. Each is read once per config |
turned_candidates |
Turned candidates. |
correct |
Feed-forward frequency + phase correction for a candidate. Returns (symbols, cfo cycles/symbol, phase); a carrier |
drift |
The phase curvature c (radians a symbol^2) a drifting carrier leaves on symbols y. |
score |
Mean log-likelihood per symbol of unit-rms y under equiprobable points with Gaussian noise: the variance fitted |
score_all |
Scores of {name: (corrected unit-rms symbols, points)} and how they were made: at the caller's esn0 ("given"); each |
null_score |
|
track_timing |
Refine sps from the drift of the best timing between the start and end of x. Returns (sps, tau) |
detect |
Find symbol rate, timing, modulation, frequency offset and phase from baseband samples |
onset |
Where a signal comes on in x. The first block whose power reaches |
Detection ¶
Result of detect. Acquire stamps it on its blocks: meta.det
strength of the symbol-rate line the rate came from, over its local floor (noise peaks at about 3-4; a rate
taken from a weaker line is a guess)
beta: the roll-off of the matched filter that scored best; rolloff: the spectrum's (rate.find_rolloff), when measured
mod: the modulation, None when detect was asked for min_evidence and the evidence is short (best the leader)
how: how the candidates were scored: "given" (at the caller's esn0, given), "moments" (each at its M2M4 Es/N0) or
"fit" (each its own variance). null: the score of Gaussian noise of the symbols' power (see over_noise)
drift: the carrier's frequency rate over the symbols searched, Hz/s (a Doppler rate; 0.0 when none stands out:
drift), taken off before the symbols were scored
Attributes:
| Name | Type | Description |
|---|---|---|
margin |
Score lead of the detected modulation over the runner-up |
|
evidence |
Total log-likelihood lead of the leader over the runner-up (nats): margin times symbols |
|
over_noise |
Total log-likelihood lead of the leader over Gaussian noise of the same power (nats): a constellation at all |
Source code in src/rpps/sync/acquire.py
Lock ¶
A signal's symbols, as a snapshot: found once by a full search (Lock.find), then followed block by block
(update) without searching again. Nothing is held between blocks, and they need not be consecutive, so a display
that seeks, pauses or changes channel gets an answer for every frame:
lk = rp.sync.Lock.find(x, Fs) # raises rp.errors.NoLock(reason) when there is nothing to lock to
lk = lk.update(x_next) # same modulation and roll-off; timing, rate and cfo followed
lk.symbols, lk.quality.esn0_db, lk.stale # stale: the signal is not the one found, search again
lk = lk.refine(x_longer) # the rate searched again on more signal (Acquire, as history grows)
lk = lk.follow(x_after, at=pos) # the block right after this one: its symbols join on with no slip
det: the Detection for this block (rate, timing on its lattice from x[0], cfo, phase, gain, modulation)
found: the Detection of the full search the lock started from
symbols: matched-filtered, frequency and phase corrected, unit rms, at centres (sample positions in the block)
points: the constellation (unit rms). quality: rpps.sync.quality.Quality of the symbols
stale: why the lock no longer fits (Es/N0 fell drop_db below the search's, the rate moved more than drift from
it, or one of the search's RECHECK runners-up now fits better), None while it does
x: the block the lock is of (after follow, with the end of the one before that the filter needs)
end: the stream position just past x, when at gave where x starts (None otherwise)
What an analyser shows of the block: decisions(), errors() and summary() (rpps.sync.quality: EVM, MER, IQ
offset, gain imbalance, quadrature error), derotated() (x as the symbols see it), matched(up) (the matched filter
between the symbols: eye diagrams) and reference() (the ideal waveform of the decided symbols)
Methods:
| Name | Description |
|---|---|
find |
Search x for a signal: its symbol rate, modulation, roll-off, timing, cfo and phase ( |
update |
The same signal in a new block x (anywhere in the stream: consecutive or not): timing and rate followed from |
follow |
The block right after this lock's (contiguous: its first sample follows the last of |
refine |
The search again on more of the signal (x: a longer stretch), its modulation and roll-off kept: the rate is |
decisions |
The nearest constellation point to each symbol (unit rms, as |
errors |
Each symbol's error against its decision: rpps.sync.quality.Errors (vector; evm_pct and mag_pct as a percentage |
summary |
An analyser's error summary of the symbols: rpps.sync.quality.Summary (EVM rms and peak, MER, magnitude and |
derotated |
x with the carrier offset and phase taken out and scaled as the symbols are (their matched filter at |
matched |
The matched filter's output between the symbols, |
reference |
The ideal waveform of the block: the decided symbols through the root raised cosine pulse at |
find
classmethod
¶
find(x, Fs, names=None, betas=None, span=8, baud=None, lock=5.0, min_samples=1024, drop_db=6.0, drift=0.002, at=None, esn0=None, min_evidence=None)
Search x for a signal: its symbol rate, modulation, roll-off, timing, cfo and phase (detect)
names / betas: candidate modulations and roll-offs (default: candidates(), and as detect chooses them)
baud: the symbol rate when known: no rate search and no line needed
lock: symbol-rate line strength needed over its local floor (noise peaks at about 3-4); None takes any line
min_samples: fewer samples are not searched (the rate search goes down to Fs/16: at least 64 symbols)
drop_db / drift: when update calls the lock stale (an Es/N0 drop [dB], a relative rate change)
esn0 / min_evidence: as detect (a known Es/N0; how sure the modulation must be: NoLock when it isn't, or
when the samples hold no symbol-rate correlation)
at: the stream position of x[0], when known: follow then checks the next block is the one right after
Raises NoLock (reason, line) when x is too short or has no clear symbol rate
Source code in src/rpps/sync/acquire.py
update ¶
The same signal in a new block x (anywhere in the stream: consecutive or not): timing and rate followed from
this lock's (track_timing, rounds times), cfo and phase measured afresh, no search. Returns a new Lock;
raises NoLock when x holds too few symbols
recheck: score the other modulations the search tried on these symbols (the same matched filter output), and
call the lock stale when one fits better by RECHECK_MARGIN: at low SNR a change of modulation can cost less Es/N0
than drop_db. at: the stream position of x[0], when known (for follow)
Source code in src/rpps/sync/acquire.py
follow ¶
The block right after this lock's (contiguous: its first sample follows the last of x), its symbols joining
on to these with no symbol dropped or repeated: the first is the one after the last here, the timing, rate,
carrier offset and phase carried on (the phase on the branch of its M-fold symmetry that continues this one's, so
the decisions keep their rotation). Concatenating the symbols of a chain of follows gives the sequence one
update over the joined record would (each block's estimates its own). Returns a new Lock, whose x starts with
the end of this one's that the matched filter needs
the stream position of x[0]. When both this lock's end and at are known and differ, the blocks are not
contiguous: NoLock (start again with update). Stale (stale) also when the timing moved more than
MAX_STEP of a symbol between the blocks: a slip is likely, so the joined symbols can't be trusted
Raises NoLock when x holds too few symbols
Source code in src/rpps/sync/acquire.py
refine ¶
The search again on more of the signal (x: a longer stretch), its modulation and roll-off kept: the rate is
searched afresh (or baud, when known), so an estimate made on few samples is corrected however far off it was,
which update, following, can't. The result is the lock's new reference (found). Raises NoLock as find
Source code in src/rpps/sync/acquire.py
decisions ¶
errors ¶
Each symbol's error against its decision: rpps.sync.quality.Errors (vector; evm_pct and mag_pct as a percentage of the constellation's rms; phase_deg)
summary ¶
An analyser's error summary of the symbols: rpps.sync.quality.Summary (EVM rms and peak, MER, magnitude and phase error, IQ offset, gain imbalance, quadrature error)
derotated ¶
x with the carrier offset and phase taken out and scaled as the symbols are (their matched filter at centres
gives about symbols; exactly for no carrier offset, the offset turning inside the filter otherwise)
Source code in src/rpps/sync/acquire.py
matched ¶
The matched filter's output between the symbols, up points a symbol: (t, z). t: time in symbols from the
first symbol instant (centres[0]); z: the output corrected as the symbols are, z[::up] being symbols. From the
first symbol to the last; the eye diagram of the block is z against t modulo a symbol or two.
The filter runs once over the block, at its sample rate, and its output (band-limited) is read between the samples by a 12-tap windowed sinc (rpps.math.interp.fractional): about 1e-3 rms of the symbols' scale from the filter's own rows (a few 1e-3 at most, at 2 samples a symbol), the instants exact. exact: the filter itself at every point (its matrix, one row a point: slow for a dense eye)
Source code in src/rpps/sync/acquire.py
reference ¶
The ideal waveform of the block: the decided symbols through the root raised cosine pulse at centres, on x's
samples, scaled and turned as derotated() (compare the two). Zero where no symbol of the lock reaches (the
ends of x hold symbols the lock has not)
Source code in src/rpps/sync/acquire.py
Acquire ¶
Acquire(lock=5.0, max_wait=2 ** 17, history=2 ** 16, names=None, betas=None, min_samples=1024, baud=None)
Bases: Stage
Detect as soon as the signal is there, then keep refining as the stream grows
The matrix matched filter and the likelihood only need a few hundred symbols, so there is no
fixed wait: blocks are held only until the symbol-rate line is significant (lock times the
local floor, noise peaks at about 3-4). Then everything held is released at once, and the
estimates are re-run on the growing history so baud and cfo tighten, up to history samples.
Every decision is made on the stream's first P samples at fixed P (min_samples, then doubling), never on whatever has arrived, so how the stream is cut into blocks changes nothing: a block that passes one or more of those positions has them run in order. The modulation and roll-off are searched again in full at each position until two in a row agree (a first decision on a few thousand samples at low SNR can be wrong, and refining would keep it); after that, refinements retest only them, which is much cheaper. A block carries the detection made by its end (meta.det). At the stream's end (flush) what has not settled is decided on the whole stream.
Calibrates meta.sps (to the detected one), so following stages get the fractional sps.
lock: symbol-rate line strength required to detect max_wait: samples after which to detect regardless min_samples: samples held before the first try, whatever the line: the rate search goes down to Fs/16, so this is at least 64 symbols (a narrow signal decimated far, a carrier, gives a few samples a block, and a line in a few hundred samples is no rate) baud: the symbol rate when known (a channel plan, rpps.analysis.spectrum.cyclic): no waiting for a line, no rate search
Source code in src/rpps/sync/acquire.py
symmetry ¶
Order M of the rotational symmetry of a point set (the M-th power removes the modulation)
Source code in src/rpps/sync/acquire.py
candidates ¶
Load candidate constellations from config/constellation: {name: unit-rms points}. Each is read once per config search path (a Lock rechecks them every block: finding the files would cost more than scoring them)
Source code in src/rpps/sync/acquire.py
turned_candidates ¶
Turned candidates.
{(name, map): unit-rms points} of each constellation names gives, as defined (map None) and as each of its maps
that turns the points uses them (map: that map's name, "DVB-S2"): what symbols whose carrier phase a known word set
are scored against (rp.sync.FrameSync's classify), where a turned set is another constellation
Source code in src/rpps/sync/acquire.py
correct ¶
Feed-forward frequency + phase correction for a candidate. Returns (symbols, cfo cycles/symbol, phase); a carrier
drifting over y (a Doppler rate: the frequency moving along) is taken off too (drift)
Source code in src/rpps/sync/acquire.py
drift ¶
The phase curvature c (radians a symbol^2) a drifting carrier leaves on symbols y.
phase(t) = c (t - centre)^2 after a frequency is taken off: the frequency moves 2c radians a symbol^2 (a Doppler
rate, a drifting oscillator).
Coarse, from the M-th power's frequency in each of segments segments (an FFT peak each, unambiguous within
+-1/(2M) cycles a symbol, whatever the phase does between them): the line through them; then fine, from the M-th
power's phase in blocks blocks (at least min_block symbols each), unwrapped by 2 pi / M, a quadratic
least-squares fit, on the symbols the coarse drift was taken off. Each counts only when sigmas standard errors off
0 (a steady carrier's segments and blocks only scatter); 0.0 with neither. offset: (c, w), w the frequency (radians a
symbol) still on y about its centre, which an FFT over a drifting carrier places off (its peak smeared)
Source code in src/rpps/sync/acquire.py
score ¶
Mean log-likelihood per symbol of unit-rms y under equiprobable points with Gaussian noise: the variance fitted (EM), or, given esn0 (dB), the points scaled to the signal's share of the power and the noise the rest
Source code in src/rpps/sync/acquire.py
score_all ¶
Scores of {name: (corrected unit-rms symbols, points)} and how they were made: at the caller's esn0 ("given"); each fitting its own variance when the fit's winner reads over FIT_MIN dB ("fit"); else each at its own M2M4 Es/N0 ("moments")
Source code in src/rpps/sync/acquire.py
null_score ¶
track_timing ¶
Refine sps from the drift of the best timing between the start and end of x. Returns (sps, tau)
A rate a little off makes the timing walk across x: the walk between its first and last eighth (at least 60 symbols each)
corrects sps, rounds times. The walk is seen modulo a symbol, so sps must be right to within about sps/(2 len(x))
relative (40 ppm for 60000 samples at 4 sps): a lock follows a clock, a search gets close first. tau is on the absolute
lattice tau + k*sps from x[0]. x too short for two such parts keeps sps.
Source code in src/rpps/sync/acquire.py
detect ¶
Find symbol rate, timing, modulation, frequency offset and phase from baseband samples
x: complex baseband at Fs, with the signal of interest centred and filtered
names: candidate modulations, default candidates()'s (the PSK, QAM and APSK definitions)
betas: RRC roll-offs to try; None: BETAS and the standard roll-off nearest the spectrum's (rate.find_rolloff: the
likelihood can't tell 0.05 from 0.15, the edges can), which rolloff records
baud: the symbol rate when already known (a channel plan, rpps.analysis.spectrum.cyclic): timing refines it, no search
esn0: the Es/N0 when known (rpps.sync.quality.from_sequence on a known sequence): every candidate is scored at it
min_evidence: nats the winner must lead the runner-up by in all (Detection.evidence), with it NULL_MARGIN over
Gaussian noise (Detection.over_noise), or mod is None and best holds the leader (see the module)
Returns a Detection; its tau is relative to x[0].
Source code in src/rpps/sync/acquire.py
onset ¶
Where a signal comes on in x. The first block whose power reaches level of the median block's (0 when the
first does, or when x is short). A stretch of nothing or of noise well under the signal at x's start is left out of
an estimate made on x (a burst, a carrier switched on after the recording started); at low SNR the noise before the
signal is not that far under it, and x is taken whole. A signal on for under half of x is not found this way (the
median is the noise's): a later, longer x finds it
Source code in src/rpps/sync/acquire.py
acquire_fec ¶
AcquireFEC: which code timed symbols carry, found as the stream arrives (the scans are in rpps.analysis.identify)
Classes:
| Name | Description |
|---|---|
AcquireFEC |
Identify the code the symbols carry, then turn them to the map its decoder uses |
AcquireFEC ¶
AcquireFEC(window=2 ** 14, skip=2048, max_wait=2 ** 18, names=None, blind=False, check=4096, relock=4.0, name='fec', min_line=5.0)
Bases: Stage
Identify the code the symbols carry, then turn them to the map its decoder uses
rx = front + rp.sync.Acquire() + rp.sync.time.Mat() + rp.sync.phase.FFCarrier() + rp.sync.AcquireFEC()
out = blk + rx
fec = out.stream.est.get("fec") # an rpps.analysis.identify.CodeDetection, once there is one
dec = fec.rx() # once fec.complete: the decoder (a profile runner), bits = dec(out)
Takes timed, carrier-corrected symbols (after phase.FFCarrier, with the modulation from Acquire in meta.det)
and gives the same symbols, turned and conjugated so the decoder's map is the right one (the carrier phase has an
M-fold ambiguity, and the IQ sense is unknown). Codes are the configured ones (rpps.analysis.identify.identify).
Acquisition: symbols are held until skip + window have arrived, and the code is identified on those window
(at absolute positions, so the result is the same however the stream was cut). While more symbols could tell more
(a window shorter than the scans use, or Reed-Solomon behind a Viterbi, which needs ~100 codewords) the window doubles,
up to max_wait symbols. A stream that ends first (meta.flush) is decided on every symbol held past skip, blind
tools included, so a short capture gets the same look a long one does. Acquire can decide again before it settles
(another modulation, or a rate more than REDECIDED off): what was held, taken at the old one, is dropped and the
acquisition starts over from that block, skip again. Then what was held is released from the window on (from a codeword start for a block code;
the skip symbols before it, where the sync before this was settling, are dropped).
Tracking (convolutional codes): every check symbols the output is re-encoded through the code on the decoder's map.
A mismatch above relock times the one at acquisition means a slip: the carrier by a turn, or the symbol timing by a
symbol (the code's puncture phase moves). Every turn and alignment is tried on that window; it goes on with the one the
code fits, turned, and with symbols dropped so the decoder after it keeps its alignment. slips counts them.
Its estimate is stream.est[name]: the CodeDetection (found False when nothing was, with its report). While it is still
acquiring it holds the answer so far with complete False (before any, found False and n the symbols held so far): a
code found then may still gain the layers inside it, so a decoder is best built once complete, which it is once the stage
stops looking.
names: only these convolutional definitions. blind: also look for unknown codes (a Guess, never decoded), unless the
rate came from a symbol-rate line weaker than min_line over its floor (Acquire took it anyway: a guess; None: always)
Source code in src/rpps/sync/acquire_fec.py
agc ¶
Automatic gain control, with no loop over samples
AGC: the level by block estimation (rpps.sync's first class): each window's level (the mean of log|x|, or of |x|),
the gain that brings it to target at the window's centre, a line between centres evaluated per sample. PeakAGC: the gain from a peak that is followed at once and decays, in closed form.
Classes:
| Name | Description |
|---|---|
PeakAGC |
Gain from the peak: |x| is followed instantly upward and decays by |
AGC |
Gain that brings the signal's level to |
PeakAGC ¶
Bases: Stage
Gain from the peak: |x| is followed instantly upward and decays by decay per sample, and the signal is scaled so
that peak sits at target. For bursts and on-off keying (Mode S pulses, OOK): the first pulse of a burst sets the level,
where an average is still settling. decay 0.999 at 2 MS/s holds a peak for about a millisecond.
The peak p[n] = max(|x[n]|, decay p[n-1]) is d^n max_(k<=n)(|x[k]| d^-k): in logs a running maximum
(np.maximum.accumulate), no loop over the samples, the same peak to rounding.
Source code in src/rpps/sync/agc.py
AGC ¶
AGC(target=1.0, *, window=0.0001, min_samples=64, log=True, min_gain=0.0, max_gain=np.inf, init=1.0, name='agc')
Bases: Stage
Gain that brings the signal's level to target, by block estimation
block + rp.sync.AGC(1.0)
First class (rpps.sync). Windows sit at absolute stream positions, window seconds (at least min_samples). Each
window's level is exp(mean log|x|) (log, the default: a level that does not depend on the signal's shape) or
mean |x|, and its gain log(target / level) is put at the window's centre; between centres the log gain is a straight
line, evaluated per sample: no steps at window edges and no loop over the samples. A level step settles within a
window, with no overshoot after it (a gain is not a drift: nothing carries a rate on). A window of zeros (a gap)
keeps the gain before it. The gain is held to [min_gain, max_gain]. Until a window with signal has been seen, samples
pass at init. Latency: a window and a half (a sample waits for the centre of the window after it). Estimates in
stream.est[name]: gain, level, latency (seconds).
Source code in src/rpps/sync/agc.py
align ¶
Classes:
| Name | Description |
|---|---|
Align |
Align a bit stream on a marker that repeats every |
Align ¶
Align(period, markers=None, pattern=None, unit=8, acquire=None, threshold=0.9, misses=3, polarity=True, name='align', start='any', publish=False)
Bases: BitStage
Align a bit stream on a marker that repeats every period units, and resolve its polarity
aligned = coded_bits + rp.sync.Align(period=204, pattern=[0xB8] + [0x47]*7) # DVB-S after Viterbi
aligned = bits + rp.sync.Align(period=64, markers=(0x7E,)) # any of a set, every period
Takes channel or data bits, as LLRs or hard bits, and gives the same form back, starting on a marker and with the polarity put right (LLRs negated, bits inverted). This is sync on bits: block estimation, then tracking at the block rate.
What starts each period is either markers: a set of unit values, any of which may start any period, or pattern: what starts each period in turn, repeating: a value, or a set of values, per period. DVB-S sends 0x47 and, every eighth packet, 0xB8. As a set those two cannot tell the polarity (inverted, one is the other); as a pattern they can, and the pattern's phase is found too.
Acquisition: once enough periods are in, every bit offset, pattern phase and polarity is scored by the fraction of
periods that start as expected, and the best one locks if it reaches threshold. Otherwise the oldest period is
dropped and it tries again as more arrives. What comes before lock is dropped (counted).
Tracking: each whole period goes out as it completes, and its start is checked. After misses periods in a row that
don't start as expected, the lock is given up and acquisition starts again from there.
period: units per period. unit: bits per unit (8: bytes, most significant bit first). acquire: periods to score, at
least one whole pattern. start: "any" period, or "pattern": the output starts on the pattern's first position (a frame
of periods: DVB-S energy dispersal restarts every 8 packets). publish: each period out is a frame start, {"frame": k}
published from it (rpps.base.control), so a header after it reads one period at a time (DVB-S's transport packets).
Its estimates are in stream.est[name].
Attributes:
| Name | Type | Description |
|---|---|---|
span |
Bits in one period |
Source code in src/rpps/sync/align.py
burst ¶
Per-burst acquisition: cut a stream of samples into the bursts that rise out of its noise floor
for b in src(65536) + rp.sync.Burst(win=8, min_s=60e-6, max_s=3e-3) + rx: # rx runs on each burst on its own
print(b.meta.pos, len(b))
data + Burst() gives a list: the bursts that ended in this block, each a Data of its own stream (the stages after it
start over on every burst: loops, timing and frame sync acquire each packet fresh), placed at its absolute position in
the source (meta.pos, and meta.time_of when the source has a time). Blocks and Pipeline run what follows on every
burst. A burst still open at the end of a block waits for the blocks that end it; the stream's end closes it.
The detector: the mean power of windows of win samples, at absolute positions (independent of the block cut), against
factor times the noise floor. The floor is taken from the noise windows alone, of those seen so far (the last history):
their mean m is the fixed point of m = mean(windows below quietm), climbed to from the quietest window, so it stops at the
lowest cluster of window powers (the noise) however many windows the bursts fill; the floor is the percentile of the
windows below quietm. Bursts may follow one another as closely as the air allows: the floor needs some quiet windows,
not most of them (a signal with no gap of a window at all is one burst). Windows of exact zeros (padding, a clean synthetic
signal's gaps) join the noise windows as the quietest of them: a few do not move the floor, but once they are percentile%
of the noise windows the floor is 0, and any power is a burst (a clean signal's bursts are all found; a noisy capture padded
with that many zeros is one burst). For one flushed block of a whole capture this is a batch rule: every window of the capture sets the floor.
A stream's first settle windows are decided together, once they are all in (or the stream ends): a floor taken from the
first few windows alone would be a burst's own level.
The rest of the burst code: rpps.sync.plan (bursts on many carriers, placed in a time plan), rpps.profile.burst (a profile's burst step), rpps.analysis.burst (bursts demodulated blind; plans learned and checked: its docstring maps it all).
Classes:
| Name | Description |
|---|---|
Burst |
Bursts of a stream of samples, each a block of its own stream (see the module) |
BurstTx |
The transmit side of Burst: bursts placed on one stream of samples, each where its start puts it |
Burst ¶
Burst(factor=6.0, win=100, min_s=0.0, max_s=None, percentile=20, history=1 << 17, settle=512, quiet=3.0)
Bases: Pipe
Bursts of a stream of samples, each a block of its own stream (see the module)
factor: how far above the noise floor a window's power is to be part of a burst
win: samples per window (the time resolution of the burst edges)
min_s, max_s: shortest and longest burst kept [s] (max_s None: any length); a longer one is dropped, and its samples
are not held past max_s
percentile: of the noise windows' powers, the noise floor; quiet: how far above their mean a window may be and still
count as noise; history: windows the floor is taken over (taken again once a 16th of them are new: one block is the
batch rule exactly, a long stream does not sort its history every block); settle: windows at the stream's start held
until the floor has them all
Estimates go in the stream's est["burst"]: the floor, bursts emitted, too short, too long.
Methods:
| Name | Description |
|---|---|
split |
The bursts that end in this block (a list of Data) |
floor |
The noise floor of window powers |
Source code in src/rpps/sync/burst.py
split ¶
The bursts that end in this block (a list of Data)
Source code in src/rpps/sync/burst.py
floor ¶
The noise floor of window powers e (see the module)
Source code in src/rpps/sync/burst.py
BurstTx ¶
Bases: Pipe
The transmit side of Burst: bursts placed on one stream of samples, each where its start puts it
btx = rp.sync.BurstTx(gap_s=1e-3)
btx.add(burst) # a Data of samples, one whole burst (its own stream, flushed)
btx.add(burst, at=0.004, freq=-3e6) # at 4 ms from the stream's start, 3 MHz below its centre
out = btx.take() # the samples no later burst can reach any more; take(flush=True): the rest
One BurstTx makes one output stream (it holds it: a profile's transmit runner builds its own). Bursts come in the
order of their starts. A burst's start is at [s from the stream's first sample], else the end of the burst before
plus gap_s (the first: gap_s from 0). The stream ends gap_s after the last burst's end, as it began.
Per burst: its first and last ramp_s raised by a raised cosine (the power ramps of a burst transmitter; 0: switched),
resampled to the stream's rate Fs (None: the first burst's rate) by a rational polyphase filter, and moved freq Hz
from the stream's centre (None: the next of hop, cycled, or 0) by an oscillator running from the stream's first
sample (every burst on one carrier has the phase of one continuous carrier). Bursts may overlap: they add (carriers
of an MF-TDMA network share a slot; a burst may also start inside the one before).
sent: (start sample, samples, freq) of every burst added. take(flush=True) ends the stream: the next add starts
a new one (as reset()), its at from that stream's start, and sent its record.
Methods:
| Name | Description |
|---|---|
reset |
Start a new stream |
add |
Place one whole burst (a Data of samples). Its samples come out of |
take |
The samples up to the last burst's start (no burst added later reaches before it), as a block of the output |
Source code in src/rpps/sync/burst.py
reset ¶
Start a new stream
Source code in src/rpps/sync/burst.py
add ¶
Place one whole burst (a Data of samples). Its samples come out of take
Source code in src/rpps/sync/burst.py
take ¶
The samples up to the last burst's start (no burst added later reaches before it), as a block of the output stream; flush: all of them and the gap after the last burst, ending the stream
Source code in src/rpps/sync/burst.py
code_acquire ¶
Functions:
| Name | Description |
|---|---|
acquire_code |
Find where a spreading code starts in a signal, and its frequency offset: the parallel code-phase search |
noise_threshold |
The ratio to the mean that the largest of |
acquire_code ¶
acquire_code(x, code: Code, sps=1, index=0, Fs=None, doppler=(0.0,), periods=None, threshold=None, pfa=0.001)
Find where a spreading code starts in a signal, and its frequency offset: the parallel code-phase search
For each trial frequency the signal is mixed down, every code period is correlated with the sequence at all delays at once (FFT), and the powers of the periods are added. Power is added, not amplitude, so data modulated on the code (a bit flip, a differential phase change) does not cancel it. A peak that stands out of the rest is the signal.
x: complex samples at sps samples per chip. index: which sequence of a set. Fs: sample rate, needed for doppler.
doppler: trial frequency offsets [Hz]; each can only be found to within about 1/(period) Hz, so space them by half that
periods: how many whole code periods to use (default all there are)
threshold: the peak's ratio to the mean power of the other delays that counts as locked. Default: what noise alone
exceeds, in the best of all the (frequency, delay) cells and periods tried, with probability pfa (the
sum of P periods' noise power is gamma distributed; its tail is taken from the Wilson-Hilferty approximation)
Returns offset (samples into x where a code period starts: give it to Despread), doppler [Hz], metric (peak / mean
of the other delays at the best frequency), threshold, locked, and power (frequencies, delays) for plotting
Source code in src/rpps/sync/code_acquire.py
noise_threshold ¶
The ratio to the mean that the largest of cells noise-only powers, each summed over periods, exceeds with probability pfa
Source code in src/rpps/sync/code_acquire.py
equalize ¶
Equalizers: symbols + rp.sync.equalize.BlockLS(qpsk) solves the taps per window
The taps carry across blocks, so any block length gives the same stream. The per-symbol adaptive equalizers (second
class) are rp.sync.loops.LMS and rp.sync.loops.CMA.
Classes:
| Name | Description |
|---|---|
BlockLS |
Equalize symbols by least squares over each window, decision directed, with the taps carried from window to window |
Functions:
| Name | Description |
|---|---|
symmetry |
(M, E[a^M]) for the smallest M whose moment E[a^M] is not zero: the constellation's rotational symmetry (2 BPSK, |
BlockLS ¶
BlockLS(constellation, taps=7, window=0.001, min_symbols=1024, iters=3, blend=0.5, gate=0.5, name='equalizer', blind=False, blind_iters=8)
Bases: Stage
Equalize symbols by least squares over each window, decision directed, with the taps carried from window to window
symbols = timed + carrier + rp.sync.equalize.BlockLS(rp.symbol.load("QPSK"), taps=7)
First class (rpps.sync): block estimation, where loops.LMS and loops.CMA adapt per symbol. Windows sit at
absolute stream positions, window seconds (at least min_symbols). On each, the taps w (symbol spaced, centred:
output n uses inputs n - taps//2 .. n + taps//2) solve min |X w - d|^2, d the constellation points nearest to X w,
iters times; the window's solution is blended with the last (blend of the old: the tracking across windows), and
that is the filter for the window. It starts as a pass-through and normalizes the power to the constellation's.
A window that is noise only would pull the taps anywhere: gate is the least fraction of decisions within half the
minimum distance for a window to update the taps. Latency: a window and taps//2 symbols (est: latency).
blind=True: a window whose decisions fail the gate (an eye the channel has closed, before any decision is right) is
solved without decisions, by block least squares constant modulus (LS-CMA, Agee): blind_iters times, the targets
are the outputs y pushed onto the constellation's modulus (R y/|y|, R^2 = E|a|^4/E|a|^2), and w solves
min |X w - R y/|y||^2 with the same normal equations. The modulus does not see the phase: the taps are turned by the
constellation's M-th power phase (M its rotational symmetry: 2 BPSK, 4 QPSK/QAM, 8 8PSK) and, of the M rotations left,
the one nearest the taps before, so windows blend alike. The window is then refined decision directed (when its
decisions pass the gate within dmin/4, not dmin/2: a dense constellation's own spread lands within dmin/2 of a point
pi/4 of the time, eye open or not); the M-fold ambiguity is left to what follows (a frame word, differential coding).
est: mode, "decided" or "blind" (the last window's).
Source code in src/rpps/sync/equalize.py
symmetry ¶
(M, E[a^M]) for the smallest M whose moment E[a^M] is not zero: the constellation's rotational symmetry (2 BPSK,
4 QPSK and square QAM, 8 8PSK); (0, 0) when none up to most (a constellation with no phase to read)
Source code in src/rpps/sync/equalize.py
frame ¶
Frame sync: where frames start (rpps.sync)
FrameSync symbols: correlate a known preamble (DVB-S2 SOF), give each frame from its preamble to the next one,
with the carrier phase the preambles measured taken off
Delimiter bits: find the word that comes before each frame (802.11b SFD, a CCSDS ASM), give the bits after it (or
the frame from its word on), for a fixed or a controlled length, with the polarity put right
Both publish {"frame": k} at each frame start (rp.base.control.publish), so a profile can drive the steps after them frame by frame (a header that reads the frame's start), and say where each frame came from (rp.base.control.anchor).
Classes:
| Name | Description |
|---|---|
FrameSync |
Find frames by a known preamble among timed symbols, and give them whole and the right way round |
Delimiter |
Find frames in a bit stream by the word that comes before each one (a start-of-frame delimiter), give the bits |
Functions:
| Name | Description |
|---|---|
word_errors |
The most bit errors a match of an |
FrameSync ¶
FrameSync(preamble, words=None, threshold=None, max_length=None, name='frame', pending=False, device=False, before=0, length=None, segments=1, scale=False, classify=None, margin=0.1, min_symbols=64, polarity=True, cfo=False, count=None, memory=32)
Bases: Stage
Find frames by a known preamble among timed symbols, and give them whole and the right way round
frames = symbols + rp.sync.FrameSync(preamble) # preamble: the known symbols, complex
frames = symbols + rp.sync.FrameSync(sof, words) # then one of a set of known continuations (DVB-S2 PLS)
frames = levels + rp.sync.FrameSync({"bs_voice": a, "bs_data": b}, before=54, length=132, scale=True) # DMR
Block estimation: the normalised correlation with the preamble, |c| / sqrt(E_window E_preamble) (1 for a perfect
match), peaks above threshold and the largest within a preamble's length. With words (M, n): the n symbols after
the preamble are one of M known words (a short header code), and the metric takes the best of them, in phase with the
preamble, over the whole L + n symbols: random data then hardly ever passes, where a short preamble alone would every
few frames (DVB-S2: 26 SOF symbols, then 64 PLS symbols from 128 words: random 8PSK data stays under 0.41, a header at
-2 dB Es/N0 is over 0.5 99 times in 100; threshold 0.5 by default with words, 0.6 without). Each frame goes out when the next
preamble is found (or the stream is flushed), from its preamble to the next, turned back by the carrier phase: a line
from the phase its preamble measured to the next one's (block-rate tracking of a slowly turning carrier; a residual
frequency is for the pilots to take off). A frame longer than max_length symbols is cut there.
A unique word known as bits (a long one after demodulation, before the FEC) is found here rather than among bits when
the carrier leaves an M-fold ambiguity: its phase is measured, so a frame turned by 90 degrees is put right too (a
bit search only corrects an inversion). pending: the preamble comes later (set_template), as a profile makes it
from such a word. Over L symbols random data correlates about 1/sqrt(L) (0.05 for a 400-symbol word), so a long word
may use a threshold well under the default.
the symbols, or alternatives of one length: {name: symbols} or {name: (symbols, {field: value})} (sync
words that say what follows: DMR's voice / data, base / mobile; Zadoff-Chu roots and shifts). Each is
correlated; the best names the frame, published as word with its fields, for controls to drive steps by.
before, length: the frame starts before symbols ahead of its preamble (a sync word mid-burst) and is length
symbols long (a controlled parameter too: a header says it); without a length a frame runs to the next one.
segments: the preamble correlated in that many parts, added without their phases: a carrier offset turns a long
word (a Zadoff-Chu sequence moves its peak with it) and a coherent sum over the whole word loses it (a burst's
own offset, 3 kHz at 512 kBd, turns a 64-symbol word by 145 degrees). "auto": one part a 16 symbols, at most 4
(1 with header words): what a profile's frame step on a word takes unless it says.
count: frames to find in a stream, then no more searching (None: all; a burst's runner: 1, as data later in the burst
can pass for the word).
cfo: take the carrier frequency its preamble measured off each frame too (within +-1/L cycles a symbol: a larger
offset is for a carrier step before), not only its phase. "track": the frequency tracked over the frames instead,
data-aided (Luise and Reggiannini over each frame's known symbols, the preamble and the word it matched, summed
over the last memory frames or so, weighted down by age, started again when a frame's own estimate is over
4 of its standard deviations off: an offset taken off upstream mid-stream; unambiguous within +-2/(L + n)
cycles a symbol), and refined by the phase from one preamble to the next (the turns between them from the
tracked frequency once it is 3 standard deviations off 0, else none, as without it; what that leaves of the
tracked frequency is published as cfo_left, for pilots closer together to take off: rpps.sync.PilotPhase): below an M-th power's SNR gate the offset is not taken
off before, and a frame's own known symbols measure it too poorly to resolve pilots far apart (DVB-S2 at
6 dB Es/N0: 90 known symbols a frame, pilot blocks 1476 apart). Published as cfo (cycles a symbol).
scale: divide each frame by the gain its preamble measured, so levels come out as the preamble's (4FSK +-1, +-3).
Real levels (a discriminator's output) stay real: the phase is a polarity, a frame upside down is turned over.
polarity: an inverted (turned) match counts (an unknown carrier phase, a discriminator of unknown sense); False:
only matches in phase, where the sense is known and alternatives are each other inverted (DMR voice / data).
classify: constellation names; each frame's symbols after its preamble are scored against them (rpps.sync.acquire)
at the Es/N0 the preamble measured, and the best published as modulation (when it leads by margin nats a
symbol over at least min_symbols; otherwise the last one stays, reported), with mapping: the name of the map
whose turned points fit (the preamble set the phase: DVB-S2 8PSK is told from 8PSK), None for the points as defined.
Each frame start publishes {"frame": k, "metric", "phase", "scale", "esn0" (dB: the frame's power less the noise the residual after its preamble measured, over that noise), "cfo" (cycles a symbol, from the phase between the preamble's halves; complex input), "word" and its fields (alternatives), "modulation" and "mapping" (classify)}. Estimates in stream.est[name]: the same of the last frame.
Methods:
| Name | Description |
|---|---|
set_template |
The known symbols that start each frame, or {name: symbols or (symbols, fields)} of one length (a profile makes |
Source code in src/rpps/sync/frame.py
set_template ¶
The known symbols that start each frame, or {name: symbols or (symbols, fields)} of one length (a profile makes them from words, through its own transmit side down to the symbol mapping: rpps.profile.Profile._template; first and span are unused, the symbols being one a sample)
Source code in src/rpps/sync/frame.py
Delimiter ¶
Delimiter(word, bits=None, order='msb', errors=0, name='delimiter', length=None, keep=False, polarity=False)
Bases: BitStage
Find frames in a bit stream by the word that comes before each one (a start-of-frame delimiter), give the bits after it
frames = bits + rp.sync.Delimiter(word=0xF3A0, bits=16, order="lsb") # 802.11b SFD, sent LSB first
frames = bits + rp.sync.Delimiter(0x1ACFFC1D, 32, length=8160, keep=True) # CCSDS: the ASM and its frame, whole
word: the delimiter's value, bits long, sent most (order "msb") or least significant bit first; or the bits
themselves (an array, in the order sent), or a sequence definition of type word (rp.sequence.load). errors: bit
errors a match may have (word_errors gives the most a false-alarm rate allows; a word longer than 64 bits is matched
by FFT correlation). length: bits in a frame after the word; after them the frame is over and the search starts
again (also a controlled parameter: a header says how long its frame is); unknown, the bits pass until the next
delimiter. keep: give each frame from its word on (so a rp.code.Marker after it can strip and check the word) rather
than from the bit after it. polarity: match the inverted word too, and give such a frame inverted back (LLRs negated),
for links whose sense an unknown carrier phase can flip. Takes hard bits or LLRs, gives the same.
Estimates in stream.est[name]: frames found, polarity of the last.
Source code in src/rpps/sync/frame.py
word_errors ¶
The most bit errors a match of an n_bits word may have while random bits stay under false_alarm matches over
positions places searched (a frame's bits, when the search restarts every frame): the largest e with
positions * P(Binomial(n_bits, 1/2) <= e) (twice that with polarity, the inverted word matched too) under it.
-1 when even an exact match is too likely (a short word over many places). A 32-bit ASM searched over a CCSDS frame
(8160 places) allows 1 at 1e-3; an 800-bit word (100 bytes) 314 at 1e-9, so its own channel errors hardly ever matter
Source code in src/rpps/sync/frame.py
inversion ¶
Spectral inversion (a stream conjugated) found by known symbols turning backwards, and undone (rpps.sync)
A high-side LO or I and Q swapped anywhere on the way conjugates a stream.
symbols + rp.sync.Inversion(rp.symbol.load_header("dvbs2_pl").preamble) # {"sync": "inversion", "header": ...}
Conjugated, everything turns clockwise. That is not a bit map: random data on a constellation the same conjugated (every
PSK, QAM, APSK) looks the same either way, so only a known sequence that turns (steps not all 0 / 180 degrees) or a code
on a standard's map (CodeDetection.inverted) tells. sense(z, known): the symbol steps z[n] conj(z[n-1]) against
the sequence's, forwards and conjugated; differential, so before carrier sync.
Classes:
| Name | Description |
|---|---|
Inversion |
Spectral inversion of timed symbols by a known sequence that turns; conjugates them back |
Functions:
| Name | Description |
|---|---|
handed |
Whether a sequence turns (a step not 0 or 180 degrees): only then does it tell the senses apart |
sense |
Whether symbols z are inverted, by a known sequence in them: True, False, None (not found, or it doesn't turn) |
Inversion ¶
Bases: Stage
Spectral inversion of timed symbols by a known sequence that turns; conjugates them back
Windows of window symbols at absolute positions: each match over threshold (forwards or backwards) adds
Re(forward) - Re(backward) to a score held within +-2 evidence (about +-2 a pi/2-BPSK word). The sense is decided
at +-evidence and changes only at the other: a stray match never flips it. Windows wait up to hold symbols for the
first decision, then go out as received. Each goes out in the sense known when it was searched (held ones in the
first decision's): the output is the input one for one, however cut. Publishes {"inverted"} where the sense is decided
or changes; est[name]: inverted, score, matches, windows, latency. Real levels pass (their polarity is a frame sync's).
Source code in src/rpps/sync/inversion.py
handed ¶
Whether a sequence turns (a step not 0 or 180 degrees): only then does it tell the senses apart
sense ¶
Whether symbols z are inverted, by a known sequence in them: True, False, None (not found, or it doesn't turn)
The top strongest matches over threshold vote: True when they turn backwards
Source code in src/rpps/sync/inversion.py
kernels ¶
Batch kernels of the sync operators: PilotLine of PilotPhase
Checked row for row against the operator run frame by frame (tests/unit/parallel/test_batch_kernels.py); they use only what
numpy and cupy share, so xp can be either (rpps.parallel)
Classes:
| Name | Description |
|---|---|
PilotLine |
The carrier phase of each frame from its pilot blocks, taken off: a least-squares line through the phase of every block (and |
PilotLine ¶
Bases: Kernel
The carrier phase of each frame from its pilot blocks, taken off: a least-squares line through the phase of every block (and
through lead, a position where it is known to be 0), per row. Symbols past the frame pass unchanged, a frame cut short
as it is. starts: where the blocks start in a frame, total: its length with the pilots; left: a frequency
(cycles a symbol) taken off from lead first (PilotPhase's)
Source code in src/rpps/sync/kernels.py
ofdm ¶
OFDM symbol timing and fractional carrier frequency from the cyclic prefix (van de Beek, Sandell & Borjesson 1997)
Classes:
| Name | Description |
|---|---|
CPSync |
OFDM symbols found by their cyclic prefix: samples in, the same samples out from the start of a symbol (its prefix), |
CPSync ¶
Bases: Stage
OFDM symbols found by their cyclic prefix: samples in, the same samples out from the start of a symbol (its prefix), whole symbols of n_fft + n_cp, with the fractional carrier frequency offset taken off. wave.OFDMRx follows it
carriers = samples + rp.sync.CPSync(64, 16) + rp.wave.OFDMRx(64, 16)
First class (rpps.sync): block estimation over windows at absolute stream positions, window seconds
(at least min_symbols OFDM symbols). In a window, the correlation of every sample with the one n_fft later, summed over
a prefix's length and folded over the window's symbols, peaks where the prefixes start: gamma(t) = sum r[k] r*[k + N]
over the prefix at t. The ML metric |gamma(t)| - rho * energy(t)/2 (rho = snr/(snr + 1)) takes the timing; the angle of
gamma there is the carrier frequency, -angle/(2 pi) of a subcarrier spacing (|offset| under half a spacing: an integer
offset is for the pilots or a preamble). Both are tracked across windows (rpps.sync.track): timing modulo a symbol, so a
clock some ppm off is followed, the output keeping whole symbols by dropping or repeating one prefix sample when the
tracked start moves by one; the frequency taken off is a phase line evaluated per sample. A window whose peak is weaker
than gate (|gamma| against the prefix's energy: 1 for a clean signal, about 1/sqrt(symbols) on noise) is skipped and the
loops coast: the gate is on the metric against what noise gives (|gamma| / energy times sqrt(symbols * prefix): about 1
on noise, and its peak over the L candidate starts about sqrt(2 ln L)), so it holds for any window length.
Estimates in stream.est[name]: timing (samples into a symbol), cfo (subcarrier spacings), metric, latency.
Source code in src/rpps/sync/ofdm.py
pilots ¶
Classes:
| Name | Description |
|---|---|
PilotEqualizer |
Equalize OFDM carriers from their pilots: n_fft carrier values per OFDM symbol in, the same with the channel removed |
PilotPhase |
Carrier phase over each frame from its pilot blocks: a line through the phases they measure, taken off the frame |
PilotEqualizer ¶
Bases: Stage
Equalize OFDM carriers from their pilots: n_fft carrier values per OFDM symbol in, the same with the channel removed
The channel seen on the pilots of each OFDM symbol is fitted with a short impulse response (least squares, taps
long), and every carrier is divided by that response's frequency response. A multipath channel shorter than the prefix
and a constant phase offset come off. Block estimation, one OFDM symbol at a time.
Which OFDM symbol a block starts on (the pilots' sign alternates) comes from its absolute stream position, so any block cut gives the same output.
carriers: the rp.symbol.Carriers layout. taps: channel length (default 3/4 of the pilots, at most max_taps)
Source code in src/rpps/sync/pilots.py
PilotPhase ¶
PilotPhase(slot=90, every=16, length=36, value=(1 + 1j) / np.sqrt(2), slots=None, pilots=True, lead=None, name='pilots', left=0.0)
Bases: Stage
Carrier phase over each frame from its pilot blocks: a line through the phases they measure, taken off the frame
payload = symbols + rp.sync.PilotPhase(slots=360) # DVB-S2: blocks of 36 pilots after every 16 slots of 90
Block estimation per frame, data-aided: the phase of each pilot block (the mean of the symbols times the conjugate pilot
value) at its centre, unwrapped in order, and a least-squares line through them (and through lead: a position before
the payload where the phase is known to be 0, the frame's preamble once a frame sync took its phase off). A frame is held
until it is whole. left: a frequency (cycles a symbol) known to be on the frame still, taken off from lead first
(a control: FrameSync's cfo_left, the part of a tracked frequency its preambles, far apart, could not place),
so the blocks' phases are unwrapped about it. Without pilots, or before a profile says how the frame is laid out
(slots, pilots), the symbols pass unchanged (left too: with nothing to check it by, it is not taken off). Frames start where a profile applies a change (rpps.profile.control), or at the start of the stream.
Estimates in stream.est[name]: the last frame's phase line (phase at the start, per symbol).
Methods:
| Name | Description |
|---|---|
kernel |
The batch carrier fit, for the frame layout |
Source code in src/rpps/sync/pilots.py
kernel ¶
The batch carrier fit, for the frame layout params set (without one, or without pilots, the symbols pass)
Source code in src/rpps/sync/pilots.py
plan ¶
Bursts on many carriers, placed in a burst time plan (rpps.plan): the return link of an MF-TDMA network
for b in src(1 << 16) + rp.sync.Bursts(carriers=[{"freq": -1e6, "width": 600e3}, {"freq": 0, "width": 600e3}]):
print(b.ctx["burst"]) # {"carrier": 0, "freq": -1e6, "start": 0.0123}
bursts = rp.sync.Bursts(plan=rp.plan.load("demo/mftdma")) # the plan's carriers; each burst labelled with its place
Detection comes first: each carrier is brought to baseband (rpps.signal.channelize) and cut into the bursts that rise out of its own noise floor (rpps.sync.Burst), at absolute positions, so a capture with no plan still gives its bursts, and a plan learned from them (rpps.analysis.burst) or told by a forward link (rpps.plan) places them:
plan: each burst is labelled with its window (superframe, frame, slot, tx type, assignment) and the fields of its tx type (what a profile's controls drive per burst). A burst no window explains is given unlabelled, and counted.- the plan's time in the capture,
origin(plan clock ticks at the capture's first sample): given (from a forward link's clock reference, rpps.plan), or acquired. Acquiring is block estimation: each detected burst votes for the origins that would put it on a slot of its carrier; the most voted, oncelockbursts agree on it (totol), is taken, and then tracked burst by burst (rpps.sync.track, its rate the clock offset between the network and the capture). The precise start of each burst comes back from the preamble its profile found (feedback, which a profile's burst runner calls): energy edges only seed it, as they smear at low SNR. gate: "energy" (default) or "plan": once the origin is locked, cut every window the plan gives (assigned ones, when the plan has assignments) whether its energy stands out or not,marginseconds either side.
Each burst is a Data of its own stream (the steps after it start over), at the carrier's rate, its first sample at its
position in the carrier's stream; ctx["burst"] holds its fields: carrier (index), freq (Hz from the capture's centre),
start (seconds from the capture's first sample), and with a plan its window's fields. sps (or a carrier's own) with
its rate brings each carrier to exactly that many samples a symbol (decimated by a whole factor, the rest resampled:
a capture at any rate), so one profile serves carriers of several rates. Estimates in est["bursts"]:
per carrier the floor and bursts, the origin, its rate, locked, labelled and unlabelled counts.
The rest of the burst code: rpps.sync.burst (one carrier's bursts by energy), rpps.profile.burst (a profile's burst step), rpps.analysis.burst (bursts demodulated blind; plans learned and checked: its docstring maps it all).
Classes:
| Name | Description |
|---|---|
Bursts |
|
PlanTx |
Bursts placed by a plan: each burst's fields name its window (sequence, superframe, frame, slot; or |
Bursts ¶
Bursts(carriers=None, plan=None, origin=None, gate='energy', tol=None, lock=8, margin=None, oversample=3.0, bw=0.25, sps=None, pad=None, **burst)
Bases: Pipe
Methods:
| Name | Description |
|---|---|
control |
A plan, or its time in the capture, from what a forward link says (rpps.plan): the origin seeds the tracker, |
split |
The bursts that end in this block, on every carrier, in order of their starts (a list of Data) |
feedback |
A burst's precise start [s from the capture's first sample], from its preamble: the tracked origin follows |
Source code in src/rpps/sync/plan.py
control ¶
A plan, or its time in the capture, from what a forward link says (rpps.plan): the origin seeds the tracker, which the bursts' preambles still refine (the forward link's clock does not know the path to this receiver)
Source code in src/rpps/sync/plan.py
split ¶
The bursts that end in this block, on every carrier, in order of their starts (a list of Data)
Source code in src/rpps/sync/plan.py
feedback ¶
A burst's precise start [s from the capture's first sample], from its preamble: the tracked origin follows it (a profile's burst runner calls this, with the burst's ctx, with what its frame sync found). The preambles of a superframe make one measurement (their median, at their median time): a block estimate the tracker takes once a superframe, as bursts on several carriers come at once
Source code in src/rpps/sync/plan.py
PlanTx ¶
Bases: BurstTx
Bursts placed by a plan: each burst's fields name its window (sequence, superframe, frame, slot; or window),
and it goes where the plan puts it: at its burst start, freq its carrier, from the plan's time origin (clock
ticks at the output's first sample) and the output's centre frequency cf
tx = rp.sync.PlanTx(plan, origin=0, cf=14e9, Fs=8e6)
tx.place(burst, {"superframe": 3, "frame": 0, "slot": 7})
Methods:
| Name | Description |
|---|---|
where |
(at [s], freq [Hz from the centre], window) of a burst whose fields name its window |
Source code in src/rpps/sync/plan.py
where ¶
(at [s], freq [Hz from the centre], window) of a burst whose fields name its window
Source code in src/rpps/sync/plan.py
preamble ¶
A preamble at the start of a burst: where it is, and the carrier offset its repetition gives
bursts = src(65536) + rp.sync.Burst(win=100, min_s=30e-6)
for b in bursts + rp.sync.Preamble(ltf_symbol, repeat=64, offset=-192, correct=True): # 802.11a/g: STF start, CFO off
...
Found once per stream: a stream is one burst after rp.sync.Burst. Until it is found the samples are held (up to search
samples of candidate starts, or the stream's end); then the output starts at the preamble (plus offset), placed at its
absolute position, and the rest of the stream passes. Not found: nothing comes out, and est[name]["found"] is False.
Classes:
| Name | Description |
|---|---|
Preamble |
Find a burst's preamble: a known waveform, or a repeated one (Schmidl & Cox) |
PreambleTx |
The transmit side of a Preamble ( |
Preamble ¶
Preamble(template=None, repeat=None, window=None, search=None, gate=0.5, offset=0, correct=False, name='preamble', first=0, pending=False, span=None)
Bases: Stage
Find a burst's preamble: a known waveform, or a repeated one (Schmidl & Cox)
the preamble's samples at the stream's rate (an 802.11 LTF symbol, an LTE PSS); its start is where the
normalized correlation |sum x t*| / sqrt(sum |x|^2 sum |t|^2) (1: the template exactly, scaled and turned) is
highest, if at least gate. A template that repeats in the preamble matches each copy: give all the copies
(802.11's two LTF symbols). A carrier offset turns the preamble over its length and lowers the metric: about
sinc(offset x length / Fs) (40 kHz over 128 samples at 20 MS/s: 0.89). None: the repetition alone finds it, Schmidl & Cox's C over window samples at lag
repeat: among the starts where |C|/P reaches gate, the first where |C| is at its plateau (97% of its peak;
|C|/P alone rises before the window is all in the preamble)
repeat: the preamble repeats after this many samples (802.11 STF 16, LTF 64): the carrier offset is the angle of the
repetition, -angle(sum x[n] x*[n + repeat]) Fs / (2 pi repeat), over window samples from the start found
(default: the template's length). correct: take that offset off the output
search: candidate starts examined (None: the whole stream, which then waits for its end). offset: the output starts
this many samples after the preamble's start (negative: before it; 802.11 STF before the LTF)
A real stream (an FSK discriminator's output) is matched by the correlation coefficient: the template and the stream's
window with their means taken off (a carrier offset there is a constant), positive only. The offset, the level b of
the fit x = a template + b over the match, is est["level"]; correct takes it off the output.
first: the template's sample at its first symbol's peak; span: its samples up to the tail its pulses leave (its symbols
times the samples a symbol; None: all of it); pending: the template comes later (set_template: a profile makes it
from its own transmit side). attach_tx(): the transmit side, which sends this template (PreambleTx).
Estimates in stream.est[name]: found, pos (absolute), metric, cfo [Hz] (with repeat), and where the symbols are:
first (the absolute sample of the first symbol's peak), delay and Fs (the group delay and rate there; known timing
with an anchor places its grid by them).
Methods:
| Name | Description |
|---|---|
set_template |
The waveform to find, its sample at the first symbol's peak, and its samples up to its pulses' tail |
attach_tx |
The transmit side: a PreambleTx that sends this preamble's template (the one set now or later) |
Source code in src/rpps/sync/preamble.py
set_template ¶
The waveform to find, its sample at the first symbol's peak, and its samples up to its pulses' tail
Source code in src/rpps/sync/preamble.py
attach_tx ¶
PreambleTx ¶
Bases: Stage
The transmit side of a Preamble (Preamble.attach_tx()): its template put before a stream
The stream starts with the template, the stream's own samples from its span on (the preamble's symbols), the tail its
pulses leave added to them: for linear steps (pulse shaping) exactly the waveform of the preamble's symbols and the
stream's sent as one. The template is the Preamble's when the stream starts (a profile sets it after building).
Source code in src/rpps/sync/preamble.py
puncture ¶
Classes:
| Name | Description |
|---|---|
Puncture |
Find where a punctured convolutional code's puncture pattern starts, and start the stream there |
Puncture ¶
Bases: BitStage
Find where a punctured convolutional code's puncture pattern starts, and start the stream there
aligned = llrs + rp.sync.Puncture(rp.code.load("conv/k7_171_133/3_4")) + ... # then Viterbi
Block estimation on channel bits: windows of window coded bits at fixed stream positions, each offset into the
puncture period tried on one by decoding it and coding the decision again; the right offset reproduces what was
received (only channel errors differ), a wrong one does not. rotations: the constellation's turns as bit transforms
(rp.symbol.mapping.bit_rotations: the carrier's M-fold phase left by an M-th power estimate) tried with every offset;
the one found is applied to everything after. The first window where the best hypothesis's mismatch is under
DECISIVE of the best one not equivalent to it (within EQUIVALENT: a code that decodes inverted bits too) decides (the stream's start is where the timing and carrier before were settling:
there every offset decodes badly, and the pick was chance); after max_windows the best summed over them. The bits
before the offset are dropped, once; after that the stream passes through. Its estimate is in stream.est[name]
(offset, the mismatch rate at each offset in the window that decided, windows).
Source code in src/rpps/sync/puncture.py
quality ¶
Signal quality of recovered symbols: Es/N0, Eb/N0, EVM, measured once (measure), over a running window (Track)
or on the stream (Monitor, a stage that publishes it); each symbol's error (errors) and an analyser's error summary
(summary: EVM, MER, magnitude and phase error, IQ offset, gain imbalance, quadrature error)
The symbols must be locked (timing, frequency, phase and gain corrected) so they sit on the constellation points. The noise is found the way detection finds it: the variance of Gaussian clusters around equiprobable points, by EM (rp.math.prob.mixture_variance), which stays right when the clusters touch and the nearest point is sometimes wrong.
Before anything is locked, three estimates need no constellation and no noise floor measured apart (each an SNR),
and a fourth needs only a constellation to assume (m2m4(y, points): the symbols' second and fourth moments under that
constellation's kurtosis, no decisions; rpps.sync.detect scores each candidate at its own):
from_sequence(y, ref): from a known sequence in the signal. With a CAZAC one (rp.sequence.zadoff_chu: LTE/NR PSS, PRACH, SRS), the circular correlation of one received period with it has one peak (the channel, multipath taps included withinguard) and noise alone at every other lag: signal and noise from the same correlation, in band. Any other known sequence, aligned: the least-squares gain and its residual.cyclic(x, sps): from the signal's own cyclostationarity, in band. Shifted by -1/2T and +1/2T, the two copies of a linearly modulated signal correlate (its spectral correlation at alpha = 1/T); noise doesn't. Where both copies carry signal (the roll-off's overlap) they are fully coherent whatever the pulse: per frequency (Sa - N0)(Sb - N0) = |C|^2, and one N0 is fitted to that over the overlap. Es is the folded spectrum over the signal's band less N0. The roll-off (which bins are the overlap) comes from fitting an RRC's correlation shape, and is given too. Any colour of noise outside the signal's band is irrelevant, and nothing but the symbol rate (searched +-2%) and independent symbols is assumed: a stream whose symbols aren't yet random (an interleaver filling from zero) reads low. Above about 15 dB the window's smoothing takes the coherence down and it reads low (17-19 at 20 dB), still high. None: no correlation found; noise alone reads None or under -3 dB (100 of 100 blocks).blind(x, sps): from the band the signal leaves empty: the eigenvalues of the covariance ofL-sample windows. The signal takes at most 2/sps of them (roll-off <= 1, MDL finds how many), the rest are the noise. Precise in white noise, but noise a front-end filter has shaped is not white: where some passband noise shows past the signal the eigenvalues are not flat and it says None, but where the filter's edge is right at the signal's band all it sees is the stopband, flat, and it reads 26-38 dB high. Use it only where the noise is white across Fs.
Measured (2026-11-23, error mean / std in dB; cyclic and blind on 2048 symbols at 4 sps, roll-off 0.35):
Es/N0 -10 -5 0 10 20 noise through a front-end filter
from_sequence, ZC 63 -0.3 / 3.0 +0.1 / 1.1 +0.15 / 0.6 within 0.5
from_sequence, ZC 839 0.0 / 0.7 0.0 / 0.3 0.0 / 0.16
cyclic (RRC 0.2-0.5) unusable -0.2..-1.5 -0.1..-0.3 -0.1..-0.5 -1.1..-2.8 the same as white
/ 0.7-1.3 / 0.2-0.6 / 0.1-0.3 / 0.1-0.2
blind None -0.2 / 0.3 -0.0 / 0.2 +0.0 / 0.1 +0.0 / 0.04 None, or 26-38 dB high
Classes:
| Name | Description |
|---|---|
Quality |
Es/N0, Eb/N0 and friends of a set of symbols (see |
SNR |
A signal-to-noise estimate before anything is locked ( |
Errors |
Per symbol, against the nearest point (see |
Summary |
A vector signal analyser's error summary of locked symbols (see |
Track |
Running Es/N0 estimate over the last |
Monitor |
Es/N0, Eb/N0 and EVM of the locked symbols going by, published to |
Functions:
| Name | Description |
|---|---|
measure |
Es/N0, Eb/N0 and EVM of locked symbols |
m2m4 |
Es/N0 (dB) of symbols y were they of the constellation |
from_sequence |
SNR of samples |
cyclic |
Es/N0 of samples of one linearly modulated signal (RRC, any roll-off) from its spectral correlation at the symbol |
blind |
SNR of oversampled samples of one signal, from the band it leaves empty (see the module). None when it can't tell |
decide |
The nearest of |
errors |
The error of each symbol of y (locked: corrected and at the constellation's scale) against the nearest of |
summary |
EVM, MER, magnitude and phase error, IQ offset, gain imbalance and quadrature error of locked symbols y against |
Quality ¶
Es/N0, Eb/N0 and friends of a set of symbols (see measure)
esn0_db: symbol energy over noise density. ebn0_db: bit energy over noise density (uncoded, or the information
bits of a code with rate). snr_db: signal over noise power in the sample bandwidth (None without sps).
evm_pct: rms error vector against the nearest point, as a percentage of the rms symbol. sigma: noise per real axis
(unit-rms symbols). n: symbols used.
Source code in src/rpps/sync/quality.py
SNR ¶
A signal-to-noise estimate before anything is locked (from_sequence, blind)
snr_db: signal over noise power per sample. esn0_db: per symbol (snr_db + 10 log10 sps). noise_var: noise power per sample (complex). gain: the complex channel gain (from_sequence). delay: the lag of the peak (from_sequence, periodic). dims: the signal's eigenvalues out of L (blind). beta: the fitted roll-off, sps: the samples a symbol the correlation was strongest at (cyclic). n: samples used.
Source code in src/rpps/sync/quality.py
Errors ¶
Per symbol, against the nearest point (see errors): vector = y - ideal; evm_pct = |vector|, mag_pct = |y| - |ideal|
(both as a percentage of the constellation's rms, as a vector signal analyser normalises them); phase_deg = the
angle from ideal to y [degrees] (0 where the ideal is the origin)
Source code in src/rpps/sync/quality.py
Summary ¶
A vector signal analyser's error summary of locked symbols (see summary)
evm_rms_pct, evm_peak_pct (at symbol evm_peak_at); mer_db: ideal symbol power over error power; mag_err_rms_pct, phase_err_rms_deg; from a fit of the symbols as kI I + kQ Q + c on the ideal points' I and Q: iq_offset_db: |c| over the rms of the rest [dB] (floored at -200); gain_imbalance_db: |kI| / |kQ| [dB], I over Q; quad_error_deg: the angle between the I and Q axes less 90 [degrees] (positive: more than 90 apart). The last two are None for a constellation on one line (BPSK, ASK). n: symbols
Source code in src/rpps/sync/quality.py
Track ¶
Running Es/N0 estimate over the last history symbols: update(block) returns the current Quality (None until enough)
Source code in src/rpps/sync/quality.py
Monitor ¶
Bases: Stage
Es/N0, Eb/N0 and EVM of the locked symbols going by, published to meta.stream.est[name] as a Quality (None until
minimum symbols): the symbols pass unchanged. The constellation is points, or the detected one (meta.det,
from Acquire) when none is given. A profile names it {"sync": "quality"}.
Source code in src/rpps/sync/quality.py
measure ¶
Es/N0, Eb/N0 and EVM of locked symbols y around the constellation points
bits: bits per symbol (default log2 of the number of points). rate: code rate, if the bits are information bits of a code (Eb/N0 is per information bit). sps: samples per symbol of the data they were taken from, for snr_db.
Source code in src/rpps/sync/quality.py
m2m4 ¶
Es/N0 (dB) of symbols y were they of the constellation points, from their second and fourth moments alone
(Pauluzzi and Beaulieu, 2000): M2 = S + N, M4 = k S^2 + 4 S N + 2 N^2 with k = E|p|^4 of the unit-rms points (1 for
any PSK; under 2 for any digital constellation), so S = sqrt((2 M2^2 - M4)/(2 - k)). No decisions, no carrier phase,
no pulse: rpps.sync.detect scores each candidate at its own. It fades for QAM at high SNR. Clamped to -30..60 dB
Source code in src/rpps/sync/quality.py
from_sequence ¶
SNR of samples y carrying the known sequence ref (one sample per element, sps samples a symbol for esn0)
y is one period of a CAZAC sequence (rp.sequence.zadoff_chu) at any cyclic shift and carrier phase, as an
OFDM symbol or a cyclic-prefixed preamble gives it: the peak of the circular correlation and the guard lags
each side of it are the signal (the channel's taps), every other lag noise alone. Needs len(y) == len(ref).
otherwise: y and ref aligned; the least-squares gain, and the residual as the noise.
Source code in src/rpps/sync/quality.py
cyclic ¶
Es/N0 of samples of one linearly modulated signal (RRC, any roll-off) from its spectral correlation at the symbol rate (see the module). None when there is no correlation to fit; esn0_db inf when N0 came out <= 0 (high SNR).
x: complex samples, the signal centred; sps: samples a symbol (more than 1.25). nseg: the Welch segment (default about 32 bins a symbol rate). search / step: the cyclic frequency is looked for within +-search of 1/sps (relative) in these steps, the strongest correlation kept: a rate a few tenths of a percent off turns the two copies half a cycle apart over a segment and the correlation, and Es with it, fades (sps in the result: the rate it was found at)
Source code in src/rpps/sync/quality.py
blind ¶
SNR of oversampled samples of one signal, from the band it leaves empty (see the module). None when it can't tell
x: complex samples, the signal centred; sps: samples a symbol (at least 1.3). L: the window, eigenvalues of its covariance; max_samples: the most used. flat: how flat the noise eigenvalues must be (geometric over arithmetic mean)
Source code in src/rpps/sync/quality.py
decide ¶
errors ¶
The error of each symbol of y (locked: corrected and at the constellation's scale) against the nearest of points.
Returns Errors (arrays of len(y))
Source code in src/rpps/sync/quality.py
summary ¶
EVM, MER, magnitude and phase error, IQ offset, gain imbalance and quadrature error of locked symbols y against
the nearest of points (Summary). Like an analyser, the decisions are the reference: at low SNR, where some are
wrong, the errors read low
Source code in src/rpps/sync/quality.py
rate ¶
Symbol rate estimates: the |x|^2 cyclostationary line on samples (find_baud), the rate of symbols (find_rate), the
pulse's roll-off from the spectrum (find_rolloff)
Functions:
| Name | Description |
|---|---|
find_baud |
Find the symbol rate from IQ samples using the |x|^2 cyclostationary line |
find_rate |
Find symbol rate (as a fraction of the sample rate) from IQ samples |
raised_cosine_psd |
The power spectrum of RRC-shaped symbols (|RRC|^2, a raised cosine) at frequencies f [Hz], 1 in the flat part |
nearest_rolloff |
The standard roll-off (ROLLOFFS) nearest a measured one |
find_rolloff |
The roll-off of an RRC-shaped signal from its spectrum: (beta, residual) |
find_baud ¶
Find the symbol rate from IQ samples using the |x|^2 cyclostationary line
lo/hi: search range in Hz [Fs/16, Fs/2.5] returns (baud, strength). Strength is the line over the local floor, a few is noise. Under 2.5 samples a symbol the line is at Fs/2.5 or above, and at 2 |x|^2 aliases it onto Fs/2: with the default range and no line over CLEAR_LINE, x is interpolated to twice its rate (in frequency) and Fs/2.5 to Fs/1.5 searched there too, its line taken when clear, stronger and no wider than the signal (16QAM at exactly 2 samples a symbol read a noise peak as its rate)
Source code in src/rpps/sync/rate.py
find_rate ¶
raised_cosine_psd ¶
The power spectrum of RRC-shaped symbols (|RRC|^2, a raised cosine) at frequencies f [Hz], 1 in the flat part
Source code in src/rpps/sync/rate.py
nearest_rolloff ¶
find_rolloff ¶
The roll-off of an RRC-shaped signal from its spectrum: (beta, residual)
A Welch spectrum of x (the signal at cfo Hz from x's centre, baud symbols a second, some floor beside it) fitted
by a raised cosine of each beta in grid plus a flat floor, each by least squares in its level and floor; the beta
whose fit leaves the least (residual: its rms over the signal's level). It measures the composite edge: a transponder
or receiver filter that steepens the edges reads as a smaller beta than the pulse's. Matched-filter likelihoods can't
tell 0.05 from 0.15 (rpps.sync.detect names 0.15 for both); the edges can: 8192 symbols at 10 dB read 0.05, 0.10,
0.20, 0.35 as 0.068, 0.109, 0.201, 0.39 (+-0.01 .. 0.05), each nearest its own of ROLLOFFS.
Source code in src/rpps/sync/rate.py
squelch ¶
Squelch: detects that a signal is present, and gates the stream on it
Classes:
| Name | Description |
|---|---|
Squelch |
Silence the signal while it is quieter than |
Functions:
| Name | Description |
|---|---|
gate |
Hysteresis: open where level > hi, closed where level <= lo, else as at the sample before ( |
Squelch ¶
Bases: Stage
Silence the signal while it is quieter than threshold_db (power, dB re 1.0), with hysteresis
The level follows a running average of the power (alpha of the gap a sample, from the first sample on: an IIR
section), so a brief dip doesn't close it. It opens where the level is over the open threshold, closes where it is at
or under the close one, and in between stays as it was: the last of those events, carried forward (no loop over the
samples).
Source code in src/rpps/sync/squelch.py
gate ¶
Hysteresis: open where level > hi, closed where level <= lo, else as at the sample before (was_open before the
first): each sample takes the last decisive one's state
Source code in src/rpps/sync/squelch.py
tone ¶
A phase-locked tone: the oscillator a pilot sets (FM stereo's 19 kHz, ATSC's pilot), and the signal mixed with it
Classes:
| Name | Description |
|---|---|
ToneLock |
Lock an oscillator to a steady tone near |
ToneLock ¶
ToneLock(f0, win=16384, kp=0.4, ki=0.05, harmonic=1, min_level=0.0, lock_level=0.0, lock_err=0.5, min_part=0.25, history=4096)
Bases: Stage
Lock an oscillator to a steady tone near f0 Hz, and mix the stream with its harmonic
A block-rate PLL: every win samples (windows at absolute positions, so the block cut does not matter) the tone's phase
is measured against the oscillator, which then corrects its phase (kp) and frequency (ki). Output, from the oscillator
as it was over each window:
complex input: x exp(-j h phase), the tone (h = 1) moved to DC (ATSC: the pilot locks the carrier)
real input: 2 x cos(h phase), a product detector at the harmonic (FM stereo: h = 2, the L-R subcarrier at 38 kHz)
min_level: below this tone level the loop holds (a station with no pilot leaves noise there); lock_level and lock_err
[rad] decide locked. min_part: at the stream's end, a last window this full still corrects. The state: level (the
tone's amplitude: 2|z| for a real input, |z| for complex), err [rad], locked, and the last history windows'
errs and levels.
Source code in src/rpps/sync/tone.py
track ¶
Block-rate tracking (rpps.sync): a slow loop run once per window over the window estimates
A first-class estimator measures a parameter on each window (block estimation); this carries the parameter and its rate
from window to window, gating outliers, so a drifting clock or carrier is followed without a staircase: the value at
any position is at(t), a line through the last update. It is a critically damped second-order loop: each window's
error (measured minus predicted, wrapped to the parameter's period) moves the value by 2*bw of itself and the rate by
bw**2 of it per window. bw is the loop's natural frequency in radians per window: smaller is quieter, larger follows
faster drift.
The state is a SimpleNamespace (new()), kept in the estimating stage's stream state, so a re-run can copy it.
Functions:
| Name | Description |
|---|---|
new |
A tracker that has seen nothing: |
wrap |
x wrapped to [-period/2, period/2) |
at |
The tracked value at position t (any position: the correction is evaluated per item, not per window) |
line_phasor |
exp(-j (phi0 + rate i)) for i in 0 .. length-1: a phase line turned into a phasor with no exponential per item. Each |
line_parts |
(starts, local) of |
update |
A window's measurement (modulo |
miss |
A window gated out: the tracker coasts on its rate |
windows |
Hold x and give each window ready: (a0, b, seg) for stream positions [a0, b) of [kW, (k+1)W). On a flush the |
keep |
Let go of the items held before stream position pos (at most all of them) |
new ¶
wrap ¶
at ¶
The tracked value at position t (any position: the correction is evaluated per item, not per window)
line_phasor ¶
exp(-j (phi0 + rate i)) for i in 0 .. length-1: a phase line turned into a phasor with no exponential per item. Each block of about sqrt(length) items is one start phasor times the same short vector of exponentials, so it costs two multiplications an item and about 2 sqrt(length) exponentials, and agrees with the direct exponential to about 1e-14
Source code in src/rpps/sync/track.py
line_parts ¶
(starts, local) of line_phasor: item i's phasor is starts[i // len(local)]*local[i % len(local)] (a device kernel
reads the line this way, the exponentials made on the host in double)
Source code in src/rpps/sync/track.py
update ¶
A window's measurement (modulo period when given) at position t, its centre. rate: a measured rate to start from
Source code in src/rpps/sync/track.py
miss ¶
windows ¶
Hold x and give each window ready: (a0, b, seg) for stream positions [a0, b) of [kW, (k+1)W). On a flush the
last, partial window comes too. st carries buf (the items held from position base), base, k and W:
None until the first block sets them. Afterwards call keep(st, pos) to let go of what lies before pos
Source code in src/rpps/sync/track.py
keep ¶
Let go of the items held before stream position pos (at most all of them)
rpps.sync.loops ¶
Second class: per-sample loops (rpps.sync)
Each updates its estimate once a sample or a symbol, carrying it from one to the next. Block estimation tracked across
windows (rpps.sync's first class) replaces them in the profiles and examples; they stay for signals and conditions it
does not suit, as references, and for comparison. Each runs in the C++ kernels when they are built (rpps._native), with
its Python loop as the reference. Their loop filter is pll.PILoop, its gains from a noise bandwidth (pll.loop_gains).
| Loop | Estimates | First-class counterpart |
|---|---|---|
MM |
symbol timing: Mueller & Muller (ted="mm", decisions) or Gardner ("gardner"), interpolated per symbol |
time.OerderMeyr, time.MatTrack |
TLL |
symbol timing: a PI loop (pll.PILoop) around a detector from ted (zero crossing, early-late) |
time.OerderMeyr, time.MatTrack |
Costas |
carrier phase and frequency, per symbol: M-PSK, or decisions on any constellation's points |
phase.MPower, phase.DDCarrier |
AGC |
the gain, sample by sample (mu, linear or in logs) |
rpps.sync.AGC (the level per window) |
PeakAGC |
the peak, followed and decayed sample by sample | rpps.sync.PeakAGC (closed form, the same output) |
Squelch |
whether a signal is there, the level followed sample by sample | rpps.sync.Squelch (an IIR section, the same output) |
LMS |
equalizer taps, per symbol: least mean squares against training, then decisions | equalize.BlockLS |
CMA |
equalizer taps, per symbol: constant modulus, blind | equalize.BlockLS (blind=True) |
Modules:
| Name | Description |
|---|---|
agc |
Automatic gain control as per-sample loops |
costas |
The Costas loop: carrier phase and frequency followed per symbol (rpps.sync.loops) |
equalize |
Adaptive equalizers, updated symbol by symbol (second class): |
mm |
Mueller & Muller and Gardner timing recovery: a per-symbol loop (rpps.sync.loops) |
pll |
Phase Locked Loop helpers |
squelch |
Squelch as a per-sample loop: the level and the gate decided sample by sample |
ted |
Timing error detectors: the error a timing loop (rpps.sync.loops.TLL) steers by, from samples around a symbol's instant |
tll |
Timing locked loop: a per-symbol loop around a timing error detector (rpps.sync.loops.ted) |
agc ¶
Automatic gain control as per-sample loops
R = reference level
x[n] = input signal z[n] = a[n-1] * x[n] controlled output e[n] = R - |z[n]| (linear) or log(R) - log|z[n]| (log) a[n] = a[n-1] + mu * e[n] (linear) or a[n-1] * exp(mu * e[n]) (log)
The gain is carried across blocks, so any block length gives the same stream. The first-class rpps.sync.AGC measures the
level per window instead; rpps.sync.PeakAGC is PeakAGC here in closed form (the same output).
Classes:
| Name | Description |
|---|---|
PeakAGC |
Gain from the peak, followed sample by sample: |x| is followed instantly upward and decays by |
AGC |
Feedback AGC: |
PeakAGC ¶
Bases: Stage
Gain from the peak, followed sample by sample: |x| is followed instantly upward and decays by decay per sample,
and the signal is scaled so that peak sits at target
Source code in src/rpps/sync/loops/agc.py
AGC ¶
Bases: Stage
Feedback AGC: block + rp.sync.loops.AGC(1.0, 0.01)
target: output amplitude R mu: loop rate (per sample). Larger tracks faster and ripples more log: adapt the gain in the log domain, so the loop speed doesn't depend on the signal level max_gain/min_gain: limits on the gain
Source code in src/rpps/sync/loops/agc.py
costas ¶
The Costas loop: carrier phase and frequency followed per symbol (rpps.sync.loops)
Classes:
| Name | Description |
|---|---|
Costas |
Costas loop: |
Costas ¶
Bases: Stage
Costas loop: symbols + rp.sync.loops.Costas.from_bandwidth(0.02, order=4). Settings live here, freq and pha live in meta.state_of(costas)
The error is normalized by the symbol amplitude, so alpha/beta don't depend on signal level
alpha, beta: proportional and integral gain (see from_bandwidth)
order: 2 (BPSK), 4 (QPSK, points at 45 degrees) or any M >= 3 for M-PSK with a point at offset radians
points: any constellation's points instead (APSK, QAM): the error is the angle to the nearest one, the loop
decision directed (in Python: the C++ kernel knows M-PSK only); order is then len(points)
Methods:
| Name | Description |
|---|---|
from_bandwidth |
Loop gains from a noise bandwidth normalised to the symbol rate (0.01-0.05 typical) |
Source code in src/rpps/sync/loops/costas.py
from_bandwidth
classmethod
¶
Loop gains from a noise bandwidth normalised to the symbol rate (0.01-0.05 typical)
Source code in src/rpps/sync/loops/costas.py
equalize ¶
Adaptive equalizers, updated symbol by symbol (second class): symbols + rp.sync.loops.CMA(11), rp.sync.loops.LMS
Each makes one output per symbol from sps input samples per symbol (1, or 2 for a fractionally spaced equalizer).
The taps carry across blocks, so any block length gives the same stream. First class: rp.sync.equalize.BlockLS, the
taps solved by least squares per window (blind, by least squares constant modulus, until the eye opens).
Classes:
| Name | Description |
|---|---|
CMA |
Constant modulus algorithm: blind, for constant-envelope modulations (PSK, FSK) -- it fixes ISI but not rotation |
LMS |
Least mean squares against a training sequence for the first symbols, then against the nearest point of |
CMA ¶
Bases: _Equalizer
Constant modulus algorithm: blind, for constant-envelope modulations (PSK, FSK) -- it fixes ISI but not rotation
modulus: the symbol amplitude it steers towards (1.0)
Source code in src/rpps/sync/loops/equalize.py
LMS ¶
Bases: _Equalizer
Least mean squares against a training sequence for the first symbols, then against the nearest point of
points (decision directed). Needs a carrier that is already locked
eq = rp.sync.loops.LMS(11, points=rp.symbol.load("QPSK").points, training=known_symbols)
With neither, the constellation is the detected one (meta.det, see rp.sync.Acquire), so after the
carrier correction: ... + rp.sync.phase.FFCarrier() + rp.sync.loops.LMS(7, 0.002).
Source code in src/rpps/sync/loops/equalize.py
mm ¶
Mueller & Muller and Gardner timing recovery: a per-symbol loop (rpps.sync.loops)
Classes:
| Name | Description |
|---|---|
MM |
Mueller & Muller timing recovery |
MM ¶
Bases: Stage
Mueller & Muller timing recovery
The whole block is interpolated once, then the optimal sample is picked from the interpolated block. The timing estimate is kept in [0, 1) (fractional sample offset); its integer part is moved into the input index.
Settings live here, the loop state (est, history...) lives in meta.state_of(mm).
"mm" (Mueller & Muller, decision directed) or "gardner" (needs no decisions, works for any modulation,
wants at least 2 samples per symbol)
biphase: Biphase (Manchester) symbols, after their matched filter, have two power peaks per symbol and M&M is happy at the weaker one. Use early-late on power, and hop half a symbol if the other peak is stronger.
Source code in src/rpps/sync/loops/mm.py
pll ¶
Phase Locked Loop helpers
Composed of: - Error detector, (eD[n]), error detector output - Loop filter, (eF[n]), filter output - Generator, (eC[n]), estimate - Accumulator - eC[n] = (eC[n-1] + K0 * eF[n-1] mod [max])
loop_gains designs the filter from a bandwidth, which is how Costas and the timing loops should be tuned; PILoop
is the filter.
Classes:
| Name | Description |
|---|---|
PILoop |
Proportional-integral loop filter: eF[n] = KpeD[n] + (sum of KieD) |
Functions:
| Name | Description |
|---|---|
loop_gains |
Proportional and integral gains (alpha, beta) of a second order loop |
K_fs |
(Kp, Ki) for a loop of noise bandwidth Bn [Hz] running at Fs [Hz] |
K_sr |
(Kp, Ki) for a loop of noise bandwidth Bn [Hz] that updates once per symbol (sr: symbol rate [Hz]) |
PILoop ¶
loop_gains ¶
Proportional and integral gains (alpha, beta) of a second order loop
bw: loop noise bandwidth, normalised to the rate the loop runs at (0.01-0.05 is typical: 1-5 % of the rate) damping: damping factor (1/sqrt(2); 0.5-2.0) Kd: detector gain, K0: generator gain
Source code in src/rpps/sync/loops/pll.py
K_fs ¶
(Kp, Ki) for a loop of noise bandwidth Bn [Hz] running at Fs [Hz]
K_sr ¶
(Kp, Ki) for a loop of noise bandwidth Bn [Hz] that updates once per symbol (sr: symbol rate [Hz])
Source code in src/rpps/sync/loops/pll.py
squelch ¶
Squelch as a per-sample loop: the level and the gate decided sample by sample
Classes:
| Name | Description |
|---|---|
Squelch |
Silence the signal while it is quieter than |
Squelch ¶
Bases: Stage
Silence the signal while it is quieter than threshold_db (power, dB re 1.0), with hysteresis
The level follows a running average of the power, updated sample by sample, so a brief dip doesn't close it. The same output as rpps.sync.Squelch, which runs the average as an IIR section.
Source code in src/rpps/sync/loops/squelch.py
ted ¶
Timing error detectors: the error a timing loop (rpps.sync.loops.TLL) steers by, from samples around a symbol's instant
Both need no decisions and no carrier (non-data aided) and at least 2 samples a symbol. Positive: the instant is early (the loop moves it later). Decision-directed Mueller & Muller is part of rpps.sync.loops.MM.
Functions:
| Name | Description |
|---|---|
zx |
Zero crossing (Gardner): |
el |
Early-late: |
tll ¶
Timing locked loop: a per-symbol loop around a timing error detector (rpps.sync.loops.ted)
Classes:
| Name | Description |
|---|---|
TLL |
Symbol timing by a timing locked loop: samples at |
TLL ¶
Bases: Stage
Symbol timing by a timing locked loop: samples at sps in (after their matched filter), one symbol each out
symbols = matched + rp.sync.loops.TLL(sps=4, bw=0.01)
Second class (rpps.sync): a loop updated once per symbol. Each symbol is interpolated at its
instant, and a timing error detector (ted: "zx", zero crossing (Gardner), on the symbol before it, the sample half
way and this one; "el", early-late, on the samples half a symbol either side of this one) gives the timing error, which a proportional-integral loop filter (rpps.sync.loops.pll.PILoop, from bw as a fraction of the
symbol rate) turns into the next instant. Needs no decisions and no carrier, so it runs before carrier recovery.
Any sps over 1, fractional too, and any block cut. Estimates in stream.est[name]: the timing phase (samples) and the
loop's rate correction.
Source code in src/rpps/sync/loops/tll.py
rpps.sync.phase ¶
Carrier frequency and phase, by block estimation (rpps.sync): MPower (M-th power: FFT acquisition, then per-window
phase, tracked), DDCarrier / decided.follow (from decisions, any constellation: APSK, QAM), FFCarrier (Viterbi &
Viterbi, per frame)
Modules:
| Name | Description |
|---|---|
decided |
Carrier phase from decisions, by block estimation tracked across windows: any constellation (APSK, QAM, PSK) |
ff |
|
mpower |
|
decided ¶
Carrier phase from decisions, by block estimation tracked across windows: any constellation (APSK, QAM, PSK)
Symbols are cut into windows of window at absolute positions. Each window is turned back by the phase the tracker
(rpps.sync.track) predicts for it, and its residual is the angle of sum y conj(d), d the nearest point to y (the
window's amplitude matched to the points' first), twice: the second time decided on symbols already closer to their
points. The tracker carries phase and frequency to the next window, so the correction is a line per symbol and a
frequency offset is followed. No loop over symbols: one per window.
Decisions are right only near the points: the phase has to start within half the points' closest angular spacing
(16APSK's outer ring: 15 degrees), so this follows a carrier a preamble or a word has taken off, as a Costas loop on
the same points would; it does not acquire one (MPower does, for M-fold symbols). follow(y, points) corrects a
whole array; DDCarrier is the stream stage.
Classes:
| Name | Description |
|---|---|
DDCarrier |
Carrier phase and frequency from decisions on any constellation, block estimation tracked across windows |
Functions:
| Name | Description |
|---|---|
decide |
The nearest of |
residual |
The phase of y against its own decisions (its amplitude matched to the points'), refined |
follow |
y (symbols, one each, a carrier near 0 already) with the phase its decisions show taken off: |
DDCarrier ¶
Bases: Stage
Carrier phase and frequency from decisions on any constellation, block estimation tracked across windows
symbols + rp.sync.phase.DDCarrier(rp.symbol.load("apsk/dvbs2_16apsk", rate="2/3").points)
First class (rpps.sync); see the module. Symbols in (one a symbol), the same out. window symbols a window, bw the
tracker's (rpps.sync.track), wide for the first windows while it pulls in. 32 symbols: on 16APSK with a
drifting, noisy phase, 64 slipped a rotation once in 40 runs while the rate was being learned, 32 never. Latency: a window. Estimates in
stream.est[name]: phase (rad), frequency (cycles a symbol), latency (symbols).
Source code in src/rpps/sync/phase/decided.py
decide ¶
The nearest of points to each of y
Source code in src/rpps/sync/phase/decided.py
residual ¶
The phase of y against its own decisions (its amplitude matched to the points'), refined iters times
Source code in src/rpps/sync/phase/decided.py
follow ¶
y (symbols, one each, a carrier near 0 already) with the phase its decisions show taken off: DDCarrier over the
whole array
Source code in src/rpps/sync/phase/decided.py
ff ¶
Classes:
| Name | Description |
|---|---|
FFCarrier |
Feed-forward carrier correction for M-fold symmetric (PSK) symbols. No loop |
FFCarrier ¶
Bases: Stage
Feed-forward carrier correction for M-fold symmetric (PSK) symbols. No loop
Takes the modulation order M, the constellation phase, the frequency offset and the gain
from the detection in Meta (meta.det). Then per symbol:
frequency: phase-continuous oscillator at the detected offset
phase: Viterbi & Viterbi, the angle of the sum of y^M over the last window symbols, divided by M
amplitude: the detected gain
window: symbols averaged for the phase. Longer is quieter, shorter follows drift better
mpower ¶
Classes:
| Name | Description |
|---|---|
MPower |
Carrier frequency and phase of M-fold symmetric symbols by the M-th power, block estimation tracked across windows |
Functions:
| Name | Description |
|---|---|
offset_of |
The angle of a constellation's mean point^M: what MPower takes off as |
MPower ¶
MPower(order=4, offset=0.0, window=0.001, min_symbols=1024, bw=0.25, gate=3.0, relock=4, name='carrier', device=False, acquire=16384)
Bases: Stage
Carrier frequency and phase of M-fold symmetric symbols by the M-th power, block estimation tracked across windows
symbols = timed + rp.sync.phase.MPower(order=4, offset=np.pi) # QPSK at 45 degrees: its points^4 are -1
First class (rpps.sync). Windows sit at absolute stream positions, window seconds (at least
min_symbols). The first window that shows the carrier acquires it: the FFT of y^M (zero padded) gives the
frequency, |f| < 1/(2M) cycles per symbol, and the phase at its centre. After that each window measures the
residual phase of y turned back by the tracked line, (angle(sum u^M) - offset) / M with u = y e^{-j phase} / |y|, and a block-rate
loop (rpps.sync.track) carries phase and frequency on, so the correction is a line per symbol, with no staircase and no
slips while the drift stays inside the loop. A window whose M-th power line is weaker than gate (its SNR: noise
alone is about 1) is skipped; after relock of those in a row the carrier is acquired again from the FFT, its phase on
the branch (of the M) nearest the line held till then, so the correction carries on without a jump. Acquiring
wants gate more than the best of the FFT's N frequencies reaches on noise, sqrt(2 ln N): at an Es/N0 where the M-th
power is lost in noise (DVB-S2 under 0 dB with M = 8) nothing is acquired and the symbols pass, for a preamble and
pilots to take the phase. acquire: a line one window can't show is tried on the last acquire symbols together,
once every that many windows (fixed positions): DVB-S2 at 8 dB under M = 8 wants about 8000. Tracking does the
same: a window under the gate holds the line, and the last acquire symbols are measured together at those
positions, so a carrier a window can't show is still tracked (each long measurement is one update; only a long one
missing counts towards relock) rather than acquired again and again.
The phase is known modulo 2 pi / M: a preamble, a differential code or a polarity search takes the rest. order: M (a
profile may change it with the modulation, live). offset: the angle of the constellation's mean point^M (0 for BPSK,
8PSK, and DVB-S2's pi/2-BPSK under M = 8; pi for QPSK at 45 degrees under M = 4).
Until it acquires, symbols pass unchanged. Estimates in stream.est[name]: frequency (cycles per symbol), phase, SNR,
latency (seconds). device: each window's measurement and correction on the GPU of rpps._accel.device() (CuPy,
CUDA or ROCm/HIP; the host without one), the samples going up once a block; acquiring (an FFT, rarely) stays on the
host, and the tracking is the host's, window by window.
Source code in src/rpps/sync/phase/mpower.py
offset_of ¶
The angle of a constellation's mean point^M: what MPower takes off as offset
rpps.sync.time ¶
Symbol timing: where to sample, by block estimation (rpps.sync). OerderMeyr (the square-law line, tracked across
windows), MatTrack (the matched filter fused in and evaluated only at the instants, timing from its energy maximum,
tracked across windows; on a GPU too), Mat (matrix matched filter, per block), Known when the timing is given
Modules:
| Name | Description |
|---|---|
known |
Known timing: the symbol instants given, not estimated (a profile's |
mat |
|
matrack |
MatTrack: the matched filter and symbol timing in one, tracked across windows (a profile's |
om |
|
known ¶
Known timing: the symbol instants given, not estimated (a profile's timing: known)
Classes:
| Name | Description |
|---|---|
Known |
Timing that is known, not estimated (a loopback, a source whose timing is given): one sample per symbol at the pulse |
Known ¶
Bases: Stage
Timing that is known, not estimated (a loopback, a source whose timing is given): one sample per symbol at the pulse peaks, which the group delay so far (meta.delay) places. Tracks the absolute input index of the next peak, so any block cut gives the same output.
With a matched filter fused in (fuse, which a profile does for the filter just before it) the filter is evaluated only at
those instants, a dot product of its taps with the signal per symbol: sps times less work than filtering every sample and
keeping every sps-th, the same symbols. The estimators that need the filter's output at every sample (Oerder & Meyr) have
nothing to fuse
anchor: the name of a preamble (rpps.sync.Preamble) in the stream's estimates: the grid starts at its first symbol's peak, moved by the group delay added since (a burst's own timing; until the preamble is found nothing comes out)
Methods:
| Name | Description |
|---|---|
fuse |
Take over a matched filter (a FIR stage): this stage then also filters, at the instants it samples |
Source code in src/rpps/sync/time/known.py
fuse ¶
Take over a matched filter (a FIR stage): this stage then also filters, at the instants it samples
mat ¶
Classes:
| Name | Description |
|---|---|
Mat |
Matrix matched filter and symbol timing |
Functions:
| Name | Description |
|---|---|
matrix_mf |
Matched filter + symbol sampling as a (banded) matrix: y = W @ x |
fits |
Which centres have their whole matched-filter support in n samples (what matrix_mf reads) |
centres_in |
Symbol centres t0 + k*sps whose whole support fits in n samples |
best_tau |
Symbol timing in [0, sps) maximising the matched-filter output energy, from x[lo:hi] |
Mat ¶
Bases: Stage
Matrix matched filter and symbol timing
Needs meta.det (see rpps.sync.detect) for beta and the timing offset. Symbols are
taken from a lattice t_next + k*sps in the (fractional) sps of Meta, then the lattice is nudged by a
block-wise energy-maximum estimate (track = fraction of it applied) to follow the clock.
beta/span/track: settings; beta None takes the detected one.
Source code in src/rpps/sync/time/mat.py
matrix_mf ¶
Matched filter + symbol sampling as a (banded) matrix: y = W @ x
W[i, j] = rrc((j - centres[i]) / sps), so symbols are taken at any fractional instant
and sps may be fractional. Only the 2spansps columns that matter are built per row.
x[centres +/- span*sps] must exist (fits; IndexError otherwise). Weights have unit energy per row.
Complex x runs in C++ when the kernels are loaded (rpps._native.matrix_mf: the rows computed and applied in one
pass, never stored); the code below is the reference it agrees with to rounding.
Source code in src/rpps/sync/time/mat.py
fits ¶
Which centres have their whole matched-filter support in n samples (what matrix_mf reads)
Source code in src/rpps/sync/time/mat.py
centres_in ¶
Symbol centres t0 + k*sps whose whole support fits in n samples
best_tau ¶
Symbol timing in [0, sps) maximising the matched-filter output energy, from x[lo:hi]
The symbol lattice is tau + k*sps in absolute sample index, so results from different segments of x are comparable. Returns (tau, mean |y|^2)
The matched filter runs once, as a convolution; its output is band-limited, so each of the grid candidate timings
reads it at its own symbol instants with a 12-tap windowed sinc (math.interp.fractional: -56 dB at 2 samples a
symbol), in chunks. A segment too short for the convolution's edges takes the filter matrix for each candidate
(_best_tau_rows), which gives the same answer.
Source code in src/rpps/sync/time/mat.py
matrack ¶
MatTrack: the matched filter and symbol timing in one, tracked across windows (a profile's timing: mat)
Classes:
| Name | Description |
|---|---|
MatTrack |
Matched filter and symbol timing in one: samples at |
MatTrack ¶
MatTrack(sps=None, window=0.001, min_symbols=2048, bw=0.25, delta=None, grid=16, gate=0.02, relock=4, group=16, device=False, name='timing')
Bases: Stage
Matched filter and symbol timing in one: samples at sps in (before their matched filter, which a profile fuses in
from the step before: fuse), one symbol each out. The matched filter is evaluated only at the instants read, a dot
product of its taps with the samples at the four around each instant, cubic-interpolated: what filtering every sample
and interpolating (Matched + OerderMeyr) gives there, sps times less filtering.
symbols = samples + rp.sync.time.MatTrack(sps=4, pulse=rrc) # or a profile's {"timing": {"method": "mat"}}
The timing is a matrix matched filter's (as Mat, MatRRC): no decisions, no per-sample loop. Each window (window
seconds, at least min_symbols symbols, at absolute stream positions) measures the filter's energy at the predicted
instants and delta samples either side; the parabola's vertex is the timing error, and the block-rate loop
(rpps.sync.track) carries the phase and the clock's rate on. The first window acquires the phase from grid phases a
symbol (the energy's maximum), as does a window after relock misses; a window without a maximum is a miss (noise,
a gap between bursts), the loop coasting through it.
Once the loop has settled (group windows), windows go in groups of group at fixed stream positions, each measured at
the instants the loop predicted at its group's start, so a group is one batch of work (one launch on a device) and any
block cut gives the same symbols; delta (default a quarter symbol) sets the range a measurement reads, which a
settled loop stays well inside of over a group. device: the evaluation on the
GPU of rpps._accel.device() (CuPy, CUDA or ROCm/HIP; numpy without one): only the samples go up and the symbols
down. Estimates in stream.est[name]: phase (samples), ppm, windows, missed, latency (seconds).
Methods:
| Name | Description |
|---|---|
fuse |
Take over a matched filter (a FIR stage, the profile's |
Source code in src/rpps/sync/time/matrack.py
fuse ¶
Take over a matched filter (a FIR stage, the profile's wave shape receive side): it is evaluated here
om ¶
Classes:
| Name | Description |
|---|---|
OerderMeyr |
Symbol timing by square-law block estimation (Oerder & Meyr), tracked across windows: samples at |
OerderMeyr ¶
OerderMeyr(sps=None, window=0.001, min_symbols=2048, bw=0.25, gate=2.0, name='timing', clock=True, device=False)
Bases: Stage
Symbol timing by square-law block estimation (Oerder & Meyr), tracked across windows: samples at sps in (after
their matched filter), one symbol each out
symbols = matched + rp.sync.time.OerderMeyr()
First class (rpps.sync). Windows sit at absolute stream positions [kW, (k+1)W): W is window
seconds, at least min_symbols symbols (the square-law line is weak: at roll-off 0.2 it is about 3% of the power, so it
wants a few thousand samples). Each window's timing phase is the angle of sum |x[n]|^2 exp(-j 2 pi n / sps), and a
block-rate loop (rpps.sync.track) carries the phase and the clock's rate (ppm: the transmitter's clock fast by that much) from window to window, so a clock some ppm
off is followed and each symbol's instant comes from the line, not a step per window. A window whose line is weaker
than gate (its SNR, |X| / sum|x|^2 * sqrt(n): noise alone is about 1) is skipped, the loop coasting through it (a gap
between bursts). Symbols are interpolated from the samples (cubic, or a windowed sinc under 4 samples a symbol:
rpps._effort.interp_taps); any sps from 1, fractional too (under 2: a 30 MBd carrier in 50 MS/s), and any block cut.
Latency: a window, as latency (seconds) in stream.est[name] with the phase, the rate (ppm) and the line's SNR.
Nothing comes out before the first window that passes the gate. device: each window's sums and symbols on the GPU
of rpps._accel.device() (CuPy, CUDA or ROCm/HIP; the host without one), the samples going up once a block; the
tracking is the host's, window by window (under 4 samples a symbol the upsampled window is made on the host).