Line Encoder
__init__(method='NRZ')
Initializes the line encoder with the specified encoding method, used to encode the bitstream as \(X[n]\) and \(Y[n]\), returning the symbol stream \(I[n]\) and \(Q[n]\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
str
|
Encoding method, 'NRZ' or 'Manchester'. |
'NRZ'
|
Raises:
Type | Description |
---|---|
ValueError
|
If the encoding method is not supported. |
Examples:
>>> import argos3
>>> import numpy as np
>>>
>>> Xn = np.random.randint(0, 2, 20)
>>> Yn = np.random.randint(0, 2, 20)
>>>
>>> print(Xn)
[1 0 1 1 0 0 1 0 0 0 0 0 0 0 1 0 1 1 0 0]
>>> print(Yn)
[1 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0 1 1 1]
>>>
>>> encoder_nrz = argos3.Encoder(method="NRZ")
>>> encoder_man = argos3.Encoder(method="Manchester")
>>>
>>> In = encoder_nrz.encode(Xn)
>>> Qn = encoder_man.encode(Yn)
>>>
>>> print(In)
[ 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1]
>>>
>>> print(Qn)
[ 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 1 -1 1
-1 1 1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 1 -1]
>>>
>>> Xn_prime = encoder_nrz.decode(In)
>>> Yn_prime = encoder_man.decode(Qn)
>>>
>>> print(Xn_prime)
[1 0 1 1 0 0 1 0 0 0 0 0 0 0 1 0 1 1 0 0]
>>> print(Yn_prime)
[1 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0 1 1 1]
- Bitstream Plot Example:
Reference:
AS3-SP-516-274-CNES (section 3.2.4)
AS3-SP-516-274-CNES (section 3.2.4)
encode(bitstream)
Encodes the bitstream using the specified encoding method. The encoding process is given by the expressions below corresponding to each method.
\[
\begin{equation}
\begin{aligned}
K[n] &=
\begin{cases}
+1, & \text{if } k[n] = 1 \\
-1, & \text{if } k[n] = 0 ,
\end{cases}
&\quad\quad
K[n] &=
\begin{cases}
+1,-1, & \text{if } k[n] = 1 \\
-1, +1, & \text{if } k[n] = 0 .
\end{cases}
\end{aligned}
\end{equation}
\]
Where
- \(k[n]\): Input bitstream.
- \(K[n]\): Output symbol stream.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bitstream
|
ndarray
|
Input bitstream. |
required |
Returns:
Name | Type | Description |
---|---|---|
out |
ndarray
|
Encoded symbol stream. |
decode(encodedstream)
Decodes the symbol stream using the specified encoding method. The decoding process is given by the expressions below corresponding to each method.
\[
\begin{equation}
\begin{aligned}
k[n] &=
\begin{cases}
1, & \text{if } K[n] = +1 \\
0, & \text{if } K[n] = -1
\end{cases}
&\quad\quad
k[n] &=
\begin{cases}
1, & \text{if } K[n] = +1, -1 \\
0, & \text{if } K[n] = -1, +1
\end{cases}
\end{aligned}
\end{equation}
\]
Where
- \(K[n]\): Input symbol stream
- \(k[n]\): Output bitstream.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
encoded_stream
|
ndarray
|
Input symbol stream. |
required |
Returns:
Name | Type | Description |
---|---|---|
out |
ndarray
|
Decoded bitstream. |