In [1]:
from pylayers.measures.vna.E5072A import *
from pylayers.measures.exploith5 import *
from matplotlib import cm
from numpy.fft import *
from pylayers.antprop.aarray import *
%matplotlib inline
In [2]:
M=Mesh5()
In [3]:
M.dir()
In [4]:
M = Mesh5('mesMIMO.h5')
In [12]:
M.read(1,ix=[0,0,0,0])
In [16]:
%matplotlib notebook
M.mes.plot()
The second measurement run has been done on 18 January by mamadou. It corresponds to a displacement along the 'x' axis with 10 measurement different location. The MIMO configuration was 4x8. The transmitting antenna center was [1.6,5.2,1.6] and the orientation along the x axis. The calibration set was 3, correseponding to 1000Hz for IF and Np = 801.
In [6]:
for r in range(4):
for t in range(8):
M.read(1,ix=[0, 0, 0, 0],calibrate=True)
C11=Tchannel()
C11.y = M.mes.y[0,r,t,:]
C11.x = M.mes.x
C11.plot(typ=['l20'])
In [9]:
M
Out[9]:
In [32]:
M.read(6,ix=[0, 0, 0, 0])
C22=Tchannel()
C22.y = M.mes.y[0,1,1,:]
C22.x = M.mes.x
In [25]:
#C22.plot(typ=['l20'])
Out[25]:
In [14]:
C11.plot(typ=['l20'])
Out[14]:
In [7]:
c11=C11.ift(ffts=1)
In [11]:
c11.plot(typ=['v'])
plt.xlim(0,50)
#plt.ylim(-160,-40)
Out[11]:
In [7]:
f,a=M.mes.plot()
In [18]:
del TD
for k in range(1):
M.read(6,ix=[k,0,0,0,0])
try:
TD = np.concatenate((TD,M.mes.y),axis=0)
except:
TD = M.mes.y
In [19]:
C11=Tchannel()
C11.y = TD[:,2,2,:]
C11.x = M.mes.x
In [20]:
TD.shape
Out[20]:
In [21]:
C11.y.shape
Out[21]:
In [22]:
fig=plt.figure(figsize=(20,10))
U=C11.plot(iy=-1,figsize=(20,20))
In [24]:
plt.figure(figsize=(10,10))
for t in range(1):
u = 10*np.log10(np.abs(C11.y[t,:]))
plt.plot(M.mes.x,u)
In [18]:
type(M.mes)
Out[18]:
In [64]:
TD.shape
Out[64]:
In [25]:
fGHz = M.mes.x
In [26]:
df=fGHz[1]-fGHz[0]
In [27]:
t = np.linspace(-1/(2*df),1/(2*df),len(fGHz))
In [79]:
Out[79]:
In [29]:
plt.figure(figsize=(10,10))
U=fftshift(fft(np.conj(TD[:,3,7,:]),axis=1))
for k in range(1):
plt.plot(np.abs(U[k,:]),'o-')
plt.xlim(400,500)
In [91]:
TD.shape
Out[91]:
In [97]:
plt.subplot?
In [30]:
imin=400
imax=460
k = 0
plt.figure(figsize=(20,15))
for ir in range(4):
for it in range(8):
k = k+1
U=fftshift(fft(np.conj(TD[:,ir,it,:]),axis=1))
#
plt.subplot(4,8,k)
plt.imshow(10*np.log10(np.abs(U[:,imin:imax])),interpolation='nearest',extent=[t[imin],t[imax],-0.35,0.35],cmap=cm.jet)
plt.axis('auto')
plt.tight_layout()
plt.colorbar()
Out[30]:
In [80]:
plt.imshow?
In [78]:
plt.plot(fftshift(np.abs(U[0,:])))
plt.xlim(300,500)
Out[78]:
In [22]:
plt.imshow(np.abs(fftshift(U,axis=1))[350:450,:])
In [ ]:
M.plot(cmd='ir')
In [114]:
from pylayers.antprop.aarray import *
A1 = AntArray(N=[100,1,1,1],min=[-0.035,0,0,0],max=[0.035,0,0,0])
In [115]:
A1
Out[115]:
In [117]:
A1.p.shape
Out[117]:
In [120]:
A1 = AntArray(N=[100,1,1,1],max=[0.035,0,0,0],min=[-0.035,0,0,0],mode='grid')
In [122]:
A1.p
Out[122]:
In [12]:
A1 = AntArray(N=[1000,1,1,1],max=[0.35,0,0,0],min=[-0.35,0,0,0],mode='grid')
In [15]:
A1.p.shape
Out[15]:
In [36]:
from numpy.linalg import svd
def sing_values():
ir = 4
it = 8
npos = 5
cpt = 0
ipos = 6
M = Mesh5('mesMIMO.h5')
for k in range(npos):
M.read(ipos,ix=[k,0,0,0,0])
try:
TD = np.concatenate((TD,M.mes.y),axis=0)
except:
TD = M.mes.y
fGHz = M.mes.x
#M.read(2,ix=[99, 0, 0, 0])
# TD.shape : (100, 4, 8, 801)
TDm = np.sum(np.abs(TD),axis=0)/npos # mean of TD ; TDm.shape : (4, 8, 801)
TDc = np.abs(TD)-TDm[None,...] # TD centered ; TDc.shape : (85, 4, 8, 801)
TDc2 = np.abs(TDc)**2 # square of TD centered ; TDc2.shape : (85, 4, 8, 801)
varTD = np.sum(TDc2,axis=0)/npos #variance of TD ; varTD.shape : (4, 8, 801)
# Friis formula with gain antenna around 12dB
FS = -(32.4+20*np.log10(fGHz)+20*np.log10(5.435))+12
#Singular values of the channel matrix
TDs = np.swapaxes(TD,1,3)
TDss = np.swapaxes(TDs,2,3)
U,S,V= svd(TDss)
#M.read(2,ix=[1, 0, 0, 0])
for k in range(npos):
M.read(ipos,ix=[k,0,0,0,0])
try:
TD = np.concatenate((TD,M.mes.y),axis=0)
except:
TD = M.mes.y
fGHz = M.mes.x
sns.set_style("darkgrid")
plt.ion()
mu0 = np.mean(S[:npos,:,0],axis=0)
mu1 = np.mean(S[:npos,:,1],axis=0)
mu2 = np.mean(S[:npos,:,2],axis=0)
mu3 = np.mean(S[:npos,:,3],axis=0)
s0 = np.sqrt(np.mean((S[:npos,:,0]-mu0[None,:])**2,axis=0))
s1 = np.sqrt(np.mean((S[:npos,:,1]-mu1[None,:])**2,axis=0))
s2 = np.sqrt(np.mean((S[:npos,:,2]-mu2[None,:])**2,axis=0))
s3 = np.sqrt(np.mean((S[:npos,:,3]-mu3[None,:])**2,axis=0))
for k in range(npos):
#First singular value
plt.semilogy(fGHz,S[k,:,0],color='k',linewidth=.1)
plt.semilogy(fGHz,mu0+1.96*s0,color='k',linewidth=1)
plt.semilogy(fGHz,mu0-1.96*s0,color='k',linewidth=1)
plt.semilogy(fGHz,mu0,color='k',marker='o',markevery=10,ms=3)
#Second singular value
plt.semilogy(fGHz,S[k,:,1],color='g',linewidth=.1)
plt.semilogy(fGHz,mu1+1.96*s1,color='g',linewidth=1)
plt.semilogy(fGHz,mu1-1.96*s1,color='g',linewidth=1)
plt.semilogy(fGHz,mu1,color='k',marker='4',markevery=10,ms=3)
#Third singular value
plt.semilogy(fGHz,S[k,:,2],color='#ff4500',linewidth=.1)
plt.semilogy(fGHz,mu2+1.96*s2,color='#ff4500',linewidth=1)
plt.semilogy(fGHz,mu2-1.96*s2,color='#ff4500',linewidth=1)
plt.semilogy(fGHz,mu2,color='k',marker='3',markevery=10,ms=3)
#Fourth singular value
plt.semilogy(fGHz,S[k,:,3],color='b',linewidth=.1)
plt.semilogy(fGHz,mu3+1.96*s3,color='b',linewidth=1)
plt.semilogy(fGHz,mu3-1.96*s3,color='b',linewidth=1)
plt.semilogy(fGHz,mu3,color='k',marker='s',markevery=10,ms=3)
plt.title(r'Evolution of singular values of the matrix $\mathbf{H}_{ij}(f)$ along a $\Delta_x=0.7m$',fontsize=14)
plt.ylabel('Module (linear scale $\in [0,1]$)',fontsize=14)
plt.xlabel('Frequency (GHz)',fontsize=14)
plt.xlim(1.8,2.2)
plt.legend(loc='best')
plt.tight_layout()
#plt.savefig('fig4.png')
In [37]:
%matplotlib inline
plt.figure(figsize=(10,10))
sing_values()
In [ ]: