Rician fading channel Simulation Python code
This fading channel python code script simulates rician channel coefficients. The rician python code output plots are also mentioned.
Introduction : The term fading refers to variation in the received signal strength due to various parameters between transmitter and receiver as well as their movements. These factors or parameters include path loss, multipaths, doppler spread, shadowing effect, mobility etc. The rayleigh channel model simulates both NLOS (Non Line of Sight) and LOS (Line of Sight) components between transmitter and receiver. Refer article on fading basics and fading types >>.
Rician Channel Python code
# This python script is used to generate rician channel coefficients
import math
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import standard_normal
# Sinusoidal waveform generation
t = np.linspace(1, 100, 750)
x_volts = 20*np.sin(t/(2*np.pi))
x_watts = x_volts ** 2
x_db = 10 * np.log10(x_watts)
# Rician channel coefficients
N = 1000 # Number of samples to generate
K_dB = 10 # K factor in dB
K = 10**(K_dB/10) # K factor in linear scale
mu = math.sqrt(K/(2*(K+1))) # mean
sigma = math.sqrt(1/(2*(K+1))) # sigma
h = (sigma*standard_normal(N)+mu)+1j*(sigma*standard_normal(N)+mu)
h_mag = np.abs(h)
h_mag_dB = 10*np.log10(h_mag) # convert channel response in dB
# Convolve rician channel response with sinusoidal waveform
Y4 = np.convolve(h, x_volts)
# Plots
figure, axis = plt.subplots(2, 2)
axis[0, 0].plot(x_volts)
axis[0, 0].set_title("Pure sine wave signal")
axis[0, 1].plot(h)
axis[0, 1].set_title("Rician Channel response")
axis[1, 0].plot(h_mag_dB)
axis[1, 0].set_title("Rician Channel response in dB")
axis[1, 1].plot(Y4)
axis[1, 1].set_title("Convolved sine wave signal")
plt.tight_layout()
plt.show()
import math
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import standard_normal
# Sinusoidal waveform generation
t = np.linspace(1, 100, 750)
x_volts = 20*np.sin(t/(2*np.pi))
x_watts = x_volts ** 2
x_db = 10 * np.log10(x_watts)
# Rician channel coefficients
N = 1000 # Number of samples to generate
K_dB = 10 # K factor in dB
K = 10**(K_dB/10) # K factor in linear scale
mu = math.sqrt(K/(2*(K+1))) # mean
sigma = math.sqrt(1/(2*(K+1))) # sigma
h = (sigma*standard_normal(N)+mu)+1j*(sigma*standard_normal(N)+mu)
h_mag = np.abs(h)
h_mag_dB = 10*np.log10(h_mag) # convert channel response in dB
# Convolve rician channel response with sinusoidal waveform
Y4 = np.convolve(h, x_volts)
# Plots
figure, axis = plt.subplots(2, 2)
axis[0, 0].plot(x_volts)
axis[0, 0].set_title("Pure sine wave signal")
axis[0, 1].plot(h)
axis[0, 1].set_title("Rician Channel response")
axis[1, 0].plot(h_mag_dB)
axis[1, 0].set_title("Rician Channel response in dB")
axis[1, 1].plot(Y4)
axis[1, 1].set_title("Convolved sine wave signal")
plt.tight_layout()
plt.show()
Rician fading channel output plots
Following are the plots of above Rician fading channel python code.
Other useful DSP codes in Python
Correlation python script
Python programming tutorial
Convolution python script
BPSK QPSK 16QAM 64QAM modulation
16-Point FFT code
OFDM transmitter simulation code
Rayleigh Fading Channel
Rician Fading Channel
ASK modulation python code
FSK modulation python code
PSK modulation python code
Useful Links to MATLAB codes
Rician channel Matlab code
OFDM Preamble generation
Time off estimation corr
Freq off estimation corr
channel estimation
11a WLAN channel
PN sequence generation
OFDMA Tx Rx
AES DES
carrier aggregation
CCDF
FIR Filter
IIR Filter
Low Pass FIR
Viterbi decoder
CRC8 CRC32