def indeptest(dim): R1 = music.covar(s1) R2 = music.covar(s2) s1spec = music.Estimator(ants, R1, nsignals=1).spectrum(dim) s2spec = music.Estimator(ants, R2, nsignals=1).spectrum(dim) bothspec = music.Estimator(ants, R, nsignals=2).spectrum(dim) scipy.misc.imsave("s1spec.png", s1spec / s1spec.max()) scipy.misc.imsave("s2spec.png", s2spec / s2spec.max()) scipy.misc.imsave("bothspec.png", bothspec / bothspec.max())
def indeptest(dim): R1 = music.covar(s1) R2 = music.covar(s2) s1spec = music.Estimator(ants,R1,nsignals=1).spectrum(dim) s2spec = music.Estimator(ants,R2,nsignals=1).spectrum(dim) bothspec = music.Estimator(ants,R,nsignals=2).spectrum(dim) sp.misc.imsave("s1spec.png",s1spec/s1spec.max()) sp.misc.imsave("s2spec.png",s2spec/s2spec.max()) sp.misc.imsave("bothspec.png",bothspec/bothspec.max())
def sumspectest(dim=512, n=16): accum = sp.zeros((dim, dim)) for i in range(n): mys1 = util.makesamples(ants, s1_aoa[0], s1_aoa[1], nsamp) mys2 = util.makesamples(ants, s2_aoa[0], s2_aoa[1], nsamp) mysamples = mys2 + mys1 mysamples = util.awgn(mysamples, snr) cov = music.covar(mysamples) accum += music.Estimator(ants, cov, nsignals=2).spectrum((dim, dim)) scipy.misc.imsave("accumspec.png", accum / accum.max())
def sumspectest(dim=512,n=16): accum = sp.zeros((dim,dim)) for i in range(n): mys1 = util.makesamples(ants,s1_aoa[0],s1_aoa[1],nsamp) mys2 = util.makesamples(ants,s2_aoa[0],s2_aoa[1],nsamp) mysamples = mys2 + mys1 mysamples = util.awgn(mysamples,snr) cov = music.covar(mysamples) accum += music.Estimator(ants,cov,nsignals=2).spectrum((dim,dim)) sp.misc.imsave("accumspec.png",accum/accum.max())
def doatest(): print("s1 is {}".format(s1_aoa)) print("s2 is {}".format(s2_aoa)) s1_est = music.Estimator(ants,music.covar(s1),nsignals=1) s2_est = music.Estimator(ants,music.covar(s2),nsignals=1) # s1 t1 = time() s1_res = s1_est.doasearch()[0] t1 = time() - t1 s1_err = sp.rad2deg(util.aoa_diff_rad(s1_res,s1_aoa)) print("s1: found {} in {}s, error {} deg".format(s1_res,t1,s1_err)) # s2 t2 = time() s2_res = s2_est.doasearch()[0] t2 = time() - t2 s2_err = sp.rad2deg(util.aoa_diff_rad(s2_res,s2_aoa)) print("s2: found {} in {}s, error {} deg".format(s2_res,t2,s2_err)) # both signals bothres = est.doasearch() print("Both signals:\n{}".format(bothres))
s2_aoa_deg = [120, 0] s1_aoa = (sp.deg2rad(s1_aoa_deg[0]), sp.deg2rad(s1_aoa_deg[1])) #s2_aoa = (pi/2 + sp.randn()/2, sp.randn()/2) s2_aoa = (sp.deg2rad(s2_aoa_deg[0]), sp.deg2rad(s2_aoa_deg[1])) s1 = util.makesamples(ants, s1_aoa[0], s1_aoa[1], nsamp) s2 = util.makesamples(ants, s2_aoa[0], s2_aoa[1], nsamp) samples = s2 + s1 samples = util.awgn(samples, snr) # add noise to s1 and s2 s1 = util.awgn(s1, snr) s2 = util.awgn(s2, snr) R = music.covar(samples) est = music.Estimator(ants, R, nsignals=2) def spectest(n=256): t = time() spec = est.spectrum((n, n)) elapsed = time() - t print("spectrum calculation time: {}".format(elapsed)) return spec def sumspectest(dim=512, n=16): accum = sp.zeros((dim, dim)) for i in range(n): mys1 = util.makesamples(ants, s1_aoa[0], s1_aoa[1], nsamp)
snr = -6 s1_aoa = (pi/2,0) #s2_aoa = (pi/2 + sp.randn()/2, sp.randn()/2) s2_aoa = (pi/2+pi/6, -pi/6) s1 = util.makesamples(ants,s1_aoa[0],s1_aoa[1],nsamp) s2 = util.makesamples(ants,s2_aoa[0],s2_aoa[1],nsamp) samples = s2 + s1 samples = util.awgn(samples,snr) # add noise to s1 and s2 s1 = util.awgn(s1,snr) s2 = util.awgn(s2,snr) R = music.covar(samples) est = music.Estimator(ants,R,nsignals=2) def spectest(n=256): t = time() spec = est.spectrum((n,n)) elapsed = time() - t print("spectrum calculation time: {}".format(elapsed)) return spec def sumspectest(dim=512,n=16): accum = sp.zeros((dim,dim)) for i in range(n): mys1 = util.makesamples(ants,s1_aoa[0],s1_aoa[1],nsamp) mys2 = util.makesamples(ants,s2_aoa[0],s2_aoa[1],nsamp) mysamples = mys2 + mys1