-
Notifications
You must be signed in to change notification settings - Fork 2
/
mod_schemes.py
37 lines (30 loc) · 1.27 KB
/
mod_schemes.py
1
2
3
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
import komm
import numpy as np
class ModScheme:
def create_object(self,x):
"""
Creates an instance of the corresponding modulation scheme
Parameters
----------
x : string containing the name of the modulation scheme
Returns
-------
instance of the corresponding modulation scheme
k : bits per symbol
"""
if x == 'BPSK':
k = 1
obj = komm.PSKModulation(2)
if x == 'QPSK':
k = 2
obj = komm.PSKModulation(4, phase_offset=np.pi/4)
if x == '4-QAM':
k = 2
obj = komm.QAModulation(4, base_amplitudes=1/np.sqrt(2.)) # base_amplitudes is set to a value such that obj.energy_per_symbol becomes unity.
if x == '16-QAM':
k = 4
obj = komm.QAModulation(16, base_amplitudes=1/np.sqrt(10.)) # base_amplitudes is set to a value such that obj.energy_per_symbol becomes unity.
if x == '256-QAM':
k = 8
obj = komm.QAModulation(256, base_amplitudes=1/np.sqrt(170.)) # base_amplitudes is set to a value such that obj.energy_per_symbol becomes unity.
return obj, k