Skip to content
Snippets Groups Projects
Commit d26361b0 authored by ferrari's avatar ferrari
Browse files

Handle hyperres computing

parent ad9ca72d
Branches master
No related tags found
No related merge requests found
...@@ -173,21 +173,28 @@ def main(args): ...@@ -173,21 +173,28 @@ def main(args):
raise ValueError(f'Error: hop size {args.stride} is neither an existing file nor a float') raise ValueError(f'Error: hop size {args.stride} is neither an existing file nor a float')
print("Computing TDOAs...") print("Computing TDOAs...")
result1 = corr(sound, pos, int(sr * args.frame_size), max_tdoa=int(np.ceil(sr * args.max_tdoa)), results = corr(sound, pos, int(sr * args.frame_size), max_tdoa=int(np.ceil(sr * args.max_tdoa)),
decimate=args.decimate if not args.temporal else 1, mode=args.mode, hyper=not args.no_hyperes) decimate=args.decimate if not args.temporal else 1, mode=args.mode, hyper=not args.no_hyperes)
if args.no_hyperres:
result1 = results
else:
result1, result2 =results
# compute additional non-independent TDOAs # compute additional non-independent TDOAs
additional1 = [(b - a) for a, b in itertools.combinations(result1.T[2:], 2)] additional1 = [(b - a) for a, b in itertools.combinations(result1.T[2:], 2)]
result1 = np.hstack((result1,) + tuple(a[:, np.newaxis] for a in additional1)) result1 = np.hstack((result1,) + tuple(a[:, np.newaxis] for a in additional1))
additional2 = [(b - a) for a, b in itertools.combinations(result2.T[1:], 2)] if not args.no_hyperres:
additional2 = [(b - a) for a, b in itertools.combinations(result2.T[2:], 2)]
result2 = np.hstack((result2,) + tuple(a[:, np.newaxis] for a in additional2)) result2 = np.hstack((result2,) + tuple(a[:, np.newaxis] for a in additional2))
if args.outfile.endswith('.npy'): if args.outfile.endswith('.npy'):
np.save(args.outfile, result1) np.save(args.outfile, result1)
if not args.no_hyperres:
np.save(args.outfile[:-4] + '_2.npy', result2) np.save(args.outfile[:-4] + '_2.npy', result2)
else: else:
np.savetxt(args.outfile, result1, delimiter=',') np.savetxt(args.outfile, result1, delimiter=',')
np.savetxt((lambda x1, x2, x3: x1 + '_2' + x2 + x3)(*args.outfile.rpartition('.', 1)), result2, delimiter=',') if not args.no_hyperres:
np.savetxt((lambda x1, x2, x3: x1 + '_2' + x2 + x3)(*args.outfile.rpartition('.', 1)),
result2, delimiter=',')
print("Done.") print("Done.")
return 0 return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment