Added utility scripts (RRC filtering)
This commit is contained in:
parent
6565de36c0
commit
c1dcc8b0c7
27
utils/filter_preamble.py
Executable file
27
utils/filter_preamble.py
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as pp
|
||||
import rrc
|
||||
|
||||
pre = [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, 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, 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, 1,
|
||||
1, -1, -1, 1, 1, 1, 1]
|
||||
|
||||
pre_up = np.zeros(2 * len(pre) + 1)
|
||||
|
||||
pre_up[1::2] = pre
|
||||
|
||||
rrc_coef = rrc.rrc_design(150, 2)
|
||||
|
||||
pre_flt = np.convolve(pre_up, rrc_coef, mode='same')
|
||||
|
||||
print(list(pre_flt))
|
||||
|
||||
pp.plot(pre_up)
|
||||
pp.plot(pre_flt)
|
||||
pp.show()
|
33
utils/rrc.py
Executable file
33
utils/rrc.py
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import numpy as np
|
||||
|
||||
def rrc_design(N, samples_per_symbol, roll_off = 0.35):
|
||||
coef = np.zeros(N)
|
||||
|
||||
k0 = N/2
|
||||
Ts = samples_per_symbol
|
||||
|
||||
for k in range(len(coef)):
|
||||
t = k - k0
|
||||
|
||||
if t == 0:
|
||||
coef[k] = 1 / np.sqrt(Ts) * (1 - roll_off + 4 * roll_off / np.pi)
|
||||
elif abs(t) == (Ts / (4*roll_off)):
|
||||
coef[k] = roll_off / np.sqrt(2 * Ts) * \
|
||||
( (1 + 2/np.pi) * np.sin(np.pi / (4 * roll_off)) + \
|
||||
(1 - 2/np.pi) * np.cos(np.pi / (4 * roll_off)) )
|
||||
else:
|
||||
coef[k] = 1 / np.sqrt(Ts) * \
|
||||
( np.sin(np.pi * t / Ts * (1 - roll_off)) + 4 * roll_off * t / Ts * np.cos(np.pi * t / Ts * (1 + roll_off)) ) / \
|
||||
( np.pi * t / Ts * (1 - (4 * roll_off * t / Ts)**2) )
|
||||
|
||||
return coef
|
||||
|
||||
if __name__ == "__main__":
|
||||
import matplotlib.pyplot as pp
|
||||
|
||||
c = rrc_design(50, 5, 0.35)
|
||||
print(np.sum(c))
|
||||
pp.plot(c)
|
||||
pp.show()
|
Loading…
Reference in a new issue