Convolutional Encoder
__init__(G=np.array([[121, 91]]))
Inicialize the Convolutional Encoder with the given polynomials \(G\). The default polynomials are \(G_0 = 121_{10}\) and \(G_1 = 91_{10}\).
The Convolutional Encoder can be represented by the block diagram below that corresponds to the shift register organization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
ndarray
|
Tuple of generator polynomials \(G\). |
array([[121, 91]])
|
Examples:
>>> import argos3
>>> import numpy as np
>>>
>>> ut = np.random.randint(0, 2, 30)
>>> encoder = argos3.EncoderConvolutional(G=np.array([[121, 91]]))
>>> vt0, vt1 = encoder.encode(ut)
>>>
>>> print(ut)
[1 0 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1]
>>>
>>> decoder = argos3.DecoderViterbi(G=np.array([[121, 91]]))
>>> ut_prime = decoder.decode(vt0, vt1)
>>>
>>> print(ut_prime)
>>>
[1 0 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1]
>>> print("ut = ut': ", np.array_equal(ut, ut_prime))
ut = ut': True
- Bitstream Plot Example:
AS3-SP-516-274-CNES (seção 3.1.4.4)
CCSDS 131.1-G-2
calc_taps(poly)
Generate the taps for each generator polynomial.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
poly
|
int
|
Generator polynomial \(G_n\) in binary format. |
required |
Returns:
Name | Type | Description |
---|---|---|
taps |
int
|
List of active tap indices. |
calc_free_distance()
Calculate the free distance \(d_{free}\) of the convolutional code, defined as the minimum Hamming distance between any two distinct output sequences.
Returns:
Name | Type | Description |
---|---|---|
dist |
int
|
Free distance \(d_{free}\) of the convolutional encoder organized with \(G\). |
encode(ut)
Encode a binary input sequence \(u_t\), returning the output sequences \(v_t^{(0)}\) and \(v_t^{(1)}\). The encoding process can be represented by the expression below.
Where
- \(v_t^{(0)}\) and \(v_t^{(1)}\): Output channels of the encoder.
- \(u_t\): Input bit vector.
- \(G_{0}\) and \(G_{1}\): Generator polynomials of the encoder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ut
|
ndarray
|
Input bit vector \(u_t\) to be encoded. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
(ndarray, ndarray)
|
Tuple with the two output channels \(v_t^{(0)}\) and \(v_t^{(1)}\). |
__init__(G=np.array([[121, 91]]), decision='hard')
Initialize the Viterbi decoder, based on a tuple of generator polynomials \(G\) that determine the structure of the decoder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
ndarray
|
Tuple of generator polynomials \(G\). |
array([[121, 91]])
|
decision
|
str
|
Decision type, either "hard" or "soft". |
'hard'
|
Raises:
Type | Description |
---|---|
ValueError
|
If decision is not "hard" or "soft". |
Examples:
>>> import argos3
>>> import numpy as np
>>>
>>> ut = np.random.randint(0, 2, 30)
>>> encoder = argos3.EncoderConvolutional(G=np.array([[121, 91]]))
>>> vt0, vt1 = encoder.encode(ut)
>>>
>>> print(ut)
[1 0 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1]
>>>
>>> decoder = argos3.DecoderViterbi(G=np.array([[121, 91]]))
>>> ut_prime = decoder.decode(vt0, vt1)
>>>
>>> print(ut_prime)
>>>
[1 0 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1]
>>> print("ut = ut': ", np.array_equal(ut, ut_prime))
ut = ut': True
- Bitstream Plot Example:
https://rwnobrega.page/apontamentos/codigos-convolucionais/
AS3-SP-516-274-CNES (seção 3.1.4.4)
https://dsplog.com/2009/01/14/soft-viterbi/
build_trellis()
Build the trellis for the Viterbi decoder based on the generator polynomials \(G\).
Returns:
Name | Type | Description |
---|---|---|
trellis |
dict
|
Trellis for the Viterbi decoder. |
branch_metric(trellis_symbol, received_symbol)
Calculate the branch metric depending on the decision type for the Viterbi decoder.
For Hard Decision uses Hamming distance, given by the expression below.
Where
- \(d_{hamming}\): Hamming distance.
- \(r_i\): Received bit.
- \(s_i\): Expected trellis output bit.
Examples:
- Bitstream Plot Example:
For Soft Decision uses Euclidean distance, given by the expression below.
Where
- \(d_{euclidean}\): Euclidean distance.
- \(r_i\): Received symbol.
- \(s_i\): Expected trellis output symbol.
Examples:
Soft Decision Example:
- Stream:
- Sampling:
- Decoding:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trellis_symbol
|
ndarray
|
Expected trellis output symbol, based on the trellis state. |
required |
received_symbol
|
ndarray
|
Received symbol. |
required |
Returns:
Name | Type | Description |
---|---|---|
metric |
float
|
Branch metric. |
decode(vt0, vt1)
Decode the bits of the input \(v_t^{(0)}\) and \(v_t^{(1)}\), returning the decoded bits \(u_t\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vt0
|
ndarray
|
Bits of the input channel I. |
required |
vt1
|
ndarray
|
Bits of the input channel Q. |
required |
Returns:
Name | Type | Description |
---|---|---|
ut_hat |
ndarray
|
Decoded bits. |