CommPy¶
CommPy is an open source package implementing digital communications algorithms in Python using NumPy, SciPy and Matplotlib.
Available Features¶
Channel Coding¶
- Encoder for Convolutional Codes (Polynomial, Recursive Systematic). Supports all rates and puncture matrices.
- Viterbi Decoder for Convolutional Codes (Hard Decision Output).
- MAP Decoder for Convolutional Codes (Based on the BCJR algorithm).
- Encoder for a rate-1/3 systematic parallel concatenated Turbo Code.
- Turbo Decoder for a rate-1/3 systematic parallel concatenated turbo code (Based on the MAP decoder/BCJR algorithm).
- Binary Galois Field GF(2^m) with minimal polynomials and cyclotomic cosets.
- Create all possible generator polynomials for a (n,k) cyclic code.
- Random Interleavers and De-interleavers.
Channel Models¶
- SISO Channel with Rayleigh or Rician fading.
- MIMO Channel with Rayleigh or Rician fading.
- Binary Erasure Channel (BEC)
- Binary Symmetric Channel (BSC)
- Binary AWGN Channel (BAWGNC)
Filters¶
- Rectangular
- Raised Cosine (RC), Root Raised Cosine (RRC)
- Gaussian
Impairments¶
- Carrier Frequency Offset (CFO)
Modulation/Demodulation¶
- Phase Shift Keying (PSK)
- Quadrature Amplitude Modulation (QAM)
- OFDM Tx/Rx signal processing
Sequences¶
- PN Sequence
- Zadoff-Chu (ZC) Sequence
Utilities¶
- Decimal to bit-array, bit-array to decimal.
- Hamming distance, Euclidean distance.
- Upsample
- Power of a discrete-time signal
Reference¶
Channel Coding (commpy.channelcoding
)¶
Galois Fields¶
GF (x, m) |
Defines a Binary Galois Field of order m, containing n, where n can be a single element or a list of elements within the field. |
Algebraic Codes¶
cyclic_code_genpoly (n, k) |
Generate all possible generator polynomials for a (n, k)-cyclic code. |
Convolutional Codes¶
Trellis (memory, g_matrix[, feedback, code_type]) |
Class defining a Trellis corresponding to a k/n - rate convolutional code. |
conv_encode (message_bits, trellis[, …]) |
Encode bits using a convolutional code. |
viterbi_decode (coded_bits, trellis[, …]) |
Decodes a stream of convolutionally encoded bits using the Viterbi Algorithm |
Turbo Codes¶
turbo_encode (msg_bits, trellis1, trellis2, …) |
Turbo Encoder. |
map_decode (sys_symbols, non_sys_symbols, …) |
Maximum a-posteriori probability (MAP) decoder. |
turbo_decode (sys_symbols, non_sys_symbols_1, …) |
Turbo Decoder. |
LDPC Codes¶
get_ldpc_code_params (ldpc_design_filename) |
Extract parameters from LDPC code design file. |
ldpc_bp_decode (llr_vec, ldpc_code_params, …) |
LDPC Decoder using Belief Propagation (BP). |
Interleavers and De-interleavers¶
RandInterlv (length, seed) |
Random Interleaver. |
Channel Models (commpy.channels
)¶
SISOFlatChannel ([noise_std, fading_param]) |
Constructs a SISO channel with a flat fading. |
MIMOFlatChannel (nb_tx, nb_rx[, noise_std, …]) |
Constructs a MIMO channel with a flat fading based on the Kronecker model. |
bec (input_bits, p_e) |
Binary Erasure Channel. |
bsc (input_bits, p_t) |
Binary Symmetric Channel. |
awgn (input_signal, snr_dB[, rate]) |
Addditive White Gaussian Noise (AWGN) Channel. |
Pulse Shaping Filters (commpy.filters
)¶
rcosfilter (N, alpha, Ts, Fs) |
Generates a raised cosine (RC) filter (FIR) impulse response. |
rrcosfilter (N, alpha, Ts, Fs) |
Generates a root raised cosine (RRC) filter (FIR) impulse response. |
gaussianfilter (N, alpha, Ts, Fs) |
Generates a gaussian filter (FIR) impulse response. |
rectfilter (N, Ts, Fs) |
Generates a rectangular filter (FIR) impulse response. |
Impairments (commpy.impairments
)¶
add_frequency_offset (waveform, Fs, delta_f) |
Add frequency offset impairment to input signal. |
Modulation Demodulation (commpy.modulation
)¶
PSKModem (m) |
Creates a Phase Shift Keying (PSK) Modem object. |
QAMModem (m) |
Creates a Quadrature Amplitude Modulation (QAM) Modem object. |
mimo_ml (y, h, constellation) |
MIMO ML Detection. |
-
class
PSKModem
(m)¶ Creates a Phase Shift Keying (PSK) Modem object.
-
class
QAMModem
(m)¶ Creates a Quadrature Amplitude Modulation (QAM) Modem object.
-
mimo_ml
(y, h, constellation)¶ MIMO ML Detection.
Parameters: - y (1D ndarray of complex floats) – Received complex symbols (shape: num_receive_antennas x 1)
- h (2D ndarray of complex floats) – Channel Matrix (shape: num_receive_antennas x num_transmit_antennas)
- constellation (1D ndarray of complex floats) – Constellation used to modulate the symbols
Sequences (commpy.sequences
)¶
pnsequence (pn_order, pn_seed, pn_mask, …) |
Generate a PN (Pseudo-Noise) sequence using a Linear Feedback Shift Register (LFSR). |
zcsequence (u, seq_length) |
Generate a Zadoff-Chu (ZC) sequence. |
Utilities (commpy.utilities
)¶
dec2bitarray (in_number, bit_width) |
Converts a positive integer to NumPy array of the specified size containing bits (0 and 1). |
bitarray2dec (in_bitarray) |
Converts an input NumPy array of bits (0 and 1) to a decimal integer. |
hamming_dist (in_bitarray_1, in_bitarray_2) |
Computes the Hamming distance between two NumPy arrays of bits (0 and 1). |
euclid_dist (in_array1, in_array2) |
Computes the squared euclidean distance between two NumPy arrays |
upsample (x, n) |
Upsample the input array by a factor of n |
signal_power (signal) |
Compute the power of a discrete time signal. |