Skip to content

Commit 9e91c12

Browse files
authored
Merge pull request #14 from matchius/patch-1
Update channels.py for awgn for complex signals
2 parents 57f5ebd + 1fa6dfe commit 9e91c12

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

commpy/channels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
"""
1818

19-
from numpy import complex, sum, pi, arange, array, size, shape, real, sqrt
19+
from numpy import complex, sum, abs, pi, arange, array, size, shape, real, sqrt
2020
from numpy import matrix, sqrt, sum, zeros, concatenate, sinc
2121
from numpy.random import randn, seed, random
2222
#from scipy.special import gamma, jn
@@ -94,7 +94,7 @@ def awgn(input_signal, snr_dB, rate=1.0):
9494
snr_linear = 10**(snr_dB/10.0)
9595
noise_variance = avg_energy/(2*rate*snr_linear)
9696

97-
if input_signal.dtype == complex:
97+
if type(input_signal[0]) == complex:
9898
noise = (sqrt(noise_variance) * randn(len(input_signal))) + (sqrt(noise_variance) * randn(len(input_signal))*1j)
9999
else:
100100
noise = sqrt(2*noise_variance) * randn(len(input_signal))

0 commit comments

Comments
 (0)