Base
rpps.base ¶
The design: data, operators, categories, contracts and the streaming rules
RPPS stays signal agnostic: a new kind of signal should be new definitions plus existing operators.
The model¶
samples -> symbols -> channel bits -> data bits -> packets / messages
Channel bits are what crosses the channel (after FEC, interleaving, scrambling, sync markers); on receive they are LLRs until the code transform decides them. Data bits are what the link layer carries.
- Transforms turn one representation into the next, as an invertible transmit/receive pair: wave, symbol, code, link.
- Conditioning (
signal) changes samples without knowing what they carry. - Sync estimates something unknown and corrects or aligns the data with it, at any representation: carrier and timing on samples, phase on symbols, codeword boundaries on channel bits, packet starts on data bits. A receiver uses it many times.
A profile (rpps.profile) puts these together for one signal, both directions. Data flows down the chain;
control flows back up it: a header decoded late can change earlier steps' parameters from a known position onward,
without losing lock (rpps.base.control, rpps.profile.control).
The rule¶
A function belongs to the category named by what it takes and what it gives, not by what a standard calls it.
- Changes the representation: the transform for that step.
- Estimates an unknown and corrects or aligns with it: sync, at whatever representation.
- Changes samples without knowledge of the signal: signal.
- Inserting or removing known structure belongs to the transform where the structure lives: pilots and physical headers among symbols (symbol), sync markers among channel bits (code), headers and CRCs among data bits (link). Finding where it starts is sync.
Two implementations of one function share a signature, so they land in the same category.
Categories¶
Receive direction; transmit runs the transforms in reverse, and sync has no transmit side.
| Category | Package | Takes → gives | Operator |
|---|---|---|---|
| Source | source |
outside world ↔ any representation | Source(n), block >> sink |
| Conditioning | signal |
samples → samples | Stage, + |
| Sync | sync |
any representation → the same, corrected or aligned; timing recovery takes samples to symbols | Stage, +, one-way |
| Wave | wave |
samples ↔ symbols | Stage pairs |
| Symbol | symbol |
symbols ↔ channel bits (LLRs on receive) | Pipe, * and / |
| Code | code |
channel bits ↔ data bits | Pipe, * and / |
| Link | link |
data bits ↔ packets | Pipe, * and / |
| Profile | profile |
one whole signal, both directions | builds the above |
| Parallel | parallel |
a profile's frame-parallel region | profile.rx(parallel=...) |
"Framing" is two things on opposite sides of the decoder: sync markers (CCSDS ASM, DVB-S sync bytes, DVB-S2 SOF, 802.15.4 SHR) live among symbols or channel bits, are found by sync and inserted by symbol or code; link framing (HDLC, headers, lengths, CRCs) lives among data bits and belongs to link.
A DVB-S2 receiver in order: channelize, decimate (signal) → AGC, coarse frequency (sync) → matched filter (wave) → timing (sync, gives symbols) → SOF, fine frequency and phase from pilots (sync) → PL descrambling, header and pilot removal, demapping (symbol, gives LLRs) → deinterleaving, LDPC, BCH, BB descrambling (code) → BBHEADER, packets (link). DVB-S puts sync between two code steps: Viterbi (code) → byte alignment and polarity from the sync bytes (sync) → Forney deinterleaving, Reed-Solomon, energy dispersal (code).
Contracts¶
tests/unit/policy/test_contracts.py checks these over every registered implementation.
- source: produces blocks at any representation and says which, and which sync was already applied (for example
timed, carrier not removed). Sets the rates it knows (
Fs,cf, symbol rate) and each block's absolute position. Sinks take any representation. - signal:
SAMPLESorREALin, the same out. May changeFs, never needssps, same in both directions. Includessignal.channel, the simulated medium tests use as the counterpart of sync. - sync: any representation in, the same out, corrected or aligned. The one exception is timing recovery, the
sampler (
SAMPLESatsps> 1 →SYMBOLS); the matched filter before it is wave. Estimates (offset, timing, lock, SNR, detection, frame start, polarity) go tometa.stream, never into the data. No inverse. - wave: transmit takes
SYMBOLSand raisessps(shaping, FM/CPM, stagger, IFFT + CP); receive prepares samples for the sampler (matched filter, discriminator, rail realignment, CP removal + FFT) without choosing the instant. Comes in pairs (rpps.wave). - symbol: encode takes channel bits, gives symbols. Decode gives
SYMBOLS(differential, despreading, removing pilots and headers, descrambling) orLLR(demapping); the last symbol step always gives soft output. - code: encode data bits → channel bits; decode channel bits (LLRs or hard) → data bits, LLRs when it can. FEC, interleaving, rate matching, puncturing, scrambling, line codes, sync markers; all invertible. Needs codeword boundaries known (finding them is sync).
- link: decode aligned data bits into packets (split at lengths or flags, check CRCs, strip headers and stuffing;
status in
ctx); encode builds them.
Grey areas¶
Each settled by the rule.
| Function | Category | Why |
|---|---|---|
| Matched filter | wave | prepares samples; does not decide when to sample |
Timing recovery (OerderMeyr, MatTrack, Mat, Known) |
sync | estimates the instant; the one sync step that changes representation |
| Differential coding on symbols / on bits (NRZI) | symbol / code | symbols ↔ symbols / bits ↔ bits |
| Manchester as a pulse / as 0 → 01, 1 → 10 | wave / code | symbols ↔ samples / bits ↔ bits |
Spreading at one sample per chip (Spread), Despread at sps with a known code phase |
symbol | chips are symbols |
| Code-phase and Doppler search, preamble correlation, sync-marker and HDLC-flag search, phase ambiguity | sync | find a start or estimate an unknown |
| Attaching a sync marker | code | known structure among channel bits |
| Pilots, physical headers, padding, OFDM carrier allocation | symbol | known structure among symbols |
| Reading a physical header's fields (DVB-S2 PLS) | symbol | symbol.Header decodes its short code into fields |
| Equalizer, OFDM pilot equalization, squelch | sync | estimate the channel / presence |
OFDM IFFT/FFT and CP; FMDemod, AMDemod, SSBDemod |
wave | symbols ↔ samples, carrier ↔ baseband |
| De-emphasis, DC block; channel impairments | signal | samples → samples |
| CRC guarding a packet / inside FEC (LTE code-block CRC) | link / code | resources are shared across categories |
Soft information only flows down the receive chain: symbol gives LLRs, code takes and gives them, link takes hard bits and their reliability, and sync on channel bits passes LLRs through. Order matters inside sync: a step sits where what it corrects can still be separated (coarse frequency before the matched filter, fine phase after timing, a staggered signal's carrier before its rails are realigned).
Type tags¶
Every block carries a form (dtype: SAMPLES, REAL, SYMBOLS, LLR, BITS, BYTES, MSG; how values are stored) and a
representation (Rep: SAMPLES, SYMBOLS, CHANNEL, DATA, PACKETS; where in the chain). Forms cross representations:
LLRs exist before the decoder and after a soft-output one. Each operator declares takes(encode) and checks it before
working, so a link decoder refuses channel bits and a constellation refuses samples; CATEGORY says which category it is.
| Category | Accepts | Gives |
|---|---|---|
| signal | SAMPLES (form SAMPLES or REAL) | the same |
| sync | any | the same; timing gives SYMBOLS from SAMPLES |
| wave | SYMBOLS (tx), SAMPLES (rx) | SAMPLES |
| symbol | CHANNEL (encode), SYMBOLS (decode) | SYMBOLS; SYMBOLS or CHANNEL as LLR |
| code | DATA or CHANNEL (both ways) | CHANNEL; DATA as LLR or BITS |
| link | PACKETS (encode), DATA (decode) | DATA; PACKETS (BYTES or MSG) |
A code transform is often several steps, so code steps take channel and data bits alike; the enforced boundary is the
link's. rp.code.Uncoded() is the code step of a link with no FEC. rp.Data(x) on a complex array is SAMPLES,
rp.Data(x, sps=1) is SYMBOLS; BitStage takes channel or data bits and keeps their form.
Data and operators¶
Data (base/data.py) wraps an array with its Meta: Fs, sps, centre frequency, group delay, stream state, and
meta.pos, the absolute position of its first item (meta.time_of(k) gives source time). Samples a source lost (a
radio's overrun, a dropped block) are counted in it, and a stage carries a gap in its input into its output positions,
so positions stay true to time. Nothing needs setting up or resetting.
| Operator | Means | On |
|---|---|---|
data * pipe, data / pipe |
encode / decode | Pipe (invertible transform) |
data + stage |
process | Stage, BitStage |
pipe * pipe, stage + stage |
a reusable Pipeline |
either |
data >> sink |
write out | Sink |
A Stage keeps its settings on the object and everything that carries between blocks in new_state(meta), held by the
stream; step(samples, st, meta) processes a block and sets meta.op. SCOPE is STREAM (state crosses frames) or
FRAME. Stream holds states, estimates (stream.est[name]), detections (det), control (stream.control) and load
statistics. data + rp.Tee(a=..., b=...) runs each branch in its own stream (FM stereo L+R and L-R).
Streaming rules¶
Tested by cutting the same input differently (tests/unit/base/, per-stage tests):
- Any block length, including 0; never drop or repeat items across blocks.
- State lives in the stream state, so one stage can serve several streams.
- Whole blocks through
rp.base.rpps.align(ctx, key, x, block, pad): the leftover waits, a flush pads (encode) or drops and reports (decode). - Positions are absolute; a stage that drops or inserts items anchors it.
- Feedforward estimators follow the rules in
rpps.sync(windows at absolute positions, tracked across windows). - Soft information flows down; sync on channel bits passes LLRs through.
Modules:
| Name | Description |
|---|---|
control |
The control path, as operators see it (rpps.profile.control) |
data |
Data containers |
frequency |
Frequencies as numbers or as people write them |
kernel |
Kernels: the batch face of an operator, beside the operator it belongs to (rpps.parallel) |
meta |
Rate information and stream state that travel with data |
rpps |
RPPS parent classes |
types |
Type tags every block of data carries (see rpps.base, Type tags) |
control ¶
The control path, as operators see it (rpps.profile.control)
A header step (a physical header, a link header) and a frame sync publish what they decoded, with the absolute stream
position it applies from; a step that drops or inserts items anchors positions. They live on meta.stream.control.
What a profile does with them (tables, controls, runners) is rpps.profile.control.
Both directions:
publish(meta, op, {"modcod": 12, "pilots": 1}, at=<input position>, out=<index in this call's output>, span=None,
group=None)
at: absolute position in the op's input from which the fields apply. out: where that is in what the op gives in
this call (None: nothing it gives is affected). span: input items the fields hold for, after which they go back
to the controls' defaults (a PLCP rate holds for its payload only). group: publications made from one header
share it (default: `at`), so a runner that re-runs keeps them together
anchor(meta, op, at, out, rate=None)
a step that drops or inserts items says which output item an input position became, so positions translate
exactly through it
emit(meta, op, kind, fields, bits=None, ok=None, at=<input position>, frame=None, parts=None)
a decoded frame, for whoever reads the profile's messages (rpps.profile.message): its fields, its payload bits,
whether its check passed, from absolute position `at` in the op's input (where the frame starts). frame: the
whole frame's bits as received (header, payload, FCS) when the op has more than the payload; parts: where each
part is in them, {"header" | "payload" | "fcs" | ...: (first bit, bits)}. The op's `check_name`, when it has
one, names the check behind `ok`
Classes:
| Name | Description |
|---|---|
Control |
The control path of one stream ( |
Functions:
| Name | Description |
|---|---|
of |
The stream's Control, made on first use |
publish |
Fields an op decoded (or was given, transmitting), applying from absolute input position |
anchor |
Absolute input position |
emit |
A decoded frame (see module): kind None takes the profile step's id |
Control ¶
The control path of one stream (stream.control)
published, anchors, messages: what operators reported since the runner last collected them (the runner empties these) log: every change the runner accepted, in order: {"step", "fields", "at", "targets"} reports: what did not go as announced: late changes re-run or dropped, restarts, fields with no table row rerun: re-runs done; buffer: the re-run buffer's current size, in items at its first step
Methods:
| Name | Description |
|---|---|
fields |
The field sets published so far, oldest first: [(step id, fields, position)] |
Source code in src/rpps/base/control.py
fields ¶
The field sets published so far, oldest first: [(step id, fields, position)]
of ¶
publish ¶
Fields an op decoded (or was given, transmitting), applying from absolute input position at onward (see module)
Source code in src/rpps/base/control.py
anchor ¶
Absolute input position at became item out of this call's output (a step that drops or inserts items)
emit ¶
A decoded frame (see module): kind None takes the profile step's id
Source code in src/rpps/base/control.py
data ¶
Data containers
Every block carries three tags (see rpps.base.types): CAT the Category of the operation that made it last REP its representation: SAMPLES, SYMBOLS, CHANNEL bits, DATA bits, PACKETS DT its form (dtype): complex samples, LLRs, bits, bytes...
Analog samples and symbols
Mod symbols, and demodulated bits (LLRs or hard) on the way to the decoder
Digital bits and bytes
Classes:
| Name | Description |
|---|---|
Analog |
Analog data |
Mod |
(De)Modulation data |
Digital |
Digital data |
Functions:
| Name | Description |
|---|---|
Data |
Wrapper to get correct Data type, and set PP and DT |
expect |
Refuse |
Analog ¶
Bases: _Data
Analog data
Source code in src/rpps/base/data.py
Mod ¶
Bases: _Data
(De)Modulation data
Symbols (rep SYMBOLS), or demodulated bits (rep CHANNEL, or DATA from a soft-output decoder): either hard bits (MAPPED_HARD), or one LLR per bit (LLR). An LLR is log(P(bit=0)/P(bit=1)), so positive means 0 and the magnitude is the confidence.
Methods:
| Name | Description |
|---|---|
bits |
Hard decided bits, leaving this data as it is |
get_soft |
Per-bit LLRs. Hard bits give +-hard_llr if it's set, otherwise None |
to_analog |
Convert to Analog |
to_digital |
Convert to Digital |
as_hard |
Make hard decisions: bit 1 where the LLR is negative |
as_bits |
Covert to Digital as bits |
as_bytes |
Convert to Digital as bytes |
Attributes:
| Name | Type | Description |
|---|---|---|
is_soft |
Does this carry LLRs (rather than hard bits) |
Source code in src/rpps/base/data.py
bits ¶
Hard decided bits, leaving this data as it is
Source code in src/rpps/base/data.py
get_soft ¶
Per-bit LLRs. Hard bits give +-hard_llr if it's set, otherwise None
Source code in src/rpps/base/data.py
to_analog ¶
to_digital ¶
Convert to Digital
Source code in src/rpps/base/data.py
as_hard ¶
as_bits ¶
Digital ¶
Bases: _Data
Digital data
Methods:
| Name | Description |
|---|---|
is_bit |
Check if data is bits |
is_byte |
Check if data is bytes |
as_bits |
Return self as bits |
as_bytes |
Return self as bytes |
bits |
The data as bits, leaving this data as it is |
get_bytes |
Return self.data as bytes |
get_bits |
Return self.data as bits |
from_bytes |
Create Digital from bytes |
from_bits |
Create Digital from bits |
Attributes:
| Name | Type | Description |
|---|---|---|
bin |
Return binary representation |
|
hex |
Return hexadecimal implementation |
Source code in src/rpps/base/data.py
is_bit ¶
is_byte ¶
as_bits ¶
as_bytes ¶
bits ¶
get_bytes ¶
Return self.data as bytes
Source code in src/rpps/base/data.py
get_bits ¶
Return self.data as bits
Source code in src/rpps/base/data.py
from_bytes
classmethod
¶
Create Digital from bytes
Source code in src/rpps/base/data.py
from_bits
classmethod
¶
Create Digital from bits
Source code in src/rpps/base/data.py
Data ¶
Data(data, ctx=None, flush=False, Fs=None, sps=None, cf=None, stream=None, delay=0.0, t0=None) -> Digital | Analog
Wrapper to get correct Data type, and set PP and DT
bool -> bits, uint8/bytes/str -> bytes, complex64 -> samples, float -> real samples
ctx: the state of earlier data (out.ctx) to continue a stream of bits in chunks
flush: this ends the stream. Otherwise a partial last block is held for the next data; flushed, it is padded (encode) or dropped (decode)
Fs, sps, cf: sample rate [Hz], samples per symbol and centre frequency [Hz] of a signal
stream: the stream of earlier signal blocks (out.stream), which keeps the state of the stages across blocks
t0: time [s] of the stream's first item, if known (a radio's timestamp): meta.time_of then gives any item's time
Each block gets its absolute position in the stream (meta.pos): the items its stream produced before it
Source code in src/rpps/base/data.py
expect ¶
Refuse data an operator does not take: takes is the set of representations it accepts (None: anything).
Raised before any work, with what was expected
Source code in src/rpps/base/data.py
frequency ¶
Frequencies as numbers or as people write them
Classes:
| Name | Description |
|---|---|
Frequency |
A frequency in Hz. Built from a number or text: |
Frequency ¶
Bases: float
A frequency in Hz. Built from a number or text: Frequency(99.5e6), Frequency("99.5M"), Frequency("2.4 GHz"), Frequency("1e6")
It is a float, so it goes anywhere a frequency is wanted (Fs=Frequency("2.4M")).
Attributes:
| Name | Type | Description |
|---|---|---|
raw |
The frequency in Hz |
|
mult |
Divisor of the unit it is shown in (1, 1e3, 1e6, 1e9) |
|
short |
The value in its unit |
kernel ¶
Kernels: the batch face of an operator, beside the operator it belongs to (rpps.parallel)
A region frame is whole, so what an operator does to it is a function of the frame and of the parameters controls gave it: no
state across calls. A Kernel is that function over a batch of frames, one frame per row of an [N, L] array:
batch = kernel.run(xp, batch)
xp is the array module (numpy; cupy on a GPU), so a kernel is written once. A kernel is immutable once built and holds its
constants (a keystream, a permutation, a code's graph), made once for its parameters, so they can live on a device and be
exported (describe). A constant goes to a device once: self.const(xp, key, make) keeps what make() gives, as an
array of xp. Rows that cannot be processed are marked in batch.bad (with a reason) and carry zeros on: the shape of
a batch never changes with the data.
Where a batch lives: b.x is an array of xp (on a device, a device array); bad, why, code_failed, notes and
pos stay on the host (small). A kernel that needs numpy says so (where = "host", a C++ decoder, a LoopKernel): a
plan on another array module puts a ToHost before it and a ToDevice after, so every crossing is in describe().
Nothing converts implicitly: to_host(a) is the one way back.
Most kernels are array code over xp. A loop that array code does badly (LDPC's layers, the demapper's sums over points)
is a device kernel of its own: portable CUDA C that NVRTC and hiprtc compile as it is, built by device_functions when
has_device_kernels(xp); on numpy the kernel runs its host path, the reference.
An operator gives one with op.kernel(params, how) (params: its controlled parameters; how: / decode, * encode, + stage;
returns None for what it has no kernel for). A step whose operators do not is run by LoopKernel: the existing
per-frame operator, through Data. That path is also the oracle every kernel is compared with.
Classes:
| Name | Description |
|---|---|
Batch |
N frames that share a key, as one array. x: [N, L]; form: what the rows are; pos: each row's absolute input position; |
Kernel |
A batch function. Subclasses set |
ToHost |
The batch back to the host (before a kernel that needs numpy) |
ToDevice |
The batch onto the device of |
Functions:
| Name | Description |
|---|---|
to_host |
A numpy array of |
has_device_kernels |
True when |
device_functions |
The functions |
Batch
dataclass
¶
Batch(x: ndarray, form: Form, pos: list, n_in: int, bad: ndarray = None, why: dict = dict(), code_failed: ndarray = None, notes: dict = dict())
N frames that share a key, as one array. x: [N, L]; form: what the rows are; pos: each row's absolute input position; n_in: the frame length they started as; bad: rows that failed, why: {row: reason}; notes: {row: [report, ...]}
Kernel ¶
A batch function. Subclasses set name and give run; shape says the output length for an input length (None: not
known before running; given None, None), consts the arrays it was built with. where: "any" (runs on the xp it is
given) or "host" (numpy only)
Methods:
| Name | Description |
|---|---|
const |
|
describe |
A JSON-able description: what a backend (a device kernel library, an HLS generator) needs to build it |
const ¶
make() as an array of xp, made and moved once per array module and key (a constant stays on its device)
Source code in src/rpps/base/kernel.py
describe ¶
A JSON-able description: what a backend (a device kernel library, an HLS generator) needs to build it
Source code in src/rpps/base/kernel.py
to_host ¶
A numpy array of a (a device array's copy back, a.get(); a numpy array as it is)
has_device_kernels ¶
True when xp compiles and launches kernels of its own (CuPy, on CUDA or HIP); not numpy, not a pretend device
device_functions ¶
The functions names of the device kernel source (portable CUDA C: NVRTC or hiprtc compile it as it is), compiled
once per process, device and source
Source code in src/rpps/base/kernel.py
meta ¶
Rate information and stream state that travel with data
Users don't build these: give rp.Data an Fs / sps / cf and the stages take care of the rest.
Classes:
| Name | Description |
|---|---|
Rate |
Sample rate (Fs), samples per symbol (sps) and centre frequency (cf) |
Stream |
Everything that follows one source across its blocks, shared by every block (and every data derived from it) |
Meta |
The rate information of one block of data, as a stage sees it |
Functions:
| Name | Description |
|---|---|
forward |
A read-only property that reads |
timed |
fn(*args), its time charged to |
Rate ¶
Stream ¶
Everything that follows one source across its blocks, shared by every block (and every data derived from it)
the carried state of each stage (filter history, oscillator phase, loop filters...), keyed by the stage,
so a stage object is reusable and the same stage in two streams has two states
det: detection result (baud, modulation, timing, cfo...), see rpps.sync.detect
busy: seconds each operator spent on this stream's blocks (a stage's step, a pipe's encode or decode), its own time
only (what it ran inside it is the inner one's); air: seconds of signal the source produced. busy/air (load)
is the operator's share of real time: 1.0 exactly keeps up, over 1 it can't. realtime() is the one number
lanes: {thread: how many run its work at once} (a parallel region's workers); a thread not named is one
thread_of: {operator: the thread it ran on}: what realtime adds up per thread
dropped: source samples lost: a radio's overruns (Device, as pysdrlib reports them) and blocks a threaded source
discarded because the stages fell behind (Blocks.threaded(drop=True), counted at the source's rate)
pos: items the source has produced so far: the absolute position of its next block
t0: time [s] of the source's item 0, when the source knows it (a radio's timestamp); None otherwise
out_pos: items each stage has produced so far in this stream: the absolute position of its next output block
in_pos: the position each stage expects its next input block at; one further on is a gap, which the stage carries
into its own output positions
est: what sync stages estimated, by name ({"align": {...}}), for whoever wants to know (det stays Acquire's)
control: the control path (rpps.base.control.Control): fields header steps published, position anchors, and
what a profile runner did with them (applied, re-run, dropped). None until a step publishes
rx: how the source's samples were received (a pysdrlib RxContext: the chain and its LO, whether it inverts, the
reference and its correction), None when the source doesn't know; rx_conjugated: the source conjugated them
because the chain inverts (rpps.source.Source). Both survive restart
Threads (Blocks.threaded): each stage's state is used only by the thread running that stage. det and
src_sps have one writer (Acquire); gen lets blocks already on their way pick up a new sps (Meta.refresh). det
here is the latest: a stage reads its block's (Meta.det), which Acquire stamps, so a stage running behind Acquire
in another thread uses the detection its block went through with, not one made for a later block.
Methods:
| Name | Description |
|---|---|
add_air |
The source made |
load |
Share of real time each operator takes, {operator: busy/air}: 1.0 exactly keeps up, over 1 it falls behind. |
realtime |
The stream's load as one number: per thread, the sum of the loads of what ran on it (divided by the thread's |
restart |
Forget everything but the source's rate: the next block starts a new stream |
Source code in src/rpps/base/meta.py
add_air ¶
The source made seconds more of signal (a source calls this per block)
Source code in src/rpps/base/meta.py
load ¶
Share of real time each operator takes, {operator: busy/air}: 1.0 exactly keeps up, over 1 it falls behind.
window: None, since the stream started; seconds, over about the last window seconds of signal (what a live view
wants: a stage that slows down shows at once)
Source code in src/rpps/base/meta.py
realtime ¶
The stream's load as one number: per thread, the sum of the loads of what ran on it (divided by the thread's
lanes), and the busiest thread's. Serial work is one thread (the sum); Blocks.pipelined gives a thread per
stage (the slowest); a parallel region counts its workers' time over their number. <= 1 keeps up in real time.
0.0 before the source has made any signal
Source code in src/rpps/base/meta.py
restart ¶
Meta ¶
The rate information of one block of data, as a stage sees it
Fs, sps, cf, isps, Ts: the rates of the block coming in (read-only for stages)
op: the rates of the block going out. A stage changes these (meta.op.Fs /= 2), the carrier applies them
delay: group delay of the data so far [s]. A stage adds its own
stream: the Stream this block belongs to (stage state, detection)
pos: absolute position of the block's first item in the stream, counted in items at this block's rate. It does
not depend on how the stream was cut into blocks, so estimators can place their windows by it. Samples a
source lost (a radio's overrun, a dropped block) are counted: positions stay true to time across a gap
timed: pos counts this block's own items (a source's block, a stage's output), so a jump in it is a gap; a
pipe's output keeps its input's position and is not timed
flush: this block ends the stream: a stage gives out what it was holding back
det: the detection this block went through Acquire with (the stream's, stream.det, until an Acquire stamps one)
Methods:
| Name | Description |
|---|---|
time_of |
Source time [s] of item k of this block: the stream's t0, plus the position at this rate, less the group delay. |
fork |
Meta for the data a stage produces: the output rates become the input rates. Stream is shared |
refresh |
Pick up an sps learned after this block left the source |
calibrate_sps |
Declare the sps at the current stage of the chain |
state_of |
Get (creating on first use) the carried state of a stage |
Source code in src/rpps/base/meta.py
time_of ¶
Source time [s] of item k of this block: the stream's t0, plus the position at this rate, less the group delay. None when the source gave no time anchor
Source code in src/rpps/base/meta.py
fork ¶
Meta for the data a stage produces: the output rates become the input rates. Stream is shared
Source code in src/rpps/base/meta.py
refresh ¶
Pick up an sps learned after this block left the source
One thread: never needed, every block starts after the last one finished. Threaded, blocks already between the source and Acquire carry the old sps: scale the source's new one by the Fs ratio, as the stages would have.
Source code in src/rpps/base/meta.py
calibrate_sps ¶
Declare the sps at the current stage of the chain
Blocks come from the source with the source's sps, so the sps at the source is worked out through the Fs ratio (decimation/resampling scale both) and handed to the blocks that follow.
Source code in src/rpps/base/meta.py
state_of ¶
Get (creating on first use) the carried state of a stage
forward ¶
A read-only property that reads name of the object in attribute to: self.Fs is self.state.Fs
timed ¶
fn(*args), its time charged to op in stream.busy: its own time only (an operator timed inside it takes its own
off), so nothing is counted twice. stream None: run, not charged
Source code in src/rpps/base/meta.py
rpps ¶
RPPS parent classes
Classes:
| Name | Description |
|---|---|
Pipe |
Parent class for RPPS implementations |
Pipeline |
Pipes (and stages) applied in order. Build one by combining pipes: |
Stage |
A DSP stage operating on a continuous stream of blocks: |
BitStage |
A stage on a stream of bits: channel bits or data bits, as LLRs or hard bits (sync on bits: alignment, polarity) |
Tee |
The same blocks through several branches: |
Functions:
| Name | Description |
|---|---|
align |
Whole blocks of x for a stage that works on |
failed_of |
The data's |
tag_stages |
Give every Stage class defined in |
Pipe ¶
Parent class for RPPS implementations
A pipe works on data with the operators: data * pipe encodes, data / pipe decodes (and data + pipe for
stages that process a signal). Two pipes multiplied/added together give a Pipeline, a reusable chain:
link = scr * ecc * mod # scrambler, then code, then modulation
syms = bits * link # same as bits * scr * ecc * mod
bits = syms / link # the decoders, run backwards
Methods:
| Name | Description |
|---|---|
takes |
The representations (rpps.base.types.Rep) this accepts to encode (True) or decode (False); None: not checked |
encode |
Encode data |
decode |
Decode data |
Pipeline ¶
Bases: Pipe
Pipes (and stages) applied in order. Build one by combining pipes: a * b * c or a + b + c
data * pipeline: every item encodes in order. data / pipeline: every item decodes, last item first.
data + pipeline: every item processes in order (stages). Pipelines nest and flatten. A stage that splits the data
(rp.sync.Burst) makes the rest run on every piece, and the pipeline gives the list of what they made.
Source code in src/rpps/base/rpps.py
Stage ¶
Bases: Pipe
A DSP stage operating on a continuous stream of blocks: block + stage
Settings (constructor args) live on the stage. Anything that must carry from one block to the
next lives in a state object returned by new_state, kept in the stream the block belongs to, so the stage
itself stays reusable. Stages never see Meta being created or reset: the data carries it.
A stage must accept any block length (including 0), and neither drop nor repeat samples across blocks.
Methods:
| Name | Description |
|---|---|
new_state |
Create this stage's carried state |
step |
Process a block, returning the output. Set meta.op (the output rates) and add to meta.delay as needed |
takes |
Representations this stage processes (rpps.base.types.Rep): samples and symbols |
BitStage ¶
Bases: Stage
A stage on a stream of bits: channel bits or data bits, as LLRs or hard bits (sync on bits: alignment, polarity)
step gets a numpy array: float LLRs (positive means 0) or bools, and gives the same form back. The output keeps the
input's representation and form; state carries across blocks as for any stage, so any block length works.
Tee ¶
Bases: Pipe
The same blocks through several branches: data + Tee(name=stage_or_pipeline, ...) gives {name: data out}
out = mpx + rp.Tee(mono=audio, stereo=pilot + audio) # one `audio` pipeline serves both
left, right = out["mono"].data + out["stereo"].data, ...
Each branch runs in a stream of its own (kept in the stream's state under the tee), so a stage can sit in several
branches, each with its state, and every branch is as independent of the block cut as a chain is. A branch's
estimates and states are on its output (out["stereo"].state(pilot), out["stereo"].stream.est). A tee ends a
chain: what follows takes one branch's output.
Source code in src/rpps/base/rpps.py
align ¶
Whole blocks of x for a stage that works on block items at a time
ctx: the stream state (a dict this call updates) holding the leftover of the previous call under key.
A leftover waits for the next call. Only when the stream is flushed is it zero padded up to a whole block
(pad: encoding) or dropped (decoding, where padding would invent data).
Source code in src/rpps/base/rpps.py
failed_of ¶
The data's failed mask (True where a decoder before could not decode it), or None: nothing known to have failed
tag_stages ¶
Give every Stage class defined in package (a module or package name, submodules included) the Category category,
unless the class sets its own. In this architecture the package is the category (rpps.base)
Source code in src/rpps/base/rpps.py
types ¶
Type tags every block of data carries (see rpps.base, Type tags)
Category the kind of operation that made the data last
Rep where in the chain the data is: samples -> symbols -> channel bits -> data bits -> packets
dtype how the values are stored (the form): complex samples, LLRs, bits, bytes...
Rep and dtype are separate because forms cross representations: LLRs and hard bits exist both before the decoder (channel bits) and after it (data bits).
Classes:
| Name | Description |
|---|---|
Category |
The kind of operation that produced the data |
Rep |
Where in the chain the data is |
dtype |
Data Type |