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 
from pylayers.antprop.antenna import *
import copy
import time


<matplotlib.figure.Figure at 0xbb9730c>

In [2]:
S = Simul()
filestr = 'd24'
S.layout(filestr+'.ini','matDB.ini','slabDB.ini')
try:
    S.L.dumpr()
except:
    S.L.build()
    S.L.dumpw()

S.tx.clear()
S.rx.clear()

In [3]:
tx=np.array((13.3,3.,1.35))
rx=np.array((5.3,3.,1.34))

In [4]:
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)

In [5]:
try: 
    Si1 = Signatures(S.L,ctx,crx)
    Si1.filename='d24_1_1_4.sig'
    Si1.load()
except:
    Si1.run4(cutoff=4,algo='old')
    Si1.save()

#sc1 = C1.prop2tran(a='theta',b='theta')
#cir1 = sc1.applywavB(wav.sfg)


r2d = Si1.rays(tx,rx)
r3d1 = r2d.to3D(S.L)
r3d1.locbas(S.L)
r3d1.fillinter(S.L)
C1 = r3d1.eval(fGHz)
C1save = copy.copy(C1)

radiation for all rays


In [6]:
tx=np.array((13.3,3.,1.35))
rx=np.array((6.3,3.,1.34))
# angle tx
a_tx = 0
# angle rx
a_rx = 0
Ttx=np.array(([[np.cos(a_tx),np.sin(a_tx),0],[-np.sin(a_tx),np.cos(a_tx),0],[0,0,1]])).T 
Trx=np.array(([[np.cos(a_rx),np.sin(a_rx),0],[-np.sin(a_rx),np.cos(a_rx),0],[0,0,1]])).T 
S.tx.orientation=Ttx
S.rx.orientation=Trx

C1r=C1.locbas(Tt=Ttx, Tr=Trx)
sca1=C1r.prop2tran(a=S.tx.A,b=S.rx.A)
#sca1.plotd(d='dod',colorbar=True,normalise=False,polar=True,reverse=True)
#C1r.doadod(polar=True)
#C1r.plotd(d='doa',polar=True,reverse=True,normalise=False,colorbar=True,cmap=plt.cm.jet,mode='mean')#plt.figure()
sca1.plotd(d='doa',polar=True,reverse=True,normalise=False,colorbar=True,cmap=plt.cm.jet)


Out[6]:
(<matplotlib.figure.Figure at 0xc254c4c>,
 <matplotlib.axes.PolarAxesSubplot at 0xbc2f08c>)

In [20]:
tx=np.array((13.3,3.,1.35))
rx=np.array((6.3,3.,1.34))
C1.locbas(b2g=True)
#S.tx.point(tx)
#S.rx.point(rx)
S.tx.A=Antenna()
S.rx.A=Antenna('S2R2.sh3')
# angle tx
a_tx = 0
# angle rx
a_rx = 0
Ttx=np.array(([[np.cos(a_tx),np.sin(a_tx),0],[-np.sin(a_tx),np.cos(a_tx),0],[0,0,1]])).T 
Trx=np.array(([[np.cos(a_rx),np.sin(a_rx),0],[-np.sin(a_rx),np.cos(a_rx),0],[0,0,1]])).T 
S.tx.orientation=Ttx
S.rx.orientation=Trx
C1r=C1.locbas(Tt=Ttx, Tr=Trx)
sca1=C1r.prop2tran(a=S.tx.A,b=S.rx.A)
#sca1.plotd(d='dod',colorbar=True,normalise=False,polar=True,reverse=True)
#C1r.doadod(polar=True)

#C1r.plotd(d='doa',polar=True,reverse=True,normalise=False,colorbar=True,cmap=plt.cm.jet,mode='mean')

#sca1.plotd(d='doa',polar=True,reverse=True,normalise=False,colorbar=True,cmap=plt.cm.jet)
sca1.plotd(d='doa',polar=True,reverse=True)
#S.show3(rays=r3d1)


Out[20]:
(<matplotlib.figure.Figure at 0xc0a7ecc>,
 <matplotlib.axes.PolarAxesSubplot at 0xd311b0c>)

In [ ]:

radiation for a limited number of rays


In [13]:
r2d = Si1.rays(tx,rx)
r3d1 = r2d.to3D(S.L)
r3d1.locbas(S.L)
r2d1e=r2d.extract(1,3)
r3d1e=r2d1e.to3D(S.L)
r3d1e.locbas(S.L)
r3d1e.fillinter(S.L)
C1e = r3d1e.eval(fGHz)


no T interaction to evaluate

In [19]:
tx=np.array((13.3,3.,1.35))
rx=np.array((6.3,3.,1.34))
#C1.locbas(b2g=True)
#S.tx.point(tx)
#S.rx.point(rx)
#S.tx.A=Antenna()
#S.rx.A=Antenna()
# angle tx
a_tx = 0
# angle rx
a_rx = np.pi
Ttx=np.array(([[np.cos(a_tx),np.sin(a_tx),0],[-np.sin(a_tx),np.cos(a_tx),0],[0,0,1]])).T 
Trx=np.array(([[np.cos(a_rx),np.sin(a_rx),0],[-np.sin(a_rx),np.cos(a_rx),0],[0,0,1]])).T 
print Ttx
print Trx
#S.tx.orientation=Ttx
#S.rx.orientation=Trx
C1er=C1e.locbas(Tt=Ttx, Tr=Trx)
scae1=C1er.prop2tran(a=S.tx.A,b=S.rx.A)
#sca1.plotd(d='dod',colorbar=True,normalise=False,polar=True,reverse=True)
C1e.plotd(d='doa',polar=True,reverse=True,normalise=False,colorbar=True,cmap=plt.cm.jet)
#plt.figure()
#scae1.plotd(d='doa',polar=True,reverse=True,normalise=False,colorbar=True,cmap=plt.cm.jet)
S.show3(rays=r3d1e)


[[ 1. -0.  0.]
 [ 0.  1.  0.]
 [ 0.  0.  1.]]
[[ -1.00000000e+00  -1.22460635e-16   0.00000000e+00]
 [  1.22460635e-16  -1.00000000e+00   0.00000000e+00]
 [  0.00000000e+00   0.00000000e+00   1.00000000e+00]]

In [21]:
np.sin(pi)


Out[21]:
1.2246063538223773e-16

In [33]:
tx=np.array((13.3,3.,1.35))
rx=np.array((6.3,3.,1.34))
#C1.locbas(b2g=True)
#S.tx.point(tx)
#S.rx.point(rx)
#S.tx.A=Antenna()
#S.rx.A=Antenna()
# angle tx
a_tx = 0
# angle rx
a_rx = 0
Ttx=np.array(([[np.cos(a_tx),np.sin(a_tx),0],[-np.sin(a_tx),np.cos(a_tx),0],[0,0,1]])).T 
Trx=np.array(([[np.cos(a_rx),np.sin(a_rx),0],[-np.sin(a_rx),np.cos(a_rx),0],[0,0,1]])).T 
#S.tx.orientation=Ttx
#S.rx.orientation=Trx
C1er=C1e.locbas(Tt=Ttx, Tr=Trx)
#scae1=C1er.prop2tran(a=S.tx.A,b=S.rx.A)
#sca1.plotd(d='dod',colorbar=True,normalise=False,polar=True,reverse=True)
C1e.plotd(d='doa',polar=True,reverse=True,normalise=False,colorbar=True,cmap=plt.cm.jet)


Out[33]:
(<matplotlib.figure.Figure at 0xcc3a7ec>,
 <matplotlib.axes.PolarAxesSubplot at 0xc70eb2c>)

In [10]:
r2d1e=r2d.extract(1,3)
r3d1e=r2d1e.to3D(S.L)
r3d1e.locbas(S.L)
r3d1e.fillinter(S.L)
C1 = r3d1e.eval(fGHz)
r3d1e.show3(S.L)


no T interaction to evaluate

In [14]:
phl=[0,2*np.pi,np.pi/2,np.pi,-np.pi,-np.pi/2]
!killall -9 gvx
C1.locbas(b2g=True)
for ph in phl:
    print ph
    plt.figure()
    tx=np.array((13.3,3.,1.35))
    rx=np.array((6.3,3.,1.34))
    S.tx.point(tx)
    S.rx.point(rx)
    S.tx.A=Antenna()
    S.rx.A=Antenna()
    Ttx = np.eye(3)
    Trx=np.array(([[np.cos(ph),np.sin(ph),0],[-np.sin(ph),np.cos(ph),0],[0,0,1]])).T 
    S.tx.orientation=Ttx
    S.rx.orientation=Trx
    C1r=C1.locbas(Tt=Ttx, Tr=Trx)
    
    C1r.doadod(colorbar=True,normalise=False,polar=False,title=str(ph))
    #sca1=C1r.prop2tran(a=S.tx.A,b=S.rx.A)
    #sca1.plotd(d='doa',colorbar=True,normalise=False,polar=True)
    #S.show3()


gvx: aucun processus trouvé
0
6.28318530718
1.57079632679
3.14159265359
-3.14159265359
-1.57079632679

In [ ]:


In [27]:
tx=np.array((13.3,3.,1.35))
rx=np.array((6.3,3.,1.34))
S.tx.point(tx)
S.rx.point(rx)
S.tx.A=Antenna(pattern=True)
S.rx.A=Antenna(pattern=True)

sca1=C1.prop2tran(a=S.tx.A,b=S.rx.A)
sca1.plotd(d='doa',polar=True,colorbar=True)
#S.show3()


Out[27]:
(<matplotlib.figure.Figure at 0xb7a518c>,
 <matplotlib.axes.PolarAxesSubplot at 0xb3489ec>)

In [12]:
sca1.plotd(d='doa',polar=False,colorbar=True)


Out[12]:
(<matplotlib.figure.Figure at 0xb03dd2c>,
 <matplotlib.axes.AxesSubplot at 0xb03d74c>)

In [38]:
S.show3(L=S.L,centered=False)

In [8]:
r2d = Si1.rays(tx,rx)
r3d1 = r2d.to3D(S.L)
r3d1.locbas(S.L)
r3d1.fillinter(S.L)
C1 = r3d1.eval(fGHz)

In [18]:
!killall -9 gvx

In [26]:
S.tx.A=Antenna('S2R2.sh3')
S.rx.A=Antenna(pattern=True)
S.tx.A.p0=0
S.tx.A.t0=-np.pi/2
S.tx.A.t3=0.001


Out[26]:
(<matplotlib.figure.Figure at 0xc95258c>,
 <matplotlib.axes.PolarAxesSubplot at 0xc8fbf8c>)

In [23]:
S.show3()

In [21]:
S.tx.A=Antenna('S2R2.sh3')
S.tx.A=Antenna(pattern=True)
S.tx.A.p0=0
S.tx.A.t0=np.pi/2
S.show3(rays=r3d1,L=S.L,centered =False)

In [9]:
r3d1.show3(S.L,ilist=[2],raylist=[11,12])

In [25]:
doa = C1.rang
Ett,Epp,Etp,Ept = C1.energy()

Etot = Ett+Epp+Etp+Ept
Emax = max(Etot)
Etot = Etot / Emax + 1e-7
Emax = max(10 * np.log10(Etot))
Emin = min(10 * np.log10(Etot))
 #col  = 1 - (10*log10(Etot)-Emin)/(Emax-Emin)
al = 180. / np.pi
col = 10 * np.log10(Etot)
if len(col) != len(doa):
    print "len(col):", len(col)
    print "len(dod):", len(dod)
plt.subplot(111,polar=True)
plt.scatter(doa[:, 0] * al, doa[:, 1] * al, s=30, c=col,
            cmap=plt.cm.jet, edgecolors='none')
plt.colorbar()
#scatter(dod[:,0]*al,dod[:,1]*al,s=s)


Out[25]:
<matplotlib.colorbar.Colorbar instance at 0xcbe778c>

In [31]:
>>> from pylayers.util.geomutil import *
           >>> import numpy as np 
           >>> th = np.arange(0,np.pi,0.05)[:,np.newaxis]
           >>> ph = np.arange(0,2*np.pi,0.05)[np.newaxis,:]
           >>> E = 1.5*np.sin(th)*np.cos(0*ph)
           >>> g = Geomoff('dipole')
           >>> g.pattern(th,ph,E)
           >>> g.show3()

In [ ]:


In [101]:
dod*al


Out[101]:
array([[  8.99283803e+01,   0.00000000e+00],
       [  9.00575455e+01,  -1.43541072e+02],
       [  9.00572476e+01,   1.43065985e+02],
       [  9.00503124e+01,   0.00000000e+00],
       [  9.00308256e+01,   1.79928792e+02],
       [  1.05118779e+02,  -1.43541072e+02],
       [  1.05044086e+02,   1.43065985e+02],
       [  7.16109966e+01,  -1.43541072e+02],
       [  7.16998138e+01,   1.43065985e+02],
       [  1.03290426e+02,   0.00000000e+00],
       [  7.37931329e+01,   0.00000000e+00],
       [  9.00444896e+01,   2.78385232e+01],
       [  9.00398746e+01,   1.23869708e+02],
       [  9.00398502e+01,  -1.23894155e+02],
       [  9.82349063e+01,   1.79928792e+02],
       [  7.99025824e+01,   1.79928792e+02],
       [  9.00293643e+01,  -1.62364429e+02],
       [  9.00293393e+01,   1.62135069e+02],
       [  9.00260731e+01,   6.02297251e-02],
       [  9.00150877e+01,   1.79837494e+02],
       [  5.89684393e+01,  -1.43541072e+02],
       [  1.21115991e+02,  -1.43541072e+02],
       [  5.90996105e+01,   1.43065985e+02],
       [  1.20984615e+02,   1.43065985e+02],
       [  6.22559766e+01,   0.00000000e+00],
       [  1.17822785e+02,   0.00000000e+00],
       [  1.01798079e+02,   2.78385232e+01],
       [  7.55859209e+01,   2.78385232e+01],
       [  1.00603528e+02,   1.23869708e+02],
       [  1.00597180e+02,  -1.23894155e+02],
       [  7.70278047e+01,   1.23869708e+02],
       [  7.70354813e+01,  -1.23894155e+02],
       [  9.00347274e+01,   4.63132392e+01],
       [  9.00347050e+01,  -4.62709758e+01],
       [  7.21375942e+01,   1.79928792e+02],
       [  1.07918239e+02,   1.79928792e+02],
       [  9.00292664e+01,  -1.14240111e+02],
       [  9.00291478e+01,   1.14092068e+02],
       [  9.78495224e+01,  -1.62364429e+02],
       [  9.78429085e+01,   1.62135069e+02],
       [  8.03720660e+01,  -1.62364429e+02],
       [  8.03801271e+01,   1.62135069e+02],
       [  9.00259469e+01,  -1.47312895e+02],
       [  9.00259388e+01,   1.47385442e+02],
       [  9.69789340e+01,   6.02297251e-02],
       [  8.14342081e+01,   6.02297251e-02],
       [  9.00251695e+01,  -1.50512113e+01],
       [  9.00251550e+01,   1.52495327e+01],
       [  9.40518360e+01,   1.79837494e+02],
       [  8.50185455e+01,   1.79837494e+02],
       [  9.00149055e+01,   1.70836327e+02],
       [  9.00149043e+01,  -1.71230484e+02],
       [  6.50560272e+01,   2.78385232e+01],
       [  1.15017083e+02,   2.78385232e+01],
       [  6.73702190e+01,   1.23869708e+02],
       [  1.12697690e+02,   1.23869708e+02],
       [  6.73826831e+01,  -1.23894155e+02],
       [  1.12685196e+02,  -1.23894155e+02],
       [  9.92601832e+01,   4.63132392e+01],
       [  9.92543222e+01,  -4.62709758e+01],
       [  7.86558359e+01,   4.63132392e+01],
       [  7.86629531e+01,  -4.62709758e+01],
       [  9.78236830e+01,  -1.14240111e+02],
       [  9.77923647e+01,   1.14092068e+02],
       [  8.04035599e+01,  -1.14240111e+02],
       [  8.04417343e+01,   1.14092068e+02],
       [  7.29340386e+01,  -1.62364429e+02],
       [  1.07119617e+02,  -1.62364429e+02],
       [  7.29477544e+01,   1.62135069e+02],
       [  1.07105863e+02,   1.62135069e+02],
       [  9.00270311e+01,  -5.73487224e+01],
       [  9.69454829e+01,  -1.47312895e+02],
       [  9.69433356e+01,   1.47385442e+02],
       [  8.14750606e+01,  -1.47312895e+02],
       [  8.14776831e+01,   1.47385442e+02],
       [  7.47526588e+01,   6.02297251e-02],
       [  1.05295870e+02,   6.02297251e-02],
       [  9.67393446e+01,  -1.50512113e+01],
       [  9.67355040e+01,   1.52495327e+01],
       [  8.17268728e+01,  -1.50512113e+01],
       [  8.17315653e+01,   1.52495327e+01],
       [  9.00229170e+01,  -2.83975417e+01],
       [  9.00229100e+01,   2.84820238e+01],
       [  9.00227441e+01,  -1.08708214e+02],
       [  9.00222304e+01,  -1.36339142e+02],
       [  9.00221814e+01,   1.36012513e+02],
       [  8.10362928e+01,   1.79837494e+02],
       [  9.89931477e+01,   1.79837494e+02],
       [  9.40030667e+01,   1.70836327e+02],
       [  9.40027436e+01,  -1.71230484e+02],
       [  8.50784035e+01,   1.70836327e+02],
       [  8.50788001e+01,  -1.71230484e+02],
       [  9.00143942e+01,   1.62722260e+02],
       [  7.00461609e+01,   4.63132392e+01],
       [  1.10015181e+02,   4.63132392e+01],
       [  7.00579994e+01,  -4.62709758e+01],
       [  1.10003312e+02,  -4.62709758e+01],
       [  7.29876327e+01,  -1.14240111e+02],
       [  1.07065874e+02,  -1.14240111e+02],
       [  7.30526231e+01,   1.14092068e+02],
       [  1.07000704e+02,   1.14092068e+02],
       [  9.72327061e+01,  -5.73487224e+01],
       [  8.11243834e+01,  -5.73487224e+01],
       [  7.48230524e+01,  -1.47312895e+02],
       [  1.05225273e+02,  -1.47312895e+02],
       [  7.48275724e+01,   1.47385442e+02],
       [  1.05220740e+02,   1.47385442e+02],
       [  7.52576537e+01,  -1.50512113e+01],
       [  1.04789415e+02,  -1.50512113e+01],
       [  7.52657639e+01,   1.52495327e+01],
       [  1.04781282e+02,   1.52495327e+01],
       [  9.61410619e+01,  -2.83975417e+01],
       [  9.61391756e+01,   2.84820238e+01],
       [  8.24583154e+01,  -2.83975417e+01],
       [  8.24606229e+01,   2.84820238e+01],
       [  9.60950618e+01,  -1.08708214e+02],
       [  8.25145892e+01,  -1.08708214e+02],
       [  9.59584160e+01,  -1.36339142e+02],
       [  9.59453526e+01,   1.36012513e+02],
       [  8.26817820e+01,  -1.36339142e+02],
       [  8.26977679e+01,   1.36012513e+02],
       [  8.11428106e+01,   1.70836327e+02],
       [  8.11435165e+01,  -1.71230484e+02],
       [  9.88862914e+01,   1.70836327e+02],
       [  9.88855833e+01,  -1.71230484e+02],
       [  9.38661600e+01,   1.62722260e+02],
       [  8.52464581e+01,   1.62722260e+02],
       [  7.42198449e+01,  -5.73487224e+01],
       [  1.05830207e+02,  -5.73487224e+01],
       [  7.65266535e+01,  -2.83975417e+01],
       [  1.03516685e+02,  -2.83975417e+01],
       [  7.65306718e+01,   2.84820238e+01],
       [  1.03512654e+02,   2.84820238e+01],
       [  7.66246775e+01,  -1.08708214e+02],
       [  1.03418369e+02,  -1.08708214e+02],
       [  7.69162327e+01,  -1.36339142e+02],
       [  1.03125942e+02,  -1.36339142e+02],
       [  7.69441344e+01,   1.36012513e+02],
       [  1.03097957e+02,   1.36012513e+02],
       [  8.14420913e+01,   1.62722260e+02],
       [  9.85860575e+01,   1.62722260e+02]])

In [88]:
N = 150
r = 1*np.ones((N))
theta = 2*pi*rand(N)
area = 200*r**2*rand(N)
ax = subplot(111, polar=True)
c = scatter(theta, r,  s=area, cmap=cm.hsv)
c.set_alpha(0.75)

show()



In [73]:
N = 5
r = 2*rand(N)
theta = 2*pi*rand(N)
area = 200*r**2*rand(N)
colors = theta
ax = subplot(111, polar=True)
c = scatter(theta, r, c=colors, s=area, cmap=cm.hsv)
c.set_alpha(0.75)

show()



In [74]:
scatter?

In [ ]:


In [ ]: