In [1]:
from pylayers.antprop.rays import *
from pylayers.gis.layout import *
from pylayers.antprop.signature import *
import pylayers.signal.bsignal as bs
import pylayers.signal.waveform as wvf 
from pylayers.simul.simulem import *
import matplotlib.pyplot as plt 
import time


<matplotlib.figure.Figure at 0xa3fe090>

In [2]:
print "======================="
print " start test_rays.py (Ray Tracing numpy) "
print "======================="
S = Simul()
filestr = 'defstr'
S.layout(filestr+'.ini','matDB.ini','slabDB.ini')
S.L.Gs.node[1]['ss_name']=['WOOD','AIR','METAL']
S.L.build()
# first case
tx=array([759,1114,1.0])
rx=array([767,1114,1.5])
S.tx.clear()
S.rx.clear()
S.tx.point(tx)
S.rx.point(rx)
Ctx = S.L.pt2cy(S.tx.position[:,0])
Crx = S.L.pt2cy(S.rx.position[:,0])
fGHz=np.arange(2,11,0.1)
wav = wvf.Waveform(fcGHz=5,bandGHz=3)


=======================
 start test_rays.py (Ray Tracing numpy) 
=======================

We start by building a first set of rays.


In [41]:
Si1 = Signatures(S.L,Ctx,Crx)
Si1.run4(cutoff=5,algo='old')
r2d = Si1.rays(tx,rx)
r3d1 = r2d.to3D(S.L)
r3d1.locbas(S.L)
r3d1.fillinter(S.L)
C1 = r3d1.eval(fGHz)
sc1 = C1.prop2tran(a='theta',b='theta',Friis=False)
cir1 = sc1.applywavB(wav.sfg)

In [42]:
r3d1.show3(S.L)

In [43]:
r2d2 = r2d.reciprocal()
# get new reciprocal r3d
r3d2 = r2d2.to3D(S.L)
r3d2.locbas(S.L)
r3d2.fillinter(S.L)
C2=r3d2.eval(fGHz)
sc2=C2.prop2tran(a='theta',b='theta',Friis=False)
cir2 = sc2.applywavB(wav.sfg)

In [44]:
r3d1.check_reciprocity(r3d2)

In [46]:
cir1.plot(typ='v')


Out[46]:
(<matplotlib.figure.Figure at 0x7f8939131d50>,
 array([[<matplotlib.axes.AxesSubplot object at 0x7f896e184550>]], dtype=object))

In [47]:
cir2.plot(typ='v')


Out[47]:
(<matplotlib.figure.Figure at 0x7f896e198b10>,
 array([[<matplotlib.axes.AxesSubplot object at 0x7f896e301910>]], dtype=object))

In [48]:
C1.Ctt.show()


Out[48]:
(<matplotlib.figure.Figure at 0x7f896e198c10>,
 [<matplotlib.axes.AxesSubplot at 0x7f896e0fa210>,
  <matplotlib.axes.AxesSubplot at 0x7f896e172b10>])

In [9]:
C2.show(mode='dB')


Out[9]:
(<matplotlib.figure.Figure at 0x7f896db3f790>,
 (<matplotlib.axes.AxesSubplot at 0x7f896db10150>,
  <matplotlib.axes.AxesSubplot at 0x1252eb90>,
  <matplotlib.axes.AxesSubplot at 0x126c4b50>,
  <matplotlib.axes.AxesSubplot at 0x128514d0>))

In [10]:
dsig1 = {}
for l in r3d1.keys():
    tsig = r3d1[l]['sig']
    nr = np.shape(tsig)[2]
    for r in range(nr):
        sig = tsig[:,:,r]
        dsig1[str(sig)]=(l,r)

dsig2 = {}
for l in r3d2.keys():
    tsig = r3d2[l]['sig']
    nr = np.shape(tsig)[2]
    for r in range(nr):
        sig = tsig[:,::-1,r]
        dsig2[str(sig)]=(l,r)

In [11]:
k1 = dsig1.keys()
k2 = dsig2.keys()

In [12]:
for s1 in k1:
    if s1 not in k2:
        l1,r1  = dsig1[s1]
        iray1 = r3d1[l1]['rayidx'][r1]
        print dsig1[s1],iray1,C1.tauk[iray1]
print "-----"        
for s2 in k2:
    if s2 not in k1:
        l2,r2  = dsig2[s2]
        iray2 = r3d2[l2]['rayidx'][r2]
        print dsig2[s2],iray2,C2.tauk[iray2]


-----

In [13]:
r134=r3d1.extract(3,4)
r134.show3(S.L)
r134[3]['pt'][:,:,0]


Out[13]:
array([[  7.59000000e+02,   7.58502390e+02,   7.63144889e+02,
          7.63502607e+02,   7.67000000e+02],
       [  1.11400000e+03,   1.11399389e+03,   1.11399723e+03,
          1.11399748e+03,   1.11400000e+03],
       [  1.00000000e+00,   1.19363167e+00,   3.00000000e+00,
          2.86081425e+00,   1.50000000e+00]])

In [18]:
r238=r3d2.extract(3,8)
r238.show3(S.L)
r238[3]['pt'][:,:,0]


Out[18]:
array([[  7.67000000e+02,   7.63513099e+02,   7.62571106e+02,
          7.58503861e+02,   7.59000000e+02],
       [  1.11400000e+03,   1.11236709e+03,   1.11192595e+03,
          1.11376754e+03,   1.11400000e+03],
       [  1.50000000e+00,   1.30560118e+00,   1.25308391e+00,
          1.02766293e+00,   1.00000000e+00]])

In [19]:
for s1 in k1:
    if s1 in k2:
        l1,r1  = dsig1[s1]
        iray1 = r3d1[l1]['rayidx'][r1]
        l2,r2 = dsig2[s1]
        iray2 = r3d2[l2]['rayidx'][r2]
        if abs(C1.tauk[iray1]-C2.tauk[iray2])>1e-7:
            print C1.tauk[iray1]-C2.tauk[iray2]

In [20]:
k1[19] in k2


Out[20]:
True

In [21]:
print r3d1[2]['sig'][:,:,0]
print r3d2[2]['sig'][:,:,1]


[[ 0  0 10  0]
 [ 0  4  2  0]]
[[ 0  0 12  0]
 [ 0  5  2  0]]

In [22]:
S.L.sla[12]


Out[22]:
'METAL'

In [23]:
S.L.sla[10]


Out[23]:
'WOOD'

In [24]:
S.L.lsss


Out[24]:
[1, 1, 1]

In [25]:
S.L.Gs.node[1]['ss_z']


Out[25]:
[(0.0, 2.4), (2.7, 2.8), (2.8, 3)]

In [26]:
print r3d1[3]['pt'][:,:,4]- r3d2[3]['pt'][:,::-1,8]


[[  0.00000000e+00  -1.47128259e-03   5.73783814e-01  -1.04923250e-02
    0.00000000e+00]
 [  0.00000000e+00   2.26351168e-01   2.07127482e+00   1.63039723e+00
    0.00000000e+00]
 [  0.00000000e+00   1.65968748e-01   1.74691609e+00   1.55521307e+00
    0.00000000e+00]]

In [27]:
r3d1.signature(2,1)


Out[27]:
array([[ 0, 12,  0,  0],
       [ 0,  2,  5,  0]])

In [28]:
r3d2.signature(2,0)


Out[28]:
array([[ 0, 10,  0,  0],
       [ 0,  2,  4,  0]])

In [29]:
print r3d1[2]['pt'][:,:,1]


[[  7.59000000e+02   7.63502592e+02   7.63571429e+02   7.67000000e+02]
 [  1.11400000e+03   1.11400000e+03   1.11400000e+03   1.11400000e+03]
 [  1.00000000e+00   2.96988400e+00   3.00000000e+00   1.50000000e+00]]

In [30]:
print r3d2[2]['pt'][:,::-1,0]


[[  7.59000000e+02   7.62200000e+02   7.63502592e+02   7.67000000e+02]
 [  1.11400000e+03   1.11400000e+03   1.11400000e+03   1.11400000e+03]
 [  1.00000000e+00   0.00000000e+00   4.07060000e-01   1.50000000e+00]]

In [31]:
idx1 = r3d1[2]['rayidx'][1]
idx2 = r3d1[2]['rayidx'][0]
print idx1
print idx2


2
1

Local Basis


In [15]:
Bi1 = r3d1[2]['Bi'][:,:,:,1]
BiN1 = r3d1[2]['BiN'][:,:,1]
Bo1 = r3d1[2]['Bo'][:,:,:,1]
Bo01 = r3d1[2]['Bo0'][:,:,1]

In [16]:
Bi2 = r3d2[2]['Bi'][:,:,:,0]
BiN2 = r3d2[2]['BiN'][:,:,0]
Bo2 = r3d2[2]['Bo'][:,:,:,0]
Bo02 = r3d2[2]['Bo0'][:,:,0]

In [17]:
print BiN1


[[ -9.16157335e-01  -4.00818834e-01   1.22464680e-16]
 [ -0.00000000e+00  -4.90861502e-17  -1.00000000e+00]
 [  4.00818834e-01  -9.16157335e-01   0.00000000e+00]]

In [18]:
print BiN2-Bo01
print BiN1-Bo02


[[ 0.03832264 -0.69909383  0.        ]
 [-0.          0.          0.        ]
 [-0.69909383 -0.03832264  0.        ]]
[[  3.83226431e-02  -6.99093827e-01   2.44929360e-16]
 [ -0.00000000e+00  -1.25579987e-17   0.00000000e+00]
 [  6.99093827e-01   3.83226431e-02   0.00000000e+00]]

In [20]:
TBi1 = np.concatenate((Bi1[:,1:,:], BiN1[:, 1:, np.newaxis]), axis=2)
TBo1 = np.concatenate((Bo01[:, 1:, np.newaxis], Bo1[:,1:,:]), axis=2)

TBi2 = np.concatenate((Bi2[:,1:,:], BiN2[:, 1:, np.newaxis]), axis=2)
TBo2 = np.concatenate((Bo02[:, 1:, np.newaxis], Bo2[:,1:,:]), axis=2)

In [21]:
B1=np.einsum('xv...,xw...->vw...', TBo1, TBi1)
B2=np.einsum('xv...,xw...->vw...', TBo2, TBi2)

In [22]:
print B1[:,:,2]


[[ -4.90861502e-17  -1.00000000e+00]
 [  1.00000000e+00  -4.90861502e-17]]

In [23]:
print B2[:,:,0]


[[ 0.0201116  -0.99979774]
 [ 0.99979774  0.0201116 ]]

In [24]:
r3d1[2]['B'][:,:,2,1]


Out[24]:
array([[ -4.90861502e-17,   1.00000000e+00],
       [ -1.00000000e+00,  -4.90861502e-17]])

In [25]:
r3d2[2]['B'][:,:,0,0]


Out[25]:
array([[ 0.0201116 ,  0.99979774],
       [-0.99979774,  0.0201116 ]])

In [26]:
np.shape(r3d1[2]['Bi'])


Out[26]:
(3, 3, 2, 6)

In [27]:
r3d1[2].keys()


Out[27]:
['BiN',
 'Bo',
 'aod',
 'sig2d',
 'aoa',
 'pt',
 'rayidx',
 'Bo0',
 'nstrwall',
 'scpr',
 'Bi',
 'si',
 'B',
 'sig',
 'rays',
 'nbrays',
 'vsi',
 'nstrswall',
 'theta',
 'norm',
 'dis']

In [28]:
r3d1[2]['Bi'][:,:,:,1]


Out[28]:
array([[[-0.91615733, -0.91615733],
        [-0.00599933,  0.        ],
        [-0.40077393,  0.40081883]],

       [[-0.        , -0.        ],
        [ 0.99988798, -1.        ],
        [-0.01496768,  0.        ]],

       [[-0.40081883, -0.40081883],
        [ 0.01371275,  0.        ],
        [ 0.91605471, -0.91615733]]])

In [29]:
r3d1[2]['Bo'][:,:,:,1]


Out[29]:
array([[[ 0.91615733,  0.91615733],
        [ 0.00599933,  0.        ],
        [-0.40077393, -0.40081883]],

       [[ 0.        ,  0.        ],
        [-0.99988798,  1.        ],
        [-0.01496768,  0.        ]],

       [[ 0.40081883, -0.40081883],
        [-0.01371275,  0.        ],
        [ 0.91605471, -0.91615733]]])

In [30]:
r3d2[2]['Bo'][:,:,::-1,0]


Out[30]:
array([[[-0.95447998, -0.95447998],
        [ 0.        , -0.00599879],
        [ 0.29827499, -0.29821466]],

       [[ 0.        ,  0.        ],
        [ 1.        ,  0.99979774],
        [ 0.        , -0.0201116 ]],

       [[ 0.29827499, -0.29827499],
        [-0.        ,  0.01919612],
        [ 0.95447998,  0.95428693]]])

In [31]:
r3d2[2]['Bi'][:,:,::-1,0]


Out[31]:
array([[[ 0.95447998,  0.95447998],
        [-0.        ,  0.00599879],
        [-0.29827499, -0.29821466]],

       [[-0.        , -0.        ],
        [-1.        , -0.99979774],
        [ 0.        , -0.0201116 ]],

       [[ 0.29827499,  0.29827499],
        [ 0.        , -0.01919612],
        [ 0.95447998,  0.95428693]]])

In [37]:
r3d2[2]['Bi'][:,:,::-1,0]-r3d1[2]['Bo'][:,:,:,1]


Out[37]:
array([[[ 0.,  0.],
        [-0.,  0.],
        [ 0.,  0.]],

       [[-0., -0.],
        [ 0.,  0.],
        [ 0.,  0.]],

       [[ 0.,  0.],
        [ 0.,  0.],
        [ 0.,  0.]]])

In [32]:
r3d2[2]['Bo'][:,:,::-1,0]-r3d1[2]['Bi'][:,:,:,1]


Out[32]:
array([[[ -3.83226431e-02,  -3.83226431e-02],
        [  5.99932787e-03,  -5.99878645e-03],
        [  6.99048927e-01,  -6.99033498e-01]],

       [[  0.00000000e+00,   0.00000000e+00],
        [  1.12021990e-04,   1.99979774e+00],
        [  1.49676796e-02,  -2.01115970e-02]],

       [[  6.99093827e-01,   1.02543841e-01],
        [ -1.37127494e-02,   1.91961166e-02],
        [  3.84252729e-02,   1.87044426e+00]]])

In [33]:
np.shape(r3d1[2]['Bo'][:,:,:,1])


Out[33]:
(3, 3, 2)

In [34]:
r3d1[2]['B'][:,:,:,1]


Out[34]:
array([[[ -1.49676796e-02,   9.99887978e-01,  -4.90861502e-17],
        [  9.99887978e-01,   1.49676796e-02,   1.00000000e+00]],

       [[ -9.99887978e-01,   1.49676796e-02,  -1.00000000e+00],
        [ -1.49676796e-02,  -9.99887978e-01,  -4.90861502e-17]]])

In [41]:
r3d2[2]['B'][:,:,::-1,0]


Out[41]:
array([[[ 0.        , -0.99979774,  0.0201116 ],
        [ 1.        ,  0.0201116 , -0.99979774]],

       [[-1.        ,  0.0201116 ,  0.99979774],
        [ 0.        ,  0.99979774,  0.0201116 ]]])

In [49]:
cir1.plot()


Out[49]:
(<matplotlib.figure.Figure at 0x7f896e2feb10>,
 array([[<matplotlib.axes.AxesSubplot object at 0x7f896fe0bc50>]], dtype=object))

In [50]:
cir2.plot()


Out[50]:
(<matplotlib.figure.Figure at 0x7f896e2fa790>,
 array([[<matplotlib.axes.AxesSubplot object at 0x7f893b293990>]], dtype=object))

In [44]:
print np.shape(r3d1[2]['Bi'])
print np.shape(r3d1[2]['pt'])
print r3d1[2]['pt']


(3, 3, 2, 6)
(3, 4, 6)
[[[  7.59000000e+02   7.59000000e+02   7.59000000e+02   7.59000000e+02
     7.59000000e+02   7.59000000e+02]
  [  7.62200000e+02   7.63502592e+02   7.62936596e+02   7.58502390e+02
     7.63062691e+02   7.63502544e+02]
  [  7.63502592e+02   7.63571429e+02   7.63491780e+02   7.63502607e+02
     7.63514435e+02   7.68502653e+02]
  [  7.67000000e+02   7.67000000e+02   7.67000000e+02   7.67000000e+02
     7.67000000e+02   7.67000000e+02]]

 [[  1.11400000e+03   1.11400000e+03   1.11400000e+03   1.11400000e+03
     1.11400000e+03   1.11400000e+03]
  [  1.11400000e+03   1.11400000e+03   1.11592757e+03   1.11399389e+03
     1.11192910e+03   1.11400799e+03]
  [  1.11400000e+03   1.11400000e+03   1.11566420e+03   1.11399748e+03
     1.11216670e+03   1.11401687e+03]
  [  1.11400000e+03   1.11400000e+03   1.11400000e+03   1.11400000e+03
     1.11400000e+03   1.11400000e+03]]

 [[  1.00000000e+00   1.00000000e+00   1.00000000e+00   1.00000000e+00
     1.00000000e+00   1.00000000e+00]
  [  0.00000000e+00   2.96988400e+00   1.24678417e+00   1.02766167e+00
     1.25308984e+00   1.20456070e+00]
  [  4.07060000e-01   3.00000000e+00   1.28138112e+00   1.30559796e+00
     1.28141889e+00   1.43172690e+00]
  [  1.50000000e+00   1.50000000e+00   1.50000000e+00   1.50000000e+00
     1.50000000e+00   1.50000000e+00]]]

In [45]:
G=geu.GeomVect()
G.geomBase(r3d1[2]['Bi'][:,:,0,0])
G.show3()
G.filename


Out[45]:
'/private/staff/t/ot/niamiot/Bureau/P1/geom/geomdef.vect'

In [46]:
fGHz=np.arange(2,11,0.1)
wav = wvf.Waveform(fcGHz=5,bandGHz=3)
C1=r3d1.eval(fGHz)
sc1=C1.prop2tran(a='theta',b='theta')
cir1 = sc1.applywavB(wav.sfg)

In [47]:
rx=array([759,1114,1.0])
tx=array([767,1114,1.5])
S.tx.clear()
S.rx.clear()
S.tx.point(tx)
S.rx.point(rx)
Ctx = S.L.pt2cy(S.tx.position[:,0])
Crx = S.L.pt2cy(S.rx.position[:,0])

In [48]:
Si2 = Signatures(S.L,Ctx,Crx)
Si2.run4(cutoff=5,algo='old')
r2d2 = Si2.rays(tx,rx)
r3d2 = r2d2.to3D(S.L)
r3d2.locbas(S.L)
r3d2.fillinter(S.L)

In [49]:
fGHz=np.arange(2,11,0.1)
wav = wvf.Waveform(fcGHz=5,bandGHz=3)
C2=r3d2.eval(fGHz)
sc2=C2.prop2tran(a='theta',b='theta')
cir2 = sc2.applywavB(wav.sfg)

In [50]:
len(C2.tauk)


Out[50]:
315

In [51]:
r3d1.signature(3,3)


Out[51]:
array([[0, 5, 3, 0, 0],
       [0, 1, 2, 5, 0]])

In [52]:
r3d2.signature(3,7)


Out[52]:
array([[0, 3, 5, 4, 0],
       [0, 2, 1, 1, 0]])

In [53]:
r31 = r3d1.extract(3,3)
r32 = r3d2.extract(3,7)

In [54]:
r31.locbas(S.L)
r31.fillinter(S.L)
r31.nray=1

In [55]:
r32.locbas(S.L)
r32.fillinter(S.L)
r32.nray=1

In [56]:
C1 = r31.eval(fGHz)
C2 = r32.eval(fGHz)

In [57]:
sc1=C1.prop2tran(a='theta',b='theta')
cir1 = sc1.applywavB(wav.sfg)
sc2=C2.prop2tran(a='theta',b='theta')
cir2 = sc2.applywavB(wav.sfg)

In [58]:
cir1.plot(types='v')
cir2.plot(types='v')


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-58-73875bbb21dc> in <module>()
----> 1 cir1.plot(types='v')
      2 cir2.plot(types='v')

/private/staff/t/ot/niamiot/Documents/Code/pylayers/pylayers/signal/bsignal.py in plot(self, **kwargs)
   1086 #                plt.ylabel('Voltage (mV)')
   1087 
-> 1088         fig,ax = Bsignal.plot(self,**kwargs)
   1089 
   1090         return(fig,ax)

/private/staff/t/ot/niamiot/Documents/Code/pylayers/pylayers/signal/bsignal.py in plot(self, **kwargs)
    449         if ndim > 1:
    450             yx = self.y[...,u]
--> 451             fig,ax = mulcplot(self.x[u],yx*conversion,**args)
    452         else:
    453             fig,ax = mulcplot(self.x[u],self.y[u]*conversion,**args)

/private/staff/t/ot/niamiot/Documents/Code/pylayers/pylayers/util/plotutil.py in mulcplot(x, y, **kwargs)
    327                     ax[l,c].plot(x,10*np.log10(np.abs(y[k%nfigy,:])),label=labels[k%nlabels],**args)
    328                 if types[k%ntypes]=='l20':
--> 329                     ax[l,c].plot(x,20*np.log10(np.abs(y[k%nfigy,:])),label=labels[k%nlabels],**args)
    330                 if types[k%ntypes]=='re':
    331                     ax[l,c].plot(x,np.real(y[k%nfigy,:]),label=labels[k%nlabels],**args)

/usr/local/lib/python2.7/site-packages/matplotlib/axes.pyc in plot(self, *args, **kwargs)
   3846         lines = []
   3847 
-> 3848         for line in self._get_lines(*args, **kwargs):
   3849             self.add_line(line)
   3850             lines.append(line)

/usr/local/lib/python2.7/site-packages/matplotlib/axes.pyc in _grab_next_args(self, *args, **kwargs)
    321                 return
    322             if len(remaining) <= 3:
--> 323                 for seg in self._plot_args(remaining, kwargs):
    324                     yield seg
    325                 return

/usr/local/lib/python2.7/site-packages/matplotlib/axes.pyc in _plot_args(self, tup, kwargs)
    308         ncx, ncy = x.shape[1], y.shape[1]
    309         for j in xrange(max(ncx, ncy)):
--> 310             seg = func(x[:,j%ncx], y[:,j%ncy], kw, kwargs)
    311             ret.append(seg)
    312         return ret

/usr/local/lib/python2.7/site-packages/matplotlib/axes.pyc in _makeline(self, x, y, kw, kwargs)
    258                      **kw
    259                      )
--> 260         self.set_lineprops(seg, **kwargs)
    261         return seg
    262 

/usr/local/lib/python2.7/site-packages/matplotlib/axes.pyc in set_lineprops(self, line, **kwargs)
    199             funcName = "set_%s"%key
    200             if not hasattr(line,funcName):
--> 201                 raise TypeError, 'There is no line property "%s"'%key
    202             func = getattr(line,funcName)
    203             func(val)

TypeError: There is no line property "types"

In [ ]:
r2 = r2d.extract(2,1)
q2 = r2.reciprocal()

In [26]:
r2.show(S.L)


Out[26]:
(<matplotlib.figure.Figure at 0xb606cec>,
 <matplotlib.axes.AxesSubplot at 0xb47586c>)

In [27]:
q2.show(S.L)


Out[27]:
(<matplotlib.figure.Figure at 0xc59c20c>,
 <matplotlib.axes.AxesSubplot at 0xc920a6c>)

In [28]:
q2[2]


Out[28]:
{'alpha': array([[ 0.43716222],
        [ 0.49382031]]), 'pt': array([[[  763.51443532],
         [  763.06269126]],
 
        [[ 1112.16670206],
         [ 1111.92909882]],
 
        [[    1.28141889],
         [    1.25308984]]]), 'sig': array([[[2],
         [9]],
 
        [[2],
         [1]]])}

In [29]:
r3 = r2.to3D(S.L)
r3.locbas(S.L)
r3.fillinter(S.L)
q3 = q2.to3D(S.L)
q3.locbas(S.L)
q3.fillinter(S.L)


> /private/staff/t/ot/niamiot/Documents/Code/pylayers/pylayers/antprop/rays.py(1048)fillinter()
-> if k !=0:
(Pdb) c
> /private/staff/t/ot/niamiot/Documents/Code/pylayers/pylayers/antprop/rays.py(1048)fillinter()
-> if k !=0:
(Pdb) c

In [30]:
r3


Out[30]:
Rays3D
----------
2 / 1 : [0]
3 / 2 : [1 2]
4 / 2 : [3 4]
-----
ni : 16
nl : 37

In [31]:
q3


Out[31]:
Rays3D
----------
2 / 1 : [0]
3 / 2 : [1 2]
4 / 2 : [3 4]
-----
ni : 16
nl : 37

In [32]:
Cr=r3.eval(fGHz)
Cr.sort()
scr=Cr.prop2tran(a='theta',b='theta')
Cq=q3.eval(fGHz)
Cq.sort()
scq=Cq.prop2tran(a='theta',b='theta')

In [33]:
scr


Out[33]:
freq :2.0 10.9 90
shape  :(5, 90)
tau :30.0754329983 37.0296953364
dist :9.0226298995 11.1089086009

In [34]:
scq


Out[34]:
freq :2.0 10.9 90
shape  :(5, 90)
tau :30.0754329983 37.0296953364
dist :9.0226298995 11.1089086009

In [35]:
scq.RSSI()


Out[35]:
-214.48794517208708

In [36]:
scr.RSSI()


Out[36]:
-201.66023304796383

In [37]:
print scr.doa
print scq.dod


[[ 1.62624094 -2.65738656]
 [ 1.84149225 -2.65738656]
 [ 1.20023375 -2.65738656]
 [ 1.02267995 -2.65738656]
 [ 2.1958194  -2.65738656]]
[[ 1.62624094 -2.65738656]
 [ 1.84149225 -2.65738656]
 [ 1.20023375 -2.65738656]
 [ 1.02267995 -2.65738656]
 [ 2.1958194  -2.65738656]]

In [38]:
print scr.dod
print scq.doa


[[ 1.51535171 -0.47140627]
 [ 1.84149225 -0.47140627]
 [ 1.20023375 -0.47140627]
 [ 2.1189127  -0.47140627]
 [ 0.94577325 -0.47140627]]
[[ 1.51535171 -0.47140627]
 [ 1.84149225 -0.47140627]
 [ 1.20023375 -0.47140627]
 [ 2.1189127  -0.47140627]
 [ 0.94577325 -0.47140627]]

In [39]:
-2.65738-0.47140627


Out[39]:
-3.12878627

In [53]:
r3[2]


Out[53]:
{'B': array([[[[ 0.99958853],
          [ 0.99085166],
          [ 0.99431503]],
 
         [[-0.02868413],
          [-0.13495552],
          [-0.10647828]]],
 
 
        [[[ 0.02868413],
          [-0.13495552],
          [ 0.10647828]],
 
         [[ 0.99958853],
          [-0.99085166],
          [ 0.99431503]]]]), 'Bo0': array([[[ 0.88956147],
         [ 0.049372  ],
         [ 0.45413962]],
 
        [[-0.45344176],
         [-0.0251667 ],
         [ 0.89093053]],
 
        [[ 0.05541622],
         [-0.99846334],
         [ 0.        ]]]), 'aoa': array([[ 1.62624094],
        [-2.65738656]]), 'aod': array([[ 1.51535171],
        [-0.47140627]]), 'dis': array([ 9.0226299]), 'nbrays': 1, 'norm': array([[[-0.00639987],
         [ 0.99997778]],
 
        [[ 0.99997952],
         [ 0.00666652]],
 
        [[ 0.        ],
         [ 0.        ]]]), 'nstrswall': array([9, 2]), 'nstrwall': array([9, 2]), 'pt': array([[[  7.59000000e+02],
         [  7.63062691e+02],
         [  7.63514435e+02],
         [  7.67000000e+02]],
 
        [[  1.11400000e+03],
         [  1.11192910e+03],
         [  1.11216670e+03],
         [  1.11400000e+03]],
 
        [[  1.00000000e+00],
         [  1.25308984e+00],
         [  1.28141889e+00],
         [  1.50000000e+00]]]), 'rayidx': array([0]), 'rays': array([[0],
        [1]]), 'scpr': array([[-0.45912556],
        [ 0.88676368]]), 'si': array([[ 4.56707198],
        [ 0.51120498],
        [ 3.94435295]]), 'sig': array([[[0],
         [9],
         [2],
         [0]],
 
        [[0],
         [1],
         [2],
         [0]]]), 'theta': array([[ 1.0937857 ],
        [ 0.48050052]]), 'vsi': array([[[ 0.88956147],
         [ 0.88368478],
         [ 0.88368478]],
 
        [[-0.45344176],
         [ 0.46479054],
         [ 0.46479054]],
 
        [[ 0.05541622],
         [ 0.05541622],
         [ 0.05541622]]])}

In [40]:
print scr.tau0
print scq.tau0


[ 30.075433    31.1640552   32.21591227  35.18330575  37.02969534]
[ 30.075433    31.1640552   32.21591227  35.18330575  37.02969534]

In [41]:
r = 1
print Cr.Ctt.y[r,0],Cr.Ctp.y[r,0]
print Cr.Cpt.y[r,0],Cr.Cpp.y[r,0]
print "---"
print Cq.Ctt.y[r,0],Cq.Ctp.y[r,0]
print Cq.Cpt.y[r,0],Cq.Cpp.y[r,0]


(0.000817805186098+0.000490962427123j) (0.000177146672464-0.000293892048238j)
(0.00101281359052+0.000812161706468j) (-0.00074956662285-0.000177517586845j)
---
(0.000601895414567-1.06109476407e-05j) (-0.000214054414722+0.000221967290327j)
(-0.000886458220214-0.000686862202976j) (-0.000987448491684-0.000697154906243j)

Quand on parcours les bases locales à l'envers on n'observe pas de transposition !


In [42]:
print r3[4]['B'][:,:,1,0]
print q3[4]['B'][:,:,-2,0]


[[ 0.28997035 -0.95703563]
 [-0.95703563 -0.28997035]]
[[ 0.28997035 -0.95703563]
 [-0.95703563 -0.28997035]]

In [43]:
print r3[4]['sig'][:,:,0]
print q3[4]['sig'][:,::-1,0]


[[0 0 9 2 0 0]
 [0 4 1 2 5 0]]
[[0 0 9 2 0 0]
 [0 4 1 2 5 0]]

In [44]:
print r3[4]['sig'][:,:,0]
print q3[4]['sig'][:,::,0]


[[0 0 9 2 0 0]
 [0 4 1 2 5 0]]
[[0 0 2 9 0 0]
 [0 5 2 1 4 0]]

In [45]:
print r3.ray2nbi
print q3.ray2nbi


[ 2.  3.  3.  4.  4.]
[ 2.  3.  3.  4.  4.]

In [46]:
print r3.I.I[0,0]
print q3.I.I[0,0]


[[-0.64527526+0.10793555j  0.00000000+0.j        ]
 [ 0.00000000+0.j          0.04168686-0.12035459j]]
[[ 0.11860977+0.03985772j  0.00000000+0.j        ]
 [ 0.00000000+0.j          0.12910212+0.03839063j]]

In [47]:
print r3.I.R.A[0,0,:,:]
print q3.I.R.A[0,0,:,:]


[[-0.64527526+0.10793555j  0.00000000+0.j        ]
 [ 0.00000000+0.j          0.04168686-0.12035459j]]
[[-0.64527526+0.10793555j  0.00000000+0.j        ]
 [ 0.00000000+0.j          0.04168686-0.12035459j]]

In [48]:
print r3.I.T.A[0,0,:,:]
print q3.I.T.A[0,0,:,:]


[[ 0.11860977+0.03985772j  0.00000000+0.j        ]
 [ 0.00000000+0.j          0.12910212+0.03839063j]]
[[ 0.11860977+0.03985772j  0.00000000+0.j        ]
 [ 0.00000000+0.j          0.12910212+0.03839063j]]

In [49]:
print r3.I.I[0,1]
print q3.I.I[0,-2]


[[ 0.11860977+0.03985772j  0.00000000+0.j        ]
 [ 0.00000000+0.j          0.12910212+0.03839063j]]
[[-0.68898310+0.09905839j  0.00000000+0.j        ]
 [ 0.00000000+0.j         -0.03467441-0.11722798j]]

In [104]:
i = 2
r = 0
a3=r3.extract(i,r)

In [105]:
a3.to3D(S.L)
b3 = a3.reciprocal()
b3.locbas(S.L)

In [106]:
np.shape(a3[i]['B'])


Out[106]:
(2, 2, 3, 1)

In [117]:
a3.info(0)


Rays have not been evaluated yet

In [108]:
a3r = a3[i]['B'].reshape(2,6,order='F')
plt.imshow(a3r,interpolation='nearest',cmap='PuOr')
colorbar()


Out[108]:
<matplotlib.colorbar.Colorbar instance at 0xf12ee8c>

In [115]:
b3[i]['B']


Out[115]:
array([[[[ 0.99431503],
         [ 0.99085166],
         [ 0.99958853]],

        [[ 0.10647828],
         [-0.13495552],
         [ 0.02868413]]],


       [[[-0.10647828],
         [-0.13495552],
         [-0.02868413]],

        [[ 0.99431503],
         [-0.99085166],
         [ 0.99958853]]]])

In [127]:
r3


Out[127]:
Rays3D
----------
2 / 1 : [0]
3 / 2 : [1 2]
4 / 2 : [3 4]
-----
ni : 16
nl : 37

In [119]:
b3r = b3[i]['B'].reshape(2,6,order='F')
plt.imshow(b3r,interpolation='nearest',cmap='PuOr')
colorbar()


Out[119]:
<matplotlib.colorbar.Colorbar instance at 0x100ff8ec>

In [125]:
import pylayers.util.geomutil as geu
pyu.getlong(S.L.filename,"geom")


Out[125]:
'/private/staff/t/ot/niamiot/Bureau/P1/geom/defstr.ini'

In [5]:
print np.shape(r3[3]['Bo'])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-2b0e647bb8da> in <module>()
----> 1 print np.shape(r3[3]['Bo'])
      2 

NameError: name 'r3' is not defined

In [ ]:
def showBases(L=[],r3):
    
    
    
    baselist = geu.Geomlist(bases,clear=True)
    baselist.append("LIST\n")
    if L!=[]:
        filestruc = pyu.getlong(L.filename,"geom")
        baselist.append('{<'+filestruc+'}\n')