add functions to generate desired locations with synthetic models

This commit is contained in:
HappyZ 2019-05-31 13:17:47 -05:00
parent b7af9e9a76
commit 41f469ee84
2 changed files with 51 additions and 12 deletions

View File

@ -86,7 +86,9 @@ def floormap_noise_injection(floormap, args):
def generateData(floormap, tx_locs, args):
'''
'''
if args.train:
if args.single:
tag = "single"
elif args.train:
tag = "input_synthetic_train"
elif args.train_real:
tag = "input_real_emu_train"
@ -180,7 +182,13 @@ def getFloormap(args):
def main(args):
tx_locs = None
if args.train:
if args.single:
if args.txloc is None:
print("did not specify tx location")
return
locations = [float(x) for x in args.txloc.split(' ')]
tx_locs = np.array(locations).reshape(-1, 2)
elif args.train:
np.random.seed(RANDOM_SEED_TRAIN)
tx_locs = getLocs([0.2, 6.2], [0.2, 6.2], step_size=0.3)
elif args.train_real:
@ -193,6 +201,10 @@ def main(args):
print("nothing specified")
return
if args.floormap is None:
print("specify floormap")
return
generateData(getFloormap(args), tx_locs, args)
@ -202,6 +214,19 @@ if __name__ == '__main__':
'outfolder',
help='output generated data to folder'
)
p.add_argument(
'--single',
dest='single',
action='store_true',
default=False,
help='generate data with tx location'
)
p.add_argument(
'--txloc',
dest='txloc',
default=None,
help='tx location in `x y x y ...` format, in meters'
)
p.add_argument(
'--training',
dest='train',
@ -223,13 +248,6 @@ if __name__ == '__main__':
default=False,
help='emulating testing data (real data part)'
)
p.add_argument(
'--visualize', '-v',
dest='visualize',
action='store_true',
default=False,
help='visualize'
)
p.add_argument(
'--floormap', '-f',
dest='floormap',

View File

@ -40,7 +40,9 @@ def getPowers(power_range, step_size: float = 2):
def generateData(tx_locs, args):
'''
'''
if args.train:
if args.single:
tag = "single"
elif args.train:
tag = "input_synthetic_train"
elif args.train_real:
tag = "input_real_emu_train"
@ -63,7 +65,7 @@ def generateData(tx_locs, args):
rx_locs = getLocs([-3.2, 3.1], [-3.2, 3.1], step_size=0.1)
powers = getPowers([-40, 30])
for i in range(tx_locs.shape[0]):
fp_base = "{0}/img_{1:.2f}_{2:.2f}_{3:.1f}".format(folderp, tx_locs[i, 0], tx_locs[i, 1], args.gamma)
fp_base = "{0}/img_{1:.2f}_{2:.2f}_{3:.1f}".format(folderp, tx_locs[i, 0] - 3.2, tx_locs[i, 1] - 3.2, args.gamma)
for power in powers:
rss_vec = log_gamma_loc(rx_locs, tx_locs[i, :], power, args.gamma, gaussian_noise=args.withnoise)
rss_map = convert_vector_to_mat(rx_locs, rss_vec, (64, 64))
@ -74,7 +76,13 @@ def generateData(tx_locs, args):
def main(args):
tx_locs = None
if args.train:
if args.single:
if args.txloc is None:
print("did not specify tx location")
return
locations = [float(x) for x in args.txloc.split(' ')]
tx_locs = np.array(locations).reshape(-1, 2)
elif args.train:
np.random.seed(RANDOM_SEED_TRAIN)
tx_locs = getLocs([-3, 3], [-3, 3], step_size=0.3)
elif args.train_real:
@ -96,6 +104,19 @@ if __name__ == '__main__':
'outfolder',
help='output generated data to folder'
)
p.add_argument(
'--single',
dest='single',
action='store_true',
default=False,
help='generate data with tx location'
)
p.add_argument(
'--txloc',
dest='txloc',
default=None,
help='tx location in `x y x y ...` format, in meters'
)
p.add_argument(
'--training',
dest='train',