Skip to content

Commit aea4244

Browse files
committed
Add a method to compute specular component in Rician fading channel.
[1] Lee M. Garth, Peter J. Smith, Mansoor Shafi, "Exact Symbol Error Probabilities for SVD Transmission of BPSK Data over Fading Channels", IEEE 2005.
1 parent 1c2ada9 commit aea4244

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

commpy/channels.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Authors: Veeresh Taranalli < veeresht @ gmail.com > & Bastien Trotobas < bastien.trotobas @ gmail.com >
1+
# Authors: Veeresh Taranalli <veeresht@gmail.com> & Bastien Trotobas <bastien.trotobas@gmail.com>
22
# License: BSD 3-Clause
33

44
"""
@@ -19,7 +19,8 @@
1919

2020
from __future__ import division, print_function # Python 2 compatibility
2121

22-
from numpy import complex, abs, sqrt, sum, zeros, identity, hstack, einsum, trace, kron, absolute, fromiter, array, exp
22+
from numpy import complex, abs, sqrt, sum, zeros, identity, hstack, einsum, trace, kron, absolute, fromiter, array, exp, \
23+
pi, cos
2324
from numpy.random import randn, random, standard_normal
2425
from scipy.linalg import sqrtm
2526

@@ -416,6 +417,47 @@ def _update_corr_KBSM(self, betat, betar):
416417
# updating of correlation matrices
417418
self.fading_param = self.fading_param[0], alpha * self.fading_param[1] * Et, self.fading_param[2] * Er
418419

420+
421+
def specularH(self, thetar, dr, thetat, dt):
422+
423+
"""
424+
Calculate the specular components of H the channel gain as in [1].
425+
ref: [1] Lee M. Garth, Peter J. Smith, Mansoor Shafi, "Exact Symbol Error Probabilities for SVD Transmission
426+
of BPSK Data over Fading Channels", IEEE 2005.
427+
428+
Parameters
429+
----------
430+
thetat : float
431+
the angle of departure.
432+
433+
dt : postive float
434+
the antenna spacing in wavelenghts of departure.
435+
436+
thetar : float
437+
the angle of arrival.
438+
439+
dr : positie float
440+
the antenna spacing in wavelenghts of arrival.
441+
442+
Returns
443+
-------
444+
H : 2D ndarray of shape (nb_rx, nb_tx)
445+
the specular components of channel gains to be use as mean in Rician fading.
446+
447+
Raises
448+
------
449+
ValueError
450+
If dt or dr are negative.
451+
452+
"""
453+
if dr < 0 or dt < 0 :
454+
raise ValueError("the distance must be positive ")
455+
H = zeros((self.nb_rx,self.nb_tx),dtype=complex)
456+
for n in range(self.nb_rx):
457+
for m in range(self.nb_tx):
458+
H[n,m] = exp(1j*2*pi*(n*dr*cos(thetar)-m*dt*cos(thetat)))
459+
return H
460+
419461
@property
420462
def fading_param(self):
421463
""" Parameters of the fading (see class attribute for details). """

commpy/tests/test_channels.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,15 @@ def check_correlation(chan, Rt, Rr):
406406
assert_allclose(chan.k_factor, 5,
407407
err_msg='Wrong k-factor with correlated rician fading')
408408

409+
# Test specularH
410+
with assert_raises(ValueError):
411+
chan.specularH(0,-1,0,1)
412+
413+
mean = chan.specularH(0,0.1,0.5,1)
414+
chan.expo_corr_rician_fading(mean, 5, exp(-0.1j*pi), exp(-0.2j*pi), 3, 2)
415+
check_chan_gain(mod, chan)
416+
assert_allclose(chan.k_factor, 5,
417+
err_msg='Wrong k-factor with correlated rician fading')
409418

410419

411420
@dec.slow

0 commit comments

Comments
 (0)