comnum.CcsdsTurbo#

class comnum.CcsdsTurbo(k, rate='1/3', *, iterations=8, max_log=False)#

A turbo code of CCSDS 131.0-B-5, Sec. 6: two 16-state recursive encoders (G0 = 23, G1 = 33, G2 = 25, G3 = 37 in octal), the permutation of Sec. 6.3 g) for k = 1784, 3568, 7136 or 8920 bits, 4 termination steps, the outputs of Sec. 6.4 at rates 1/2, 1/3, 1/4 and 1/6, n = (k + 4)/r (Table 6-2); decoded by iterative log-MAP decoding.

Parameters:
  • k (int) – information bits per codeword.

  • rate (str) – "1/2", "1/3", "1/4" or "1/6".

  • iterations (int) – decoding iterations.

  • max_log (bool) – max-log-MAP instead of log-MAP.

Raises:

ValueError – for another k or rate.

Examples

>>> import comnum, numpy as np
>>> code = comnum.CcsdsTurbo(1784, "1/3")
>>> (code.k, code.n)
(1784, 5364)
>>> b = comnum.bits(1784, comnum.Rng(2))
>>> bool(np.array_equal(code.decode(2.0 - 4.0 * code.encode(b)), b))
True
decode(llr)#

Decode whole codewords of LLRs.

Parameters:

llr (array_like) – a multiple of n LLRs (positive for a 0).

Returns:

k bits per codeword (uint8).

Return type:

numpy.ndarray

Raises:

ValueError – for an input that is not an array of numbers of the expected shape.

encode(bits)#

Encode whole codewords.

Parameters:

bits (array_like) – a multiple of k bits.

Returns:

n bits per codeword (uint8).

Return type:

numpy.ndarray

Raises:

ValueError – for an input that is not an array of bits of the expected shape.

k#

Information bits per codeword.

Type:

int

n#

Transmitted bits per codeword, (k + 4)/r.

Type:

int

permutation#

The permutation of the second encoder, π(s) for s = 0, …, k − 1 (int64): the encoder b reads the bit π(s) at step s.

Type:

numpy.ndarray

rate#

The rate.

Type:

str