support groundtruth output
This commit is contained in:
parent
006463ef87
commit
798197044c
|
|
@ -4,6 +4,7 @@ import os
|
|||
import sys
|
||||
import pickle
|
||||
import argparse
|
||||
from math import sqrt
|
||||
|
||||
from libs.util import touch
|
||||
from libs.util import stats
|
||||
|
|
@ -30,6 +31,10 @@ def fittingSingle(filepath, args):
|
|||
if data is None:
|
||||
print("err: failed to load file {}".format(filepath))
|
||||
return
|
||||
location_gt = [float('nan'), float('nan')]
|
||||
if len(data) is 2:
|
||||
data, location_gt = data
|
||||
location_gt = location_gt * 0.1
|
||||
|
||||
# convert data matrix to vectors
|
||||
rx_locs, rx_rsses = convert_mat_to_vector(data, block_size=0.1)
|
||||
|
|
@ -69,6 +74,8 @@ def fittingSingle(filepath, args):
|
|||
print("|- final:")
|
||||
print("|--- tx loc: {:.3f}, {:.3f}".format(best_tx_loc[0], best_tx_loc[1]))
|
||||
print("|--- tx pwr: {:.2f}".format(best_tx_pwr))
|
||||
error = sqrt((best_tx_loc[0] - location_gt[0]) ** 2 + (best_tx_loc[1] - location_gt[1]) ** 2)
|
||||
print("|--- loc error distance: {:.2f}".format(error))
|
||||
print("|--- env gamma: {:.2f}".format(best_env_gamma))
|
||||
print("|--- fitting mse: {:.6f}".format(min_fit_mse))
|
||||
print("|--- rss diff: 5perc/95perc/median/mean: {:.4f}/{:.4f}/{:.4f}/{:.4f} m"
|
||||
|
|
@ -79,7 +86,9 @@ def fittingSingle(filepath, args):
|
|||
with open(args.outputfile, 'a') as f:
|
||||
f.write(
|
||||
"{},".format(filename) +
|
||||
"{:.3f},{:.3f},".format(location_gt[0], location_gt[1]) +
|
||||
"{:.3f},{:.3f},".format(best_tx_loc[0], best_tx_loc[1]) +
|
||||
"{:.3f},".format(error) +
|
||||
"{:.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']) +
|
||||
|
|
@ -107,7 +116,7 @@ def main(args):
|
|||
# prepare
|
||||
if args.outputfile and not os.path.isfile(args.outputfile):
|
||||
with open(args.outputfile, 'w') as f:
|
||||
f.write("filename,tx_x,tx_y,tx_pwr,env_gamma,fit_mse,rss_diff_5perc,rss_diff_95perc,rss_diff_med,rss_diff_avg\n")
|
||||
f.write("filename,true_x,true_y,est_tx_x,est_tx_y,tx_pwr,env_gamma,fit_mse,rss_diff_5perc,rss_diff_95perc,rss_diff_med,rss_diff_avg\n")
|
||||
|
||||
|
||||
# loop through and fit
|
||||
|
|
|
|||
Loading…
Reference in New Issue