From d26361b0b74d6f7f5dc0fbf1b26c0478c2cab8c3 Mon Sep 17 00:00:00 2001 From: ferrari <maxence.ferrari@gmail.com> Date: Fri, 7 Jan 2022 17:21:20 +0100 Subject: [PATCH] Handle hyperres computing --- gsrp_tdoa_hyperres.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gsrp_tdoa_hyperres.py b/gsrp_tdoa_hyperres.py index 27f8d05..73836c1 100755 --- a/gsrp_tdoa_hyperres.py +++ b/gsrp_tdoa_hyperres.py @@ -173,21 +173,28 @@ def main(args): raise ValueError(f'Error: hop size {args.stride} is neither an existing file nor a float') 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) - + if args.no_hyperres: + result1 = results + else: + result1, result2 =results # compute additional non-independent TDOAs 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)) - additional2 = [(b - a) for a, b in itertools.combinations(result2.T[1:], 2)] - result2 = np.hstack((result2,) + tuple(a[:, np.newaxis] for a in additional2)) + 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)) if args.outfile.endswith('.npy'): np.save(args.outfile, result1) - np.save(args.outfile[:-4] + '_2.npy', result2) + if not args.no_hyperres: + np.save(args.outfile[:-4] + '_2.npy', result2) else: 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.") return 0 -- GitLab