Symbol
rpps.symbol ¶
Modulation: the symbol layer (channel bits <-> symbols, * and /); the waveform layer is rpps.wave
A signal is built from explicit pieces, and a new kind of signal is a new config or a new piece, not a new special case.
| Layer | Pieces | Operator | What flows |
|---|---|---|---|
Symbol (rp.symbol; codes from rp.sequence) |
Constellation, Differential, Spread, Carriers |
* encodes, / decodes |
bits, symbols, chips (a Pipe each; decoding ends in LLRs) |
Waveform (rp.wave; pulses from rp.signal.filters.load("pulse/...")) |
Shape / Matched, Stagger, FM, FMDemod |
+ |
symbols and samples (a streaming Stage each; any block length) |
Constellations¶
A constellation is a set of points and the ways of labelling them with bits. PSK, QAM, APSK and ASK are generators
(rp.symbol.PSK(8), rp.symbol.QAM(16), rp.symbol.generate("64QAM")); anything else is a config file
(config/constellation/
{"points": [{"mag": 1, "pha": 45}, {"re": 0, "im": 2}, [-1.5, 0]],
"maps": [{"map": [0, 1, 3, 2], "comment": "Grey"}]}
maps[i].map[point] is the value (bits, first bit most significant) the point carries. Points are scaled to unit mean
power unless "normalize": false. The first map is also turned by every rotation the points allow, with and without
spectral inversion (rp.symbol.load("psk/qpsk", "R090 inverted")): the maps a receiver has to try when it does not know
the carrier phase or the IQ sense. Shapes and definitions are separate: DVB-S2's 16APSK is
rp.symbol.load("apsk/dvbs2_16apsk", rate="3/4"), not generate("16APSK").
Differential coding¶
Explicit: bits * rp.symbol.load("psk/bpsk") * rp.symbol.Differential() is DBPSK; the constellation's points are then the
phase changes. 802.11b DQPSK is psk/qpsk_axes + Differential(); pi/4-DQPSK the ordinary 45 degree psk/qpsk +
Differential(). Bit-level differential coding (NRZ-M, NRZ-I) is rp.code.Line.
Frame structure¶
Known structure among the symbols of a frame (rpps.symbol.frame), restarted at each frame start a profile gives it:
Header: known symbols then a short code carrying fields (config/header/physical,rp.symbol.load_header("dvbs2_pl")). Receiving it decodes the fields (every code word tried, soft) and publishes them for the profile; transmitting it builds them.Pilots: a block of pilots after every few slots (DVB-S2: 36 after every 16 slots of 90).PhaseScramble: each symbol turned by a multiple of 90 degrees from a binary sequence (DVB-S2 PL scrambling).
Recipes¶
Each is exercised in tests/unit/wave/test_recipes.py and tests/unit/wave/test_wave.py. Shaping needs the symbols' rate, so the
bits say theirs: bits = rp.Data(b, Fs=1e6, sps=1).
# 802.11b 1 Mb/s: DBPSK, Barker-11, then 11 Mcps shaped as you like
chips = bits * rp.symbol.load("psk/bpsk") * rp.symbol.Differential() * rp.symbol.Spread(rp.sequence.load("barker11"))
# O-QPSK (half-sine pulses, Q half a symbol late; MSK when the symbols are unit QPSK)
halfsine = rp.signal.filters.load("pulse/halfsine/halfsine")
wave = bits * rp.symbol.load("psk/qpsk") + rp.wave.Shape(8, halfsine) + rp.wave.Stagger()
# 802.15.4 2.4 GHz: 4 bits pick a 32-chip sequence, even chips on I, odd on Q
wave = bits * rp.symbol.Spread(rp.sequence.load("ieee802154_2450"), pair=True) + rp.wave.Shape(4, halfsine) + rp.wave.Stagger()
# GFSK (Bluetooth LE: BT 0.5, h 0.5): levels from an ASK constellation, a pulse, a frequency modulator
c = rp.symbol.ASK(2)
wave = bits * c + rp.wave.Shape(8, rp.signal.filters.load("pulse/gaussian/bt0p5")) + rp.wave.FM(0.5, c.min_distance)
levels = wave + rp.wave.FMDemod(rp.wave.fm_gain(0.5, 8, c.min_distance)) # then integrate over each symbol and sample
Notes¶
- BPSK: \(P_b = Q(\sqrt{2E_b/N_0}) = \tfrac12 \text{erfc}(\sqrt{E_b/N_0})\); QPSK (Gray) has the same bit error rate per \(E_b/N_0\), O-QPSK with matched filters too.
- O-QPSK delays Q by half a symbol, so I and Q never change together and the phase moves by at most 90 degrees at a time. With half-sine pulses \(p(t) = \sin(\pi t/T)\) on both rails the envelope is constant: it is MSK.
Modules:
| Name | Description |
|---|---|
constellation |
Constellations: a set of points and the bit maps that say which bits each point carries |
despread |
|
differential |
|
frame |
Known structure among the symbols of a frame (rpps.symbol): physical headers, pilot blocks, phase scrambling |
kernels |
Batch kernels of the symbol operators: |
mapping |
Bit maps of a constellation: which value (bits, first bit most significant) each point carries, and the maps a receiver that |
modulation |
|
ofdm |
|
serial |
Constellations: config/constellation/[ |
shapes |
Constellation generators: points (unit mean power) and the labels that go with them |
spread |
|
constellation ¶
Constellations: a set of points and the bit maps that say which bits each point carries
A constellation is data, not code: any point set with any labelling is one, from config/constellation (rp.symbol.load("QPSK")) or
built from points (rp.symbol.Constellation(points, maps)). PSK, QAM, APSK and ASK are generators of such point sets.
Classes:
| Name | Description |
|---|---|
Constellation |
Symbols from bits and back: |
Functions:
| Name | Description |
|---|---|
PSK |
M points on the unit circle with a Gray map; offset: the first point's phase [rad], default pi/M (QPSK at 45 degrees), |
QAM |
Square (4, 16, 64, 256) and cross (32, 128, 512) QAM; square sizes are Gray, cross sizes as close as a cross allows |
APSK |
Amplitude-phase keying on rings: |
ASK |
Amplitude levels on the real axis: |
Constellation ¶
Bases: Modulation
Symbols from bits and back: bits * c maps bits to points, symbols / c gives one LLR per bit
c = rp.symbol.load("QPSK") # a definition, or a generated one ("16QAM")
syms = bits * c
llr = syms / c # log(P(0)/P(1)), positive means 0
complex points. They are scaled to unit mean power (what the noise estimate and the LLR scale assume) unless
normalize is False. The number must be a power of two; a point carries log2(number) bits.
maps: the ways of labelling the points: Mapping objects, or (labels, comment), or just labels. labels[point] is the value
(bits, first bit most significant) the point carries. The first map is the one used unless mapping picks another.
A map with a turn (radians; "rotate" in degrees in a definition) uses the points turned by it: a standard that
labels the same set turned (DVB-S2 8PSK at k45 degrees on 8PSK at 22.5 + k45) is a map, not another constellation.
Such maps are in turned, picked by name; maps holds the ones on the points as given. blind_maps: maps, then
each turned map with every turn and inversion of it the points allow, what a blind search tries.
The first map is also turned by every rotation the points allow, with and without spectral inversion (see .maps), the
maps a receiver that does not know the carrier phase or the IQ sense has to try. No maps: the points in order, 0, 1, 2...
mapping: which map to use: an index into maps, words of its comment ("R090", "R090 inverted"), a Mapping, or labels
Methods:
| Name | Description |
|---|---|
turned_name |
The name of the turned map |
takes |
Encodes channel bits (data bits too: a link with no channel code), decodes symbols |
control |
Become another constellation ( |
kernel |
The batch demapper, for the constellation as |
pos_rate |
Bits per symbol decoding, symbols per bit encoding (rpps.profile positions) |
set_mapping |
Choose the bit mapping: an index into |
labels |
Bits of every point under the current map: (points, bits per symbol), first bit first |
modulate |
Bits to symbols (complex64). A partial last symbol is padded with zeros |
estimate_noise |
Noise variance E|n|^2 of received symbols (assumes the constellation has unit mean power and the gain is right) |
llr |
Per-bit log-likelihood ratios of received symbols, log(P(bit=0)/P(bit=1)), positive means 0 |
draw_refs |
Draw the points with their labels (and the unit circle) |
load |
{"base": "constellation", "points": [...] or "rings": [...], "rotate": 0, "maps": [{"map": [...], "comment": "..."}], "normalize": true} |
Attributes:
| Name | Type | Description |
|---|---|---|
order |
Number of points |
|
min_distance |
Distance between the two closest points |
Source code in src/rpps/symbol/constellation.py
turned_name ¶
The name of the turned map m (one of blind_maps) is a turn of ("DVB-S2"), as load(name, mapping) takes it;
None for a map on the points as given
takes ¶
Encodes channel bits (data bits too: a link with no channel code), decodes symbols
control ¶
Become another constellation (name, as rp.symbol.load takes it, with the definition's params, a dict) and/or
use another of its maps, from here on: what a header that changes the modulation does. Nothing else carries over,
so it applies between symbols
Source code in src/rpps/symbol/constellation.py
kernel ¶
The batch demapper, for the constellation as params (live parameters) make it; encoding has none yet
Source code in src/rpps/symbol/constellation.py
pos_rate ¶
Bits per symbol decoding, symbols per bit encoding (rpps.profile positions)
set_mapping ¶
Choose the bit mapping: an index into maps, words of its comment ("R090", "R090 inverted"), a Mapping, or a list of labels.
A constellation starts on its first map, so this is only needed for another one
Source code in src/rpps/symbol/constellation.py
labels ¶
Bits of every point under the current map: (points, bits per symbol), first bit first
modulate ¶
Bits to symbols (complex64). A partial last symbol is padded with zeros
Source code in src/rpps/symbol/constellation.py
estimate_noise ¶
Noise variance E|n|^2 of received symbols (assumes the constellation has unit mean power and the gain is right)
Expectation-maximisation over the Gaussian mixture of the constellation points
Source code in src/rpps/symbol/constellation.py
llr ¶
Per-bit log-likelihood ratios of received symbols, log(P(bit=0)/P(bit=1)), positive means 0
complex noise variance E|n|^2 of the symbols, estimated from them when None (the demodulator
always does; passing it is for tests). LLRs are only calibrated when this is right: decoders that are scale-invariant (Viterbi, min-sum LDPC) don't care, log-MAP decoders do
maxlog: use the nearest point of each bit value rather than summing over all of them
Returns a flat array, symbol after symbol, bits in the order modulate takes them. One implementation with the
batch demapper (rpps.math.demap): a frame in a batch comes out as it does alone
Source code in src/rpps/symbol/constellation.py
draw_refs ¶
Draw the points with their labels (and the unit circle)
Source code in src/rpps/symbol/constellation.py
load
staticmethod
¶
{"base": "constellation", "points": [...] or "rings": [...], "rotate": 0, "maps": [{"map": [...], "comment": "..."}], "normalize": true}
A point is {"mag": 1, "pha": 45} (phase in degrees), {"re": 0.7, "im": -0.7} or [re, im]. A ring is {"n": 12, "mag": 2.85, "pha": 15}: n points of magnitude mag (default 1), the first at pha degrees (default 180/n, so a 4-point ring is QPSK at 45 degrees) and the rest evenly round, counter-clockwise; rings are listed innermost first and the points come out ring by ring, so a map indexes them in that order (PSK is one ring, APSK several). rotate: degrees added to every point's phase (QPSK on the axes is QPSK rotated by -45) A map may say "rotate" too: degrees the points are turned by while that map is used (DVB-S2 8PSK on 8PSK)
Source code in src/rpps/symbol/constellation.py
PSK ¶
M points on the unit circle with a Gray map; offset: the first point's phase [rad], default pi/M (QPSK at 45 degrees),
0 for BPSK (+-1, as load("psk/bpsk"))
Source code in src/rpps/symbol/constellation.py
QAM ¶
Square (4, 16, 64, 256) and cross (32, 128, 512) QAM; square sizes are Gray, cross sizes as close as a cross allows
APSK ¶
Amplitude-phase keying on rings: APSK(16) is 4+12, APSK(32) 4+12+16; or give the rings, APSK(rings=(8, 8))
ratios: radius of the outer rings over the innermost
Source code in src/rpps/symbol/constellation.py
ASK ¶
Amplitude levels on the real axis: ASK(2) is on-off keying, ASK(4) has four Gray levels; bipolar: symmetric about zero
(PAM, the default for M > 2) rather than 0..1
Source code in src/rpps/symbol/constellation.py
despread ¶
Classes:
| Name | Description |
|---|---|
Despread |
Despread a direct-sequence signal: one value per code period, the correlation with the code |
Functions:
| Name | Description |
|---|---|
correlate |
Correlate whole code periods of x (len a multiple of code.length*sps) with every sequence of the code: (periods, code.count). |
Despread ¶
Bases: Stage
Despread a direct-sequence signal: one value per code period, the correlation with the code
The input is at sps samples per chip (from the stream's sps, or the argument), aligned to the code: the first
offset samples (a code phase from acquisition) are skipped, then every N chips are one period. Output rates:
Fs / (N*sps), 1 sample per symbol.
code: a Code. index: which of its sequences to correlate with (a set has more than one; for the strongest of a set
use correlate and take the argmax). offset: samples to skip at the start of the stream. sps: samples per chip
Source code in src/rpps/symbol/despread.py
correlate ¶
Correlate whole code periods of x (len a multiple of code.length*sps) with every sequence of the code: (periods, code.count). Each correlation is normalised, so a signal that is the sequence times a symbol gives that symbol
Source code in src/rpps/symbol/despread.py
differential ¶
Classes:
| Name | Description |
|---|---|
Differential |
Differential phase coding of symbols: each one is sent as the phase change from the one before |
Differential ¶
Bases: Modulation
Differential phase coding of symbols: each one is sent as the phase change from the one before
syms = bits * constellation * Differential() # the constellation's points are phase changes
bits = syms / Differential() / constellation
The receiver needs no carrier phase, only that it holds over two symbols (a constant phase offset cancels). DBPSK is BPSK (points 1, -1: bit 1 turns the phase by 180 degrees); DQPSK is QPSK, the points on the axes for 802.11b (config/constellation/psk/qpsk_axes) or at 45 degrees for pi/4-DQPSK (psk/qpsk itself), whose phase moves by an odd multiple of 45 degrees every symbol.
The sent symbols have unit magnitude (the phase is what is coded). The phase before the first symbol is 0, so that one symbol of a
stream decodes right only when the carrier phase is too; a decoder joined mid-stream is right from its second symbol.
Each received symbol is multiplied by the conjugate of the one before (the noncoherent detector): the phase change, with
each symbol weighted by its own reliability, as the demapper's LLRs want. Dividing instead (y/prev) gives the same hard
decisions, but a weak prev blows the noise up: measured DQPSK into a K=7 Viterbi decoder, BER 5e-3 dividing against
1.6e-5 at Eb/N0 7 dB (over 2 dB). The phase cancels; the signal comes out at the input's amplitude squared, so the input
is at unit amplitude as for any demapper (the hard decisions don't depend on it).
Source code in src/rpps/symbol/modulation.py
frame ¶
Known structure among the symbols of a frame (rpps.symbol): physical headers, pilot blocks, phase scrambling
These work frame by frame. A frame starts wherever a profile applies a change to them (rpps.profile.control): a frame sync publishes each frame's start, a header publishes what follows it, and each step restarts its frame there. Used on their own, a stream starts on a frame.
Header known symbols (a preamble), then a short block code carrying fields: decoded and published on
receive, built from the frame's fields on transmit (DVB-S2 PLHEADER: SOF + PLS)
Pilots a block of known symbols after every few slots: removed on receive, inserted on transmit
PhaseScramble every symbol turned by a multiple of a step, the multiple from a binary sequence, restarting each
frame (DVB-S2 PL scrambling)
A header is a definition: config/header/physical/rp.symbol.load_header("dvbs2_pl")
{"base": "header", "type": "physical", "comment": "...", "ref": "...",
"constellation": "bpsk", "phase": 45, "rotate": 90, symbol k is the point turned by phase + k*rotate degrees,
"cycle": 2, k counted modulo cycle (pi/2-BPSK: 0, 90, 0, 90...)
"known": {"bits": "0x18D2E82", "n": 26}, the preamble, first bit first
"code": {"n": 64, "rows": ["0x...", ...], generator rows, one per message bit, n bits each, and
"scramble": "0x..."}, a mask XOR'd onto every code word
"fields": [{"name": "modcod", "bits": 5}, ...], the message, first field first, most significant bit first
"turn": {"field": "s2x", "degrees": 90}, optional: a message with this one-bit field set has its
code word sent turned this much more (DVB-S2X's MODCODs)
"max_errors": 16} receive: a header with more bit errors is refused
Classes:
| Name | Description |
|---|---|
Header |
A physical header at the start of every frame: known symbols, then a code word whose message is the fields |
Pilots |
Blocks of known pilot symbols among a frame's data: removed on receive, inserted on transmit |
PhaseScramble |
Every symbol of a frame turned by step * R(i) degrees, R(i) = sum_j 2**(J-1-j) z(i + offsets[j]) for a binary |
Marker |
Known symbols at the start of every frame (a symbol-level sync word: a Zadoff-Chu preamble, a word already mapped) |
Puncture |
Symbols at fixed places of every period of a frame, removed on receive and inserted on transmit: P25's status |
Functions:
| Name | Description |
|---|---|
turns |
exp(j(phase + k*rotate)) in degrees for symbols k = start .. start+n-1, k modulo cycle when given |
rotating |
Symbols of bits on a constellation turned by |
pilot_layout |
(symbols in the frame, start of each pilot block): |
Header ¶
Header(name, constellation, phase, rotate, known, rows, n, scramble, fields, max_errors=None, cycle=None, turn=None)
Bases: _Frame
A physical header at the start of every frame: known symbols, then a code word whose message is the fields
rx: frame -> payload. Each frame's header is decoded (soft, every message tried: the code is short) and its fields
published from the payload's first symbol (rp.base.control.publish). A header with more than `max_errors` bit errors
is refused, and the frame dropped. Its estimates are in stream.est[name]: frames, refused, last errors. Each header
is also emitted as a message (rpps.profile.message) from its first symbol, its fields and bit errors with it:
crc_ok True when taken, False when refused.
tx: payload -> frame, the header built from the fields as last controlled (`control(modcod=..., ...)`).
Frames start where a profile says (a frame sync before it), or at the start of the stream.
Methods:
| Name | Description |
|---|---|
words |
The symbols each message's code word is sent as, after the known part: (2^k, n) |
encode_fields |
The header's symbols for these field values |
decode_fields |
(fields, bit errors) of a header's symbols (the known part included) |
Source code in src/rpps/symbol/frame.py
words ¶
The symbols each message's code word is sent as, after the known part: (2^k, n)
Source code in src/rpps/symbol/frame.py
encode_fields ¶
The header's symbols for these field values
Source code in src/rpps/symbol/frame.py
decode_fields ¶
(fields, bit errors) of a header's symbols (the known part included)
Source code in src/rpps/symbol/frame.py
Pilots ¶
Pilots(slot=90, every=16, length=36, value=(1 + 1j) / np.sqrt(2), slots=None, pilots=True, name='pilots')
Bases: _Frame
Blocks of known pilot symbols among a frame's data: removed on receive, inserted on transmit
The frame has slots slots of slot symbols; with pilots on, a block of length pilots (each value) follows
every every slots but the last (DVB-S2: 90, 16, 36, (1+j)/sqrt2). On receive, symbols past the end of a frame are
dropped (counted in stream.est[name]["extra"]): the next frame starts where a profile says.
Methods:
| Name | Description |
|---|---|
kernel |
The batch pilot remover (decoding), for the frame layout |
Source code in src/rpps/symbol/frame.py
kernel ¶
The batch pilot remover (decoding), for the frame layout params set: pilots, and what is past the frame, dropped
Source code in src/rpps/symbol/frame.py
PhaseScramble ¶
Bases: _Frame
Every symbol of a frame turned by step * R(i) degrees, R(i) = sum_j 2**(J-1-j) z(i + offsets[j]) for a binary
sequence z (rpps.sequence), i counted from the frame start (and from 0 again every length symbols
when that is set). DVB-S2 PL scrambling: z the Gold sequence, offsets (131072, 0), step 90 degrees.
Receiving turns them back.
Methods:
| Name | Description |
|---|---|
R |
R(0..n-1) |
kernel |
The batch rotation, for a frame that starts at its first symbol ( |
Source code in src/rpps/symbol/frame.py
R ¶
R(0..n-1)
Source code in src/rpps/symbol/frame.py
kernel ¶
The batch rotation, for a frame that starts at its first symbol (control marks it) and restarts every length
Source code in src/rpps/symbol/frame.py
Marker ¶
Bases: _Frame
Known symbols at the start of every frame (a symbol-level sync word: a Zadoff-Chu preamble, a word already mapped)
rx: frame -> the symbols after the marker (a frame sync gives each frame from its preamble on); the marker's
match, |<marker, received>| / (|marker| |received|), is in stream.est[name]["match"]
tx: the marker, then the frame's symbols
symbols: the marker; or zc (a length) and the Zadoff-Chu root and shift, controlled per frame (root, shift),
or sequence (a definition with symbols), so a transmitter sends the preamble that says what its frame is.
length: symbols of a frame after the marker; None: frames as a profile's control starts them (frame).
Source code in src/rpps/symbol/frame.py
Puncture ¶
Bases: _Frame
Symbols at fixed places of every period of a frame, removed on receive and inserted on transmit: P25's status
symbol after every 35 (every 36, at [35]), counted from the frame start
rx: the frame without them; tx: the frame with `value` put in (a status symbol's level, a known point), its
last ones (after its last data symbol: P25's status symbol at 359 of 360) when the next frame starts or the
stream ends
Source code in src/rpps/symbol/frame.py
turns ¶
exp(j(phase + k*rotate)) in degrees for symbols k = start .. start+n-1, k modulo cycle when given
Source code in src/rpps/symbol/frame.py
rotating ¶
Symbols of bits on a constellation turned by phase degrees, and by rotate more each symbol (modulo cycle
symbols), counting from start (pi/2-BPSK: "bpsk", 45, 90, cycle 2)
Source code in src/rpps/symbol/frame.py
pilot_layout ¶
(symbols in the frame, start of each pilot block): slots slots of slot symbols, a block of length pilots after
every every slots but the last
Source code in src/rpps/symbol/frame.py
kernels ¶
Batch kernels of the symbol operators: Demap of a constellation, Rotate of a phase scrambler, Gather of a pilot or
header remover
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). Demap on a GPU is a device kernel of its own (DEMAP_SOURCE)
Classes:
| Name | Description |
|---|---|
Demap |
Symbols to per-bit LLRs, as |
Rotate |
Symbols turned by a fixed phasor each position: the batch of a phase scrambler, or any known rotation. |
Gather |
Symbols kept by a fixed selection of positions (pilots and headers removed): |
Demap ¶
Bases: Kernel
Symbols to per-bit LLRs, as Constellation.llr: the noise level of each row (frame) estimated from its own symbols by EM
over the points, then log(P(0)/P(1)) per bit (exact, or max-log). One row in gives bits_per_symbol LLRs per symbol
Source code in src/rpps/symbol/kernels.py
Rotate ¶
Bases: Kernel
Symbols turned by a fixed phasor each position: the batch of a phase scrambler, or any known rotation. phasors(L): the
unit phasors of a frame of L symbols, made once per length
Source code in src/rpps/symbol/kernels.py
Gather ¶
mapping ¶
Bit maps of a constellation: which value (bits, first bit most significant) each point carries, and the maps a receiver that does not know the carrier phase or the IQ sense has to try (every rotation the constellation allows, with and without spectral inversion)
An "Inverted" map is the labelling a conjugated stream reads right with: on its own it says nothing about the spectrum (a
standard's map can be a conjugate of another, DVB-S2's QPSK is "R090 Grey Inverted"). The spectrum's sense is found by
rpps.sync.Inversion (known symbols that turn) or a code on a standard's map (rpps.analysis.identify CodeDetection.inverted).
Classes:
| Name | Description |
|---|---|
Mapping |
Constellation map |
Functions:
| Name | Description |
|---|---|
symmetries |
Every (rotation [rad], conjugated) that maps the constellation onto itself, as (angle, flip, permutation) |
bit_rotations |
A constellation's turns that are bit swaps and inversions. Rotations (no conjugate) acting on its labels as a |
expand_maps |
The given maps, then the first one turned by every rotation the constellation allows and spectrally inverted |
hard_bits |
Hard bits of symbols y: the labels (values, first bit most significant) of the nearest points, as uint8 bits |
Mapping ¶
Constellation map
Methods:
| Name | Description |
|---|---|
str |
Return map values as str |
Source code in src/rpps/symbol/mapping.py
symmetries ¶
Every (rotation [rad], conjugated) that maps the constellation onto itself, as (angle, flip, permutation) A flip (spectral inversion) is applied first, then the rotation.
Source code in src/rpps/symbol/mapping.py
bit_rotations ¶
A constellation's turns that are bit swaps and inversions. Rotations (no conjugate) acting on its labels as a permutation and inversion of the bits: [(perm, flip)] with bit j of a turned point's label = bit perm[j] of the point's label, inverted where flip[j] (Gray QPSK's 90 degree turns: a swap and one bit inverted). Rotations that don't (8PSK's, most QAM's) are left out. On LLRs the same turn is new[j] = old[perm[j]] * (-1 if flip[j]): what a receive tries when the carrier's M-fold phase is unknown (rp.sync.Puncture). The identity is first.
Source code in src/rpps/symbol/mapping.py
expand_maps ¶
The given maps, then the first one turned by every rotation the constellation allows and spectrally inverted
(conjugated) with each. The point is a receiver that doesn't know the carrier phase or the IQ sense: one of
these is the map that decodes. Named R
Source code in src/rpps/symbol/mapping.py
hard_bits ¶
Hard bits of symbols y: the labels (values, first bit most significant) of the nearest points, as uint8 bits
Source code in src/rpps/symbol/mapping.py
modulation ¶
Classes:
| Name | Description |
|---|---|
Modulation |
Modulation parent class |
ofdm ¶
Classes:
| Name | Description |
|---|---|
Carriers |
OFDM carrier allocation, the symbol-transform part of OFDM: data symbols <-> the carrier values of each OFDM symbol |
Carriers ¶
Bases: Modulation
OFDM carrier allocation, the symbol-transform part of OFDM: data symbols <-> the carrier values of each OFDM symbol
carriers = rp.symbol.Carriers() # 64 carriers: 48 data, 4 pilots (802.11a layout)
wave = bits * qam * carriers + rp.wave.OFDMTx(64, 16) # transmit
syms = wave + rp.wave.OFDMRx(64, 16) + rp.sync.PilotEqualizer(carriers) / carriers # receive
Encoding puts each data_per_symbol data symbols on the data carriers, the pilots' known values on the pilot carriers
(their sign alternating from one OFDM symbol to the next), and zero on the rest: n_fft values per OFDM symbol, in FFT
bin order. Decoding takes those n_fft values back to the data symbols. Equalizing them is sync's job
(rp.sync.PilotEqualizer), and the FFT and cyclic prefix are the wave transform's (rp.wave.OFDMTx, OFDMRx).
n_fft: carriers. used: carrier numbers (-n_fft/2 .. n_fft/2 - 1, 0 is DC) that carry something, default 52 (802.11a). pilots: carriers (a subset of used) with a known value, default -21 -7 7 21. More pilots follow a longer echo.
Methods:
| Name | Description |
|---|---|
bins |
FFT bins of carrier numbers |
pilot_values |
Pilot values of OFDM symbols number |
encode |
Data symbols -> n_fft carrier values per OFDM symbol. A partial last OFDM symbol is held, or padded when flushed |
decode |
n_fft carrier values per OFDM symbol (equalized) -> the data symbols |
Source code in src/rpps/symbol/ofdm.py
bins ¶
pilot_values ¶
Pilot values of OFDM symbols number index (an array): (len(index), pilots); the sign alternates by symbol
encode ¶
Data symbols -> n_fft carrier values per OFDM symbol. A partial last OFDM symbol is held, or padded when flushed
Source code in src/rpps/symbol/ofdm.py
decode ¶
n_fft carrier values per OFDM symbol (equalized) -> the data symbols
Source code in src/rpps/symbol/ofdm.py
serial ¶
Constellations: config/constellation/[rp.symbol.load("QPSK"); physical headers:
config/header/physical/rp.symbol.load_header("dvbs2_pl")
load only loads definitions; the usual shapes by name ("16QAM", "64QAM", "16APSK", "4ASK", "OOK") come from generate, so a
DVB-S2 16APSK (load("apsk/dvbs2_16apsk", rate="2/3")) is never confused with the generic one (generate("16APSK")).
constellation {"base": "constellation",
"points": [{"mag": 1, "pha": 45}, {"re": 0.7, "im": -0.7}, [-0.7, 0.7], ...], where the points are: phase in degrees
or "rings": [{"n": 4, "mag": 1, "pha": 45}, {"n": 12, "mag": 2.85, "pha": 15}], PSK / APSK rings, innermost first
"rotate": -45, degrees added to every point
"maps": [{"map": [0, 1, 3, 2], "comment": "Grey"}, ...], the ways of labelling them with bits
"normalize": true} scale to unit mean power (default)
maps[i].map[point] is the value (bits, first bit most significant) the point carries. The first map is the default;
its turns are not listed (the code makes them, below): a map in the file is a labelling of its own (a standard's).
`rp.symbol.load(name, "R090")` picks another by index or a word of its comment, and every rotation and spectral inversion of
the first map is added (see rpps.symbol.mapping).
header {"base": "header", "type": "physical" | "link"}: known symbols then a short code carrying fields
(rpps.symbol.frame.Header), or a link header (rpps.link.header.Header): one resource, `header`
Functions:
| Name | Description |
|---|---|
load_header |
A physical header definition: |
ls |
List available modulation types: {category: [names]} |
load_or_generate |
A definition named |
init |
Initialize modulation |
generate |
Make a constellation from its name: "16QAM", "QAM64", "8PSK", "16APSK", "4ASK", "OOK"... (no definition file) |
load |
Load a constellation definition, config/constellation/ |
load_header ¶
A physical header definition: load_header("dvbs2_pl") (config/header/physical)
Source code in src/rpps/symbol/serial.py
ls ¶
List available modulation types: {category: [names]}
blind: only what the blind tools try (rp._config.ls): no definitions tagged "example", and only the selected tags (rp.select_tags)
Source code in src/rpps/symbol/serial.py
load_or_generate ¶
A definition named name, else the shape generate makes of it: for names that come out of a detector ("8PSK",
"16QAM"), where either can turn up. Code that knows which it wants calls load or generate
Source code in src/rpps/symbol/serial.py
init ¶
generate ¶
Make a constellation from its name: "16QAM", "QAM64", "8PSK", "16APSK", "4ASK", "OOK"... (no definition file)
Source code in src/rpps/symbol/serial.py
load ¶
Load a constellation definition, config/constellation/load("psk/qpsk"), load("apsk/dvbs2_16apsk", rate="3/4")
(a bare name works while unique). For the usual shapes by name use generate("16QAM").
mapping: which bit map, if not the first: an index, or a word of its comment (load("psk/qpsk", "R090"))
params: values of the definition's "params" (see rp._config.resolve)
Source code in src/rpps/symbol/serial.py
shapes ¶
Constellation generators: points (unit mean power) and the labels that go with them
A label list is in the form Mapping uses: labels[point] = the value (bits, first bit most significant) it carries.
Functions:
| Name | Description |
|---|---|
gray |
Gray code of integers |
psk |
M points round the unit circle, counter-clockwise from |
ask |
M amplitudes, evenly spaced, on the real axis (bipolar: -1..1 like PAM, otherwise 0..1 like OOK for M=2). Labels: Gray |
qam |
Square (4, 16, 64, 256...) or cross (32, 128, 512...) QAM, labels Gray per axis |
apsk |
Amplitude-phase keying on concentric rings |
gray ¶
psk ¶
M points round the unit circle, counter-clockwise from offset (default: pi/M, so QPSK sits at 45 degrees; BPSK at 0,
on the real axis, as config/constellation/psk/bpsk). Labels: Gray, going round the circle
Source code in src/rpps/symbol/shapes.py
ask ¶
M amplitudes, evenly spaced, on the real axis (bipolar: -1..1 like PAM, otherwise 0..1 like OOK for M=2). Labels: Gray
Source code in src/rpps/symbol/shapes.py
qam ¶
Square (4, 16, 64, 256...) or cross (32, 128, 512...) QAM, labels Gray per axis
Source code in src/rpps/symbol/shapes.py
apsk ¶
Amplitude-phase keying on concentric rings
rings: points per ring, innermost first, e.g. (4, 12) is 16APSK and (4, 12, 16) is 32APSK ratios: radius of each outer ring over the innermost one (default DVB-S2-like) Labels: the ring picks the top bits, Gray round the ring for the rest (not the DVB-S2 labelling, which is a config definition)
Source code in src/rpps/symbol/shapes.py
spread ¶
Classes:
| Name | Description |
|---|---|
Spread |
Direct-sequence spreading as an operator: symbols (or bits) to chips and back, one sample per chip (shape and upsample them |
Spread ¶
Bases: Modulation
Direct-sequence spreading as an operator: symbols (or bits) to chips and back, one sample per chip (shape and upsample them with the waveform stages)
chips = syms * Spread(code) # one sequence (Barker, GPS C/A): every symbol times the sequence
syms = chips / Spread(code) # correlate each code period
chips = bits * Spread(set) # a set (802.15.4): every log2(count) bits, the first the least significant, pick a sequence
llr = chips / Spread(set) # strongest correlations: one LLR per bit
pair: put even chips on I and odd chips on Q (complex chips at half the chip rate), as O-QPSK carries 802.15.4's. Decoding a set through pair needs the carrier phase removed first: the I and Q parts are taken as the two rails of chips. A single-sequence code works on symbols that need a code period of chips each; a partial period is held until the rest arrives.
Methods:
| Name | Description |
|---|---|
takes |
A set encodes channel bits (or data bits, uncoded); one sequence encodes symbols. Both decode chips (symbols) |
pos_rate |
Output items per input item (rpps.profile positions): chips per symbol or bits, or the other way round |