hamnet70-gnuradio-legacy/utils/rrc.py

34 lines
984 B
Python
Raw Normal View History

2019-06-20 16:57:12 +02:00
#!/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()