111 lines
2.5 KiB
Python
111 lines
2.5 KiB
Python
#!/usr/bin/python
|
|
|
|
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
from libs.consts import COLORMAP_MIN
|
|
from libs.consts import COLORMAP_MAX
|
|
|
|
|
|
def plotSpace(
|
|
space_map,
|
|
space_rays = None,
|
|
cminmax: tuple = (COLORMAP_MIN, COLORMAP_MAX)
|
|
):
|
|
'''
|
|
'''
|
|
tx_locs = space_map.getTransmitterLocs()
|
|
penetration_loss, reflection_loss = space_map.getLosses()
|
|
|
|
fig = plt.figure(figsize=(8, 3))
|
|
|
|
ax1 = fig.add_subplot(1, 2, 1)
|
|
ax1.set_title("penetration loss")
|
|
plt.imshow(
|
|
np.transpose(penetration_loss),
|
|
cmap='hot',
|
|
origin='lower',
|
|
interpolation='nearest',
|
|
vmin=cminmax[0],
|
|
vmax=cminmax[1]
|
|
)
|
|
ax1.set_xlim([0,64])
|
|
ax1.set_ylim([0,64])
|
|
plt.colorbar()
|
|
|
|
if space_rays:
|
|
for each in space_rays:
|
|
ax1.plot([each.start.x / 0.1, each.end.x / 0.1], [each.start.y / 0.1, each.end.y / 0.1], 'b-')
|
|
|
|
ax2 = fig.add_subplot(1, 2, 2)
|
|
ax2.set_title("reflection loss")
|
|
plt.imshow(
|
|
np.transpose(reflection_loss),
|
|
cmap='hot',
|
|
origin='lower',
|
|
interpolation='nearest',
|
|
vmin=cminmax[0],
|
|
vmax=cminmax[1]
|
|
)
|
|
ax2.set_xlim([0,64])
|
|
ax2.set_ylim([0,64])
|
|
plt.colorbar()
|
|
|
|
# plt.show()
|
|
plt.draw()
|
|
plt.pause(0.1)
|
|
q = input("press enter..")
|
|
plt.close()
|
|
|
|
|
|
def plotRSS(
|
|
ori_rss: np.ndarray,
|
|
est_rss: np.ndarray = None,
|
|
est_tx_loc: np.ndarray = None,
|
|
true_tx_loc: np.ndarray = None,
|
|
cminmax: tuple = (COLORMAP_MIN, COLORMAP_MAX)
|
|
):
|
|
'''
|
|
'''
|
|
fig = plt.figure(figsize=(8, 3))
|
|
ax1 = fig.add_subplot(1, 2, 1)
|
|
ax1.set_title("original rss map")
|
|
plt.imshow(
|
|
np.transpose(ori_rss),
|
|
cmap='hot',
|
|
origin='lower',
|
|
interpolation='nearest',
|
|
vmin=cminmax[0],
|
|
vmax=cminmax[1]
|
|
)
|
|
plt.colorbar()
|
|
|
|
ax2 = fig.add_subplot(1, 2, 2)
|
|
ax2.set_title("est rss map")
|
|
if est_rss is not None:
|
|
plt.imshow(
|
|
np.transpose(est_rss),
|
|
cmap='hot',
|
|
origin='lower',
|
|
interpolation='nearest',
|
|
vmin=cminmax[0],
|
|
vmax=cminmax[1]
|
|
)
|
|
plt.colorbar()
|
|
if est_tx_loc is not None:
|
|
ax2.plot(est_tx_loc[0], est_tx_loc[1], 'bo')
|
|
ax2.text(est_tx_loc[0] - 5, est_tx_loc[1] + 2, 'est tx', color='b')
|
|
if true_tx_loc is not None:
|
|
ax2.plot(true_tx_loc[0], true_tx_loc[1], 'bs')
|
|
ax2.text(true_tx_loc[0], true_tx_loc[1], 'true tx', color='b')
|
|
|
|
# plt.show()
|
|
plt.draw()
|
|
plt.pause(0.1)
|
|
q = input("press enter..")
|
|
plt.close()
|
|
|
|
|
|
|