Skip to content

Commit cb1310b

Browse files
committed
actualizacion
1 parent 5066129 commit cb1310b

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed
4.34 KB
Binary file not shown.
Binary file not shown.

macro.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Wed Nov 30 16:28:39 2022
4+
5+
@author: user
6+
"""
7+
import threeGPPMultipathGenerator as pg
8+
import numpy as np
9+
import matplotlib.pyplot as plt
10+
from collections import Counter
11+
12+
#-------------------------PLOTEO MACRO-------------------------------------
13+
txPos = (0,0,10)
14+
Nusers = 300
15+
cell = 15 #m
16+
distance = 15*cell#m
17+
numberCells = np.ceil(distance/cell).astype(int)
18+
19+
users = []
20+
x = []
21+
y = []
22+
contadorY = []
23+
contadorX = []
24+
key=[]
25+
26+
modelMacro = pg.ThreeGPPMultipathChannelModel(sce="UMi")
27+
28+
macroChannel = []
29+
dfList = []
30+
mm = (np.zeros((numberCells,numberCells))).astype(np.int32)
31+
32+
33+
for i in range(Nusers):
34+
posX = round(np.random.uniform(0, distance-1), 2)
35+
posY = round(np.random.uniform(0, distance-1), 2)
36+
users.append(tuple([posX,posY,1.5]))
37+
x.append(posX)
38+
y.append(posY)
39+
RgridXIndex = int(np.abs((txPos[0]-x[i]) // cell)-1)
40+
RgridYIndex = int(np.abs((txPos[1]-y[i]) // cell)-1)
41+
if RgridXIndex < 0:
42+
contadorX.append(0)
43+
else:
44+
contadorX.append(RgridXIndex)
45+
if RgridYIndex < 0:
46+
contadorY.append(0)
47+
else:
48+
contadorY.append(RgridYIndex)
49+
mm[contadorX[i],contadorY[i]] += 1
50+
macroChannel.append(modelMacro.create_channel(txPos,users[i])[0])
51+
dfList.append(modelMacro.create_channel(txPos,users[i])[1])
52+
key.append([contadorX[i],contadorY[i]])
53+
54+
#plt.subplot(1,2,1)
55+
#plt.imshow(mm, cmap='RdYlBu_r', interpolation='nearest')
56+
#plt.colorbar(label="Number of users", orientation="vertical")
57+
#plt.show()
58+
59+
#Eliminamos los macros que se repiten para quedarnos con uno por casilla
60+
result = []
61+
for item in macroChannel:
62+
if item not in result:
63+
result.append(item)
64+
keyResult = []
65+
for item in key:
66+
if item not in keyResult:
67+
keyResult.append(str(item))
68+
69+
result = tuple(result)
70+
keyResult = tuple(keyResult)
71+
dictMacro = (dict(zip(keyResult, result)))
72+
73+
74+
macroDS = []
75+
macroASA = []
76+
77+
78+
for i in range(len(macroChannel)):
79+
macroDS.append(str(macroChannel[i].ds))
80+
macroASA.append(str(macroChannel[i].asa))
81+
82+
83+
contadorRepes = Counter(macroDS)
84+
85+
listaRepes = []
86+
for i in range(len(contadorRepes)):
87+
listaRepes.append(contadorRepes[macroDS[i]])
88+
89+
colorDS = []
90+
for item in macroDS:
91+
if item not in colorDS:
92+
colorDS.append(item)
93+
94+
listaRepes = []
95+
for i in range(len(contadorRepes)):
96+
listaRepes.append(contadorRepes[colorDS[i]])
97+
98+
indexList = []
99+
for j in range(len(colorDS)):
100+
for i in range(len(macroDS)):
101+
if macroDS[i] == colorDS[j]:
102+
indexList.append(i)
103+
104+
color = []
105+
ayuda = []
106+
for i in range(len(colorDS)):
107+
ayuda.append(i)
108+
color.append(np.random.choice(range(256), size=3))
109+
110+
ultima = []
111+
colorUltima = []
112+
for i in range(len(listaRepes)):
113+
cont = listaRepes[i]
114+
while cont != 0:
115+
ultima.append(ayuda[i])
116+
colorUltima.append(color[i])
117+
cont = cont-1
118+
119+
listaFinal = []
120+
colorFinal = []
121+
listaFinal = [0]*len(ultima)
122+
colorFinal = [0]*len(ultima)
123+
for index, value in zip(indexList, ultima):
124+
listaFinal[index] = value
125+
colorFinal[index] = value
126+
127+
fig,ax = plt.subplots()
128+
plt.xlim([0, distance+5])
129+
plt.ylim([0, distance+5])
130+
plt.yticks(np.arange(0, distance+5, cell))
131+
plt.xticks(np.arange(0, distance+5, cell))
132+
plt.grid(axis='both',color='red')
133+
sc = plt.scatter(x,y,s=15,c=np.take(colorUltima,listaFinal),data=macroDS)
134+
plt.title('User Distribution')
135+
plt.xlabel('Distance (m)')
136+
plt.ylabel('Distance (m)')
137+
#plt.scatter(x,y,c='red',data=macroASA)
138+
#plt.show()

0 commit comments

Comments
 (0)