comnum.CcsdsConvolutional#

class comnum.CcsdsConvolutional(rate='1/2')#

The convolutional code of CCSDS 131.0-B-5, Sec. 3: constraint length 7, G1 = 171 then G2 = 133 (octal), G2 inverted at rate 1/2, punctured by Table 3-1 at rates 2/3, 3/4, 5/6 and 7/8 (C1 and C2 sent in the order of the table); the encoder starts in state 0 and is not terminated, the decoder is the soft Viterbi decoder of the whole stream.

Parameters:

rate (str) – "1/2", "2/3", "3/4", "5/6" or "7/8".

Raises:

ValueError – for another rate.

Examples

The first symbols of a one followed by zeros at rate 1/2: C1 follows G1 = 1111001, C2 the inverse of G2 = 1011011:

>>> import comnum, numpy as np
>>> comnum.CcsdsConvolutional("1/2").encode([1, 0, 0])
array([1, 0, 1, 1, 1, 0], dtype=uint8)
>>> code = comnum.CcsdsConvolutional("3/4")
>>> b = comnum.bits(300, comnum.Rng(3))
>>> c = code.encode(b)
>>> len(c)
400
>>> bool(np.array_equal(code.decode(2.0 - 4.0 * c, 300), b))
True
decode(llr, n_bits)#

The input bits of the channel LLRs of encode().

Parameters:
  • llr (array_like) – the LLRs of the channel symbols (positive for a 0).

  • n_bits (int) – the number of input bits.

Returns:

n_bits bits (uint8).

Return type:

numpy.ndarray

Raises:

ValueError – if the number of LLRs is not that of n_bits bits.

encode(bits)#

The channel symbols of a stream of bits.

Parameters:

bits (array_like) – the input bits (a multiple of the puncturing period).

Returns:

the channel symbols (uint8).

Return type:

numpy.ndarray

Raises:

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

rate#

The rate.

Type:

str