Skip to content

Commit

Permalink
Commit final
Browse files Browse the repository at this point in the history
  • Loading branch information
uxxiat committed Jul 31, 2023
1 parent f4147e7 commit d450901
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 136 deletions.
220 changes: 118 additions & 102 deletions testAOATransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@
plt.close('all')
fig_ctr = 0

""" Banco de gráficas e tests exclusivo da función fitAOA (e correción de backlobes se corresponde)"""

# Posicións transmisor e receptor


""" Testbench for fitAOA and backlobe correction functions """
phi0 = 0

# Selección de escenario - UMi, UMa, RMa, InH-Office-Mixed, InH-Office-Open
sce = "UMi"
# Selección de escenario
sce = "UMa"
# Posicións transmisor e receptor
tx = (0,0,10)
rx = (45,45,1.5)
#Creación de canle- con largeBW e scenario UMi
rx = (45,20,1.5)
#Creación de canle
modelA = mpg.ThreeGPPMultipathChannelModel(scenario = "UMi", bLargeBandwidthOption=True)
#Xeramos clusters e subpaths non adaptados:
plinfoA,macroA,clustersNAD,subpathsNAD = modelA.create_channel(tx,rx)
Expand All @@ -31,41 +26,48 @@
clustersAD = modelA.fitAOA(tx,rx,clustersAD)
subpathsAD = modelA.fitAOA(tx,rx,subpathsAD)



#%%
plinfoA,macroA,clustersA,subpathsA = modelA.create_channel(tx,rx)

#AOAs non correxidos
AOA_cA = clustersA['AOA'].T.to_numpy() * (np.pi/(180.0))
AOA_sA = subpathsA['AOA'].T.to_numpy() * (np.pi/(180.0))
AOA_cA = clustersNAD['AOA'].T.to_numpy() * (np.pi/(180.0))
AOA_sA = subpathsNAD['AOA'].T.to_numpy() * (np.pi/(180.0))

clustersAD = clustersA.copy()
subpathsAD = subpathsA.copy()
clustersAD = clustersNAD.copy()
subpathsAD = subpathsNAD.copy()


# Adaptación canle 1:

clustersAD = modelA.fitAOA(tx,rx,clustersAD)
subpathsAD = modelA.fitAOA(tx,rx,subpathsAD)
#%%

#Se queremos ademais correxir backlobes:

clustersAD = modelA.deleteBacklobes(clustersAD,phi0)
subpathsAD = modelA.deleteBacklobes(subpathsAD,phi0)
clustersADb = modelA.deleteBacklobes(tx,rx,clustersAD,phi0)
subpathsADb = modelA.deleteBacklobes(tx,rx,subpathsAD,phi0)

#%%
#Posición dos rebotes:
xc_A,yc_A = [clustersAD['xloc'].T.to_numpy(),clustersAD['yloc'].T.to_numpy()]
xs_A,ys_A = [subpathsAD['xloc'].T.to_numpy(),subpathsAD['yloc'].T.to_numpy()]

xc_Ab,yc_Ab = [clustersADb['xloc'].T.to_numpy(),clustersADb['yloc'].T.to_numpy()]
xs_Ab,ys_Ab = [subpathsADb['xloc'].T.to_numpy(),subpathsADb['yloc'].T.to_numpy()]


#Distancia entre receptor e posición do rebote
liRX_cA = np.sqrt((xc_A-rx[0])**2+(yc_A - rx[1])**2)
liRX_sA = np.sqrt((xs_A-rx[0])**2+(ys_A - rx[1])**2)
#Distancia entre transmisor e receptor do rebote
liTX_cA = np.sqrt(xc_A**2+yc_A**2)
liTX_sA = np.sqrt(xs_A**2+ys_A**2)

#Distancia entre receptor e posición do rebote
liRX_cAb = np.sqrt((xc_Ab-rx[0])**2+(yc_Ab - rx[1])**2)
liRX_sAb = np.sqrt((xs_Ab-rx[0])**2+(ys_Ab - rx[1])**2)
#Distancia entre transmisor e receptor do rebote
liTX_cAb = np.sqrt(xc_Ab**2+yc_Ab**2)
liTX_sAb = np.sqrt(xs_Ab**2+ys_Ab**2)

#Caso A: Sen correción de backlobes

#AOAs correxidos
AOA_cfA = clustersAD['AOA'].T.to_numpy() * (np.pi/(180.0))
AOA_sfA = subpathsAD['AOA'].T.to_numpy() * (np.pi/(180.0))
Expand All @@ -77,79 +79,18 @@
tau_cA = clustersAD['tau'].T.to_numpy() * (np.pi/(180.0))
tau_sA = subpathsAD['tau'].T.to_numpy() * (np.pi/(180.0))

#Caso B: Correción de backlobes

# -----------------------------
# ---- Canle B, largeBW = true, adaptrayTX ) = true
# -----------------------------

modelB = mpg.ThreeGPPMultipathChannelModel(scenario = sce, bLargeBandwidthOption=False, adaptRaytx = True)
plinfoB,macroB,clustersB,subpathsB = modelB.create_channel(tx,rx)


#Posición dos rebotes:
xc_B,yc_B = [clustersB['xloc'].T.to_numpy(),clustersB['yloc'].T.to_numpy()]
xs_B,ys_B = [subpathsB['xloc'].T.to_numpy(),subpathsB['yloc'].T.to_numpy()]
#AOAs correxidos
AOA_cfAb = clustersADb['AOA'].T.to_numpy() * (np.pi/(180.0))
AOA_sfAb = subpathsADb['AOA'].T.to_numpy() * (np.pi/(180.0))

#Distancia entre receptor e posición do rebote
liRX_cB = np.sqrt((xc_B-rx[0])**2+(yc_B - rx[1])**2)
liRX_sB = np.sqrt((xs_B-rx[0])**2+(xs_B - rx[1])**2)
#Distancia entre transmisor e receptor do rebote
liTX_cB = np.sqrt(xc_B**2+yc_B**2)
liTX_sB = np.sqrt(xs_B**2+ys_B**2)

# AOA_cB = clustersB['AOA'].T.to_numpy() * (np.pi/(180.0))
# AOA_sB = subpathsB['AOA'].T.to_numpy() * (np.pi/(180.0))

# AOD_cB = clustersB['AOD'].T.to_numpy() * (np.pi/(180.0))
# AOD_sB = subpathsB['AOD'].T.to_numpy() * (np.pi/(180.0))

# nSubp = subpathsB['tau'].size

# fig_ctr+=1
# fig = plt.figure(fig_ctr)
# plt.title("Subpaths correxidos directamente")
# plt.grid(linestyle = '--')
# plt.xlabel('x-location (m)')
# plt.ylabel('y-location (m)')
# plt.plot(tx[0],tx[1],'^g',label='BS',linewidth = '4.5')
# plt.plot(rx[0],rx[1],'^r',label='UE', linewidth='4.5')

# plt.plot(xs_B,ys_B,'x',label='Rebotes subpaths')
# for i in range(0,AOD_sB.size):
# plt.plot([tx[0],tx[0]+liTX_sB[i]*np.cos(AOD_sB[i])],[tx[1],tx[1]+liTX_sB[i]*np.sin(AOD_sB[i])],color=cm.jet(i/(nSubp-1)),linewidth = '0.5')
# plt.plot([rx[0],rx[0]+liRX_sB[i]*np.cos(AOA_sB[i])],[rx[1],rx[1]+liRX_sB[i]*np.sin(AOA_sB[i])],color=cm.jet(i/(nSubp-1)),linewidth = '0.5')
# legend = plt.legend(shadow=True, fontsize='10')
# ruta_archivo = os.path.join("img", "nombre_archivo")


# fig_ctr+=1
# fig = plt.figure(fig_ctr)
# nClus = clustersB['tau'].size
# plt.subplot(2,2,1, projection='polar',title="AoD")
# for n in range(nClus):
# AOD_1c = subpathsB.loc[n,:].AOD.to_numpy() *np.pi/180
# pathAmplitudesdBtrunc25_1c = np.maximum(10*np.log10( subpathsB.loc[n,:].P.to_numpy() ),-45)
# Nsp=len(AOD_1c)
# plt.polar(AOD_1c*np.ones((2,1)),np.vstack([-40*np.ones((1,Nsp)),pathAmplitudesdBtrunc25_1c]),':',color=cm.jet(n/(nClus-1)) )
# plt.scatter(AOD_1c,pathAmplitudesdBtrunc25_1c,color=cm.jet(n/(nClus-1)),marker='<')
# plt.yticks(ticks=[-40,-30,-20,-10],labels=['-40dB','-30dB','-20dB','-10dB'],fontsize = 7)
# plt.subplot(2,2,2, projection='polar')
# for n in range(nClus):
# AOA_1cf = subpathsB.loc[n,:].AOA.to_numpy() *np.pi/180
# pathAmplitudesdBtrunc25_1c = np.maximum(10*np.log10( subpathsB.loc[n,:].P.to_numpy() ),-45)
# Nsp=len(AOA_1cf)
# plt.polar(AOA_1cf*np.ones((2,1)),np.vstack([-40*np.ones((1,Nsp)),pathAmplitudesdBtrunc25_1c]),':',color=cm.jet(n/(nClus-1)) )
# plt.scatter(AOA_1cf,pathAmplitudesdBtrunc25_1c,color=cm.jet(n/(nClus-1)),marker='+')
# plt.yticks(ticks=[-40,-30,-20,-10],labels=['-40dB','-30dB','-20dB','-10dB'],fontsize=7)
# plt.subplot(2,1,2)
# plt.ylabel("power [dB]")
# plt.xlabel("TDoA (s)")
# for n in range(nClus):
# markerline, stemlines, baseline = plt.stem( subpathsB.loc[n,:].tau.to_numpy() ,10*np.log10( subpathsB.loc[n,:].P.to_numpy() ),bottom=np.min(10*np.log10(subpathsB.P.to_numpy())))
# plt.setp(stemlines, color=cm.jet(n/(nClus-1)))
# plt.setp(markerline, color=cm.jet(n/(nClus-1)))
# plt.grid()
#AODs e tau non varían
AOD_cAb = clustersADb['AOD'].T.to_numpy() * (np.pi/(180.0))
AOD_sAb = subpathsADb['AOD'].T.to_numpy() * (np.pi/(180.0))

tau_cAb = clustersADb['tau'].T.to_numpy() * (np.pi/(180.0))
tau_sAb = subpathsADb['tau'].T.to_numpy() * (np.pi/(180.0))

# ---- Gráfica 1, camiños non adaptados:

Expand All @@ -160,6 +101,7 @@
plt.ylabel('y-location (m)')

nClus = tau_cA.size
nClusb = tau_cAb.size
nSubp = tau_sA.size

plt.plot([tx[0],rx[0]],[tx[1],rx[1]],'--')
Expand Down Expand Up @@ -193,7 +135,28 @@
plt.plot(rx[0],rx[1],'^r',label='UE', linewidth='4.5')
legend = plt.legend(shadow=True, fontsize='10')

ruta = os.path.join("img", "fitAOA_clusAD.png")
ruta = os.path.join("img", "fitAOA_nbclusAD.png")
plt.savefig(ruta)

#Gráfica 2 - Camiños clusters adaptados con corrección de backlobes

fig_ctr+=1
fig = plt.figure(fig_ctr)

plt.grid(linestyle = '--')
plt.xlabel('x-location (m)')
plt.ylabel('y-location (m)')

plt.plot([tx[0],rx[0]],[tx[1],rx[1]],'--')
plt.plot(xc_Ab,yc_Ab,'x',label='Rebotes clusters')
for i in range(0,AOD_cAb.size):
plt.plot([tx[0],tx[0]+liTX_cAb[i]*np.cos(AOD_cAb[i])],[tx[1],tx[1]+liTX_cAb[i]*np.sin(AOD_cAb[i])],color='red',linewidth = '0.9')
plt.plot([rx[0],rx[0]+liRX_cAb[i]*np.cos(AOA_cfAb[i])],[rx[1],rx[1]+liRX_cAb[i]*np.sin(AOA_cfAb[i])],color='blue',linewidth = '0.9')
plt.plot(tx[0],tx[1],'^g',label='BS',linewidth = '4.5')
plt.plot(rx[0],rx[1],'^r',label='UE', linewidth='4.5')
legend = plt.legend(shadow=True, fontsize='10')

ruta = os.path.join("img", "fitAOA_bclusAD.png")
plt.savefig(ruta)

# Gráfica 3 - Subpaths non adaptados
Expand Down Expand Up @@ -231,27 +194,45 @@
plt.plot([rx[0],rx[0]+liRX_sA[i]*np.cos(AOA_sfA[i])],[rx[1],rx[1]+liRX_sA[i]*np.sin(AOA_sfA[i])],color=cm.jet(i/(nSubp-1)),linewidth = '0.5')
legend = plt.legend(shadow=True, fontsize='10')

ruta = os.path.join("img", "fitAOA_subpAD.png")
ruta = os.path.join("img", "fitAOA_nbsubpAD.png")
plt.savefig(ruta)

#subpaths con backlobe correction
fig_ctr+=1
fig = plt.figure(fig_ctr)
plt.grid(linestyle = '--')
plt.xlabel('x-location (m)')
plt.ylabel('y-location (m)')
plt.plot(tx[0],tx[1],'^g',label='BS',linewidth = '4.5')
plt.plot(rx[0],rx[1],'^r',label='UE', linewidth='4.5')

plt.plot(xs_Ab,ys_Ab,'x',label='Rebotes subpaths')
for i in range(0,AOD_sAb.size):
plt.plot([tx[0],tx[0]+liTX_sAb[i]*np.cos(AOD_sAb[i])],[tx[1],tx[1]+liTX_sAb[i]*np.sin(AOD_sAb[i])],color='red',linewidth = '0.5')
plt.plot([rx[0],rx[0]+liRX_sAb[i]*np.cos(AOA_sfAb[i])],[rx[1],rx[1]+liRX_sAb[i]*np.sin(AOA_sfAb[i])],color='blue',linewidth = '0.5')
legend = plt.legend(shadow=True, fontsize='10')

ruta = os.path.join("img", "fitAOA_bsubpAD.png")
plt.savefig(ruta)


# Gráfica 5: Deck de subpaths AOD, AOA e delay non correxido

fig_ctr+=1
fig = plt.figure(fig_ctr)
nClus = clustersA['tau'].size
nClus = clustersNAD['tau'].size
plt.subplot(2,2,1, projection='polar',title="AoD")
for n in range(nClus):
AOD_1c = subpathsA.loc[n,:].AOD.to_numpy() *np.pi/180
pathAmplitudesdBtrunc25_1c = np.maximum(10*np.log10( subpathsA.loc[n,:].P.to_numpy() ),-45)
AOD_1c = subpathsNAD.loc[n,:].AOD.to_numpy() *np.pi/180
pathAmplitudesdBtrunc25_1c = np.maximum(10*np.log10( subpathsNAD.loc[n,:].P.to_numpy() ),-45)
Nsp=len(AOD_1c)
plt.polar(AOD_1c*np.ones((2,1)),np.vstack([-40*np.ones((1,Nsp)),pathAmplitudesdBtrunc25_1c]),':',color=cm.jet(n/(nClus-1)) )
plt.scatter(AOD_1c,pathAmplitudesdBtrunc25_1c,color=cm.jet(n/(nClus-1)),marker='<')
plt.yticks(ticks=[-40,-30,-20,-10],labels=['-40dB','-30dB','-20dB','-10dB'],fontsize = 7)
plt.subplot(2,2,2, projection='polar')
for n in range(nClus):
AOA_1cf = subpathsA.loc[n,:].AOA.to_numpy() *np.pi/180
pathAmplitudesdBtrunc25_1c = np.maximum(10*np.log10(subpathsA.loc[n,:].P.to_numpy() ),-45)
AOA_1cf = subpathsNAD.loc[n,:].AOA.to_numpy() *np.pi/180
pathAmplitudesdBtrunc25_1c = np.maximum(10*np.log10(subpathsNAD.loc[n,:].P.to_numpy() ),-45)
Nsp=len(AOA_1cf)
plt.polar(AOA_1cf*np.ones((2,1)),np.vstack([-40*np.ones((1,Nsp)),pathAmplitudesdBtrunc25_1c]),':',color=cm.jet(n/(nClus-1)) )
plt.scatter(AOA_1cf,pathAmplitudesdBtrunc25_1c,color=cm.jet(n/(nClus-1)),marker='+')
Expand All @@ -260,7 +241,7 @@
plt.ylabel("power [dB]")
plt.xlabel("TDoA (s)")
for n in range(nClus):
markerline, stemlines, baseline = plt.stem( subpathsA.loc[n,:].tau.to_numpy() ,10*np.log10( subpathsAD.loc[n,:].P.to_numpy() ),bottom=np.min(10*np.log10(subpathsAD.P.to_numpy())))
markerline, stemlines, baseline = plt.stem( subpathsNAD.loc[n,:].tau.to_numpy() ,10*np.log10( subpathsAD.loc[n,:].P.to_numpy() ),bottom=np.min(10*np.log10(subpathsAD.P.to_numpy())))
plt.setp(stemlines, color=cm.jet(n/(nClus-1)))
plt.setp(markerline, color=cm.jet(n/(nClus-1)))
plt.grid()
Expand All @@ -271,6 +252,41 @@

# Gráfica 6: Deck de subpaths AOD, AOA e delay correxido

fig_ctr+=1
fig = plt.figure(fig_ctr)
nSubpb = subpathsADb['tau'].size
plt.subplot(2,2,1, projection='polar',title="AoD")

AOD_1c = subpathsADb['AOD'].to_numpy() *np.pi/180
pathAmplitudesdBtrunc25_1c = np.maximum(10*np.log10( subpathsADb['P'].to_numpy() ),-45)
Nsp=len(AOD_1c)
plt.polar(AOD_1c,pathAmplitudesdBtrunc25_1c,':',color='red' )
plt.scatter(AOD_1c,pathAmplitudesdBtrunc25_1c,color='red',marker='<')
plt.yticks(ticks=[-40,-30,-20,-10],labels=['-40dB','-30dB','-20dB','-10dB'],fontsize = 7)
plt.subplot(2,2,2, projection='polar')


AOA_1cf = subpathsADb['AOA'].to_numpy() *np.pi/180
pathAmplitudesdBtrunc25_1c = np.maximum(10*np.log10( subpathsADb['P'].to_numpy() ),-45)
Nsp=len(AOA_1cf)
plt.polar(AOA_1cf,pathAmplitudesdBtrunc25_1c,':',color='blue' )
plt.scatter(AOA_1cf,pathAmplitudesdBtrunc25_1c,color='blue',marker='+')

plt.yticks(ticks=[-40,-30,-20,-10],labels=['-40dB','-30dB','-20dB','-10dB'],fontsize=7)
plt.subplot(2,1,2)
plt.ylabel("power [dB]")
plt.xlabel("TDoA (s)")

markerline, stemlines, baseline = plt.stem( subpathsADb['tau'].to_numpy() ,10*np.log10( subpathsADb['P'].to_numpy() ),bottom=np.min(10*np.log10(subpathsADb['P'].to_numpy())))
plt.setp(stemlines, color='green')
plt.setp(markerline, color='orange')
plt.grid()

ruta = os.path.join("img", "fitAOA_bdeckAD.png")
plt.savefig(ruta)

#Gráfica 7: deck de subpaths con backlobe correction

fig_ctr+=1
fig = plt.figure(fig_ctr)
nClus = clustersAD['tau'].size
Expand Down Expand Up @@ -299,7 +315,7 @@
plt.setp(markerline, color=cm.jet(n/(nClus-1)))
plt.grid()

ruta = os.path.join("img", "fitAOA_deckAD.png")
ruta = os.path.join("img", "fitAOA_nbdeckAD.png")
plt.savefig(ruta)

# %%
10 changes: 5 additions & 5 deletions testAODTransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
plt.plot([rx[0],rx[0]+liRX_cA[i]*np.cos(AOA_cA[i])],[rx[1],rx[1]+liRX_cA[i]*np.sin(AOA_cA[i])],color=cm.jet(i/(nClus-1)),linewidth = '0.5')
legend = plt.legend(shadow=True, fontsize='10')

ruta = os.path.join("img", "fitAOD_clusNAD.png")
ruta = os.path.join("img", "testNAD.png")
plt.savefig(ruta)


Expand All @@ -115,10 +115,10 @@
plt.plot([rx[0],rx[0]+liRX_cA[i]*np.cos(AOA_cA[i])],[rx[1],rx[1]+liRX_cA[i]*np.sin(AOA_cA[i])],color=cm.jet(i/(nClus-1)),linewidth = '0.5')
legend = plt.legend(shadow=True, fontsize='10')

ruta = os.path.join("img", "fitAOD_clusAD.png")
ruta = os.path.join("img", "testAD.png")
plt.savefig(ruta)


#%%
# Gráfica 3 - Subpaths non adaptados

fig_ctr+=1
Expand All @@ -139,7 +139,7 @@
ruta = os.path.join("img", "fitAOD_subpNAD.png")
plt.savefig(ruta)


#%%
# Gráfica 4 - Subpaths adaptados

fig_ctr+=1
Expand All @@ -159,7 +159,7 @@

ruta = os.path.join("img", "fitAOD_subpAD.png")
plt.savefig(ruta)

#%%


# Gráfica 5: Deck de subpaths AOD, AOA e delay non correxido
Expand Down
Loading

0 comments on commit d450901

Please sign in to comment.