This commit is contained in:
HappyZ 2019-05-23 18:08:58 -05:00
parent f051687899
commit 45a83d473c
4 changed files with 41 additions and 7 deletions

View File

@ -45,6 +45,7 @@ def convert_vector_to_mat(
for i in range(rx_locs.shape[0]):
if offset is None:
x, y = rx_locs[i, :] / block_size
print(x, y)
else:
x, y = (rx_locs[i, :] + offset) / block_size
result[int(round(x)), int(round(y))] = rx_rsses[i]

View File

@ -80,7 +80,7 @@ def fittingSingle(filepath, args):
f.write(
"{},".format(filename) +
"{:.3f},{:.3f},".format(best_tx_loc[0], best_tx_loc[1]) +
"{:.2f},{:.2f}".format(best_tx_pwr, best_env_gamma) +
"{:.2f},{:.2f},".format(best_tx_pwr, best_env_gamma) +
"{:.6f},".format(min_fit_mse) +
"{:.4f},{:.4f},{:.4f},{:.4f}".format(stat['5perc'], stat['95perc'], stat['median'], stat['mean']) +
"\n"

View File

@ -51,9 +51,29 @@ def log_gamma_floorplan_multi(floormap, rx_loc, tx_loc, power, gaussian_noise, r
power,
gaussian_noise=gaussian_noise
)
print(kk, rss)
results[kk] = rss
def floormap_noise_injection(floormap, args):
if not args.floormap_rand:
return
for j in range(floormap.map.shape[1]):
if np.random.random() < 0.8:
continue
loss_p, loss_r = floormap.getLoss(i, j)
loss_r = np.random.randint(-3, 3) - 50
floormap.setLoss(
i, j,
min(loss_p + np.random.randint(-3, 3), 0.0),
loss_r
)
floormap.setOrientation(
i, j,
np.random.random() * 2 * np.pi - np.pi
)
def generateData(floormap, tx_locs, args):
'''
'''
@ -85,12 +105,16 @@ def generateData(floormap, tx_locs, args):
rss_vec = []
starttime = int(time.time())
tx_loc = SpaceBlock(3.2, 3.2)
# tx_loc = SpaceBlock(tx_locs[i, 0], tx_locs[i, 1])
if args.floormap_rand:
floormap = getFloormap(args)
floormap_noise_injection(floormap, args)
floormap.traceRays(power, tx_loc)
for j in range(0, rx_locs.shape[0], args.procnum):
procs = []
results = Manager().dict()
for kk in range(args.procnum):
rx_loc = SpaceBlock(rx_locs[j, 0], rx_locs[j, 1])
rx_loc = SpaceBlock(rx_locs[j + kk, 0], rx_locs[j + kk, 1])
proc = Process(
target=log_gamma_floorplan_multi,
args=(floormap, rx_loc, tx_loc, power, args.withnoise, results, kk)
@ -195,7 +219,14 @@ if __name__ == '__main__':
'--floormap', '-f',
dest='floormap',
default=None,
help='floormap data'
help='the base of floormap data'
)
p.add_argument(
'--floormap-rand', '-frnd',
dest='floormap_rand',
action='store_true',
default=False,
help='add some random penetration losses in floormap'
)
p.add_argument(
'--with-noise',

View File

@ -53,16 +53,18 @@ def test():
plotSpace(spacemap, cminmax=(-50, 0.0))
rx_locs = [SpaceBlock(1.0, 4.3), SpaceBlock(4.2, 4.4), SpaceBlock(4.4, 4.4)]
rx_locs = []
for i in range(64):
rx_locs.append(SpaceBlock(0 + i * 0.1, 4.4))
spacemap.traceRays(-40, SpaceBlock(3.2, 3.2))
for rx_loc in rx_locs:
rx_loc_rss, rx_loc_paths = spacemap.traceRay(rx_loc)
multipaths = []
for path in rx_loc_paths:
print("found path: {}".format(path))
# print("found path: {}".format(path))
multipaths.extend(list(path))
print("rss = {:.6f}dB".format(rx_loc_rss))
plotSpace(spacemap, space_rays=multipaths, cminmax=(-50, 0.0))
print("{:.6f}".format(rx_loc_rss))
# plotSpace(spacemap, space_rays=multipaths, cminmax=(-50, 0.0))