def eval(self, **kwrgs): """ """ for kt in range(Nb_tx): tx = np.array([ self.tx.position[0, kt + 1], self.tx.position[1, kt + 1], self.tx.position[2, kt + 1] ]) link.a = tx for kr in range(Nb_Run): rx = np.array([ S.rx.position[0, Run], S.rx.position[1, Run], S.rx.position[2, Run] ]) link.b = rx tic = time.clock() ak, tk = link.eval(verbose=False, diffraction=True) toc = time.clock() ciro = link.H.applywav(wav.sfg) cir = bs.TUsignal(ciro.x, np.squeeze(np.sum(ciro.y, axis=0))) tac = time.clock() tcir[Run] = cir print toc - tic, tac - toc
def ref156(self, beta=0.5): """ reference pulse of IEEE 802.15.6 UWB standard Parameters ---------- beta : float roll-off factor Tns = 1/499.2MHz Notes ----- From P8O2.15.6/D02 December 2010 Formula 96 p 215 """ Tw = self['twns'] fe = self['feGHz'] te = 1. / fe beta = 0.5 Tns = 1. / 0.4992 x = np.linspace(-0.5 * Tw + te / 2, 0.5 * Tw + te / 2, Np, endpoint=False) z = x / Tns t1 = np.sin(np.pi * (1 - beta) * z) t2 = np.cos(np.pi * (1 + beta) * z) t3 = (np.pi * z) * (1 - (4 * beta * z)**2) y = (t1 + 4 * beta * z * t2) / t3 st = bs.TUsignal() st.x = x st.y = y sf = st.ftshift() return (st, sf)
def ip_generic(self): """ Create an energy normalized Gaussian impulse (Usignal) ip_generic(self,parameters) """ Tw = self['twns'] fcGHz = self['fcGHz'] WGHz = self['WGHz'] thresh = self['threshdB'] feGHz = self['feGHz'] te = 1.0 / feGHz self['te'] = te Np = feGHz * Tw self['Np'] = Np #x = np.linspace(-0.5*Tw+te/2,0.5*Tw+te/2,Np,endpoint=False) #x = arange(-Tw,Tw,te) w = bs.TUsignal() w.EnImpulse(fcGHz=fcGHz, WGHz=WGHz, threshdB=thresh, feGHz=feGHz) #W = w.ft() W = w.ft() return (w, W)
def pltcir(self, itx=1, irx=1, mode='linear', noise=False, color='b', format='a', fig=[], ax=[]): """ plot Channel Impulse Response Parameters ---------- itx : Tx index irx : Rx index mode : str {'linear','dB'} noise : boolean color : string default 'b' >>> from pylayers.simul.simulem import * >>> S = Simul() >>> S.load('where2.ini') >>> S.run(1,1) >>> S.pltcir(1,1,mode='linear',noise=False,color='k') """ if fig == []: fig = plt.gcf() #if ax==[]: # ax = fig.gca() _filecir = self.dcir[itx][irx] + '.mat' filecir = pyu.getlong(_filecir, pstruc['DIRCIR'] + '/Tx' + str('%0.3d' % itx)) D = spio.loadmat(filecir) ax = fig.add_subplot('211') fig, ax = self.show(itx, irx, fig=fig, ax=ax) ax = fig.add_subplot('212') if 'a' in format: kxa = 't' kya = 'cir' ta = D[kxa] Tobs = ta[-1] - ta[0] te = ta[1] - ta[0] if noise: na = bs.Noise(Tobs + te, 1. / te) naf = na.gating(4.493, 0.5) cira = bs.TUsignal(ta, D[kya][:, 0]) if 'o' in format: kxo = 'to' + str(irx) kyo = 'ciro' + str(irx) to = D[kxo] Tobs = to[-1] - to[0] te = to[1] - to[0] if noise: no = bs.Noise(Tobs + te, 1. / te) nof = no.gating(4.493, 0.5) ciro = bs.TUsignal(to, D[kyo][:, 0]) if mode == 'linear': #plt.plot(ta,naf.y,color='k',label='Noise') plt.plot(ta, D[kya], label='Rx ' + str(irx), color=color) plt.xlabel('Time (ns)') '''if noise: naf.plot(col='k') cira.plot(col=color)''' else: '''if noise: naf.plotdB(col='k') cira.plotdB()''' plt.plot(ta, 20 * np.log10(abs(D[kya])), label='Rx ' + str(irx), color=color) plt.xlabel('Time (ns)') # plt.legend() plt.show()