Skip to content

Modulator

Bases: object

Class representing modualtor.

Attributes:

Name Type Description
...

Methods:

Name Description
bpsk

The purpose of this method is to modulate bit sequence using BPSK.

Source code in src\modulator.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Modulator(object):
    """
    Class representing modualtor.

    Attributes
    ----------
    ...

    Methods
    -------
    bpsk(bit_seq)
        The purpose of this method is to modulate bit sequence using BPSK.
    """

    def __init__(self):
        pass

    def bpsk(self, bit_seq: NDArray[np.uint8]) -> NDArray[np.int8]:
        """
        Performs BPSK modulation.

        Parameters
        ----------
        bit_seq : NDArray[np.uint8]
            Input bit seqence.

        Returns
        -------
        bpsk_out_seq : NDArray[np.int8]
            Seqence after BPSK modulation (channel input signal).
        """

        size = bit_seq.size
        bpsk_out_seq = np.zeros(size, dtype=np.int8)

        for i in range(size):
            bpsk_out_seq[i] = 1 if bit_seq[i] == 0 else -1

        return bpsk_out_seq

bpsk(bit_seq)

Performs BPSK modulation.

Parameters:

Name Type Description Default
bit_seq NDArray[uint8]

Input bit seqence.

required

Returns:

Name Type Description
bpsk_out_seq NDArray[int8]

Seqence after BPSK modulation (channel input signal).

Source code in src\modulator.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def bpsk(self, bit_seq: NDArray[np.uint8]) -> NDArray[np.int8]:
    """
    Performs BPSK modulation.

    Parameters
    ----------
    bit_seq : NDArray[np.uint8]
        Input bit seqence.

    Returns
    -------
    bpsk_out_seq : NDArray[np.int8]
        Seqence after BPSK modulation (channel input signal).
    """

    size = bit_seq.size
    bpsk_out_seq = np.zeros(size, dtype=np.int8)

    for i in range(size):
        bpsk_out_seq[i] = 1 if bit_seq[i] == 0 else -1

    return bpsk_out_seq