def test_redcal_xtalk(self): antpos = np.array([[0., 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0]]) d = { (1, 2): np.array([[1.]], dtype=np.complex64), (2, 3): np.array([[1. + 1j]], dtype=np.complex64) } x = { (1, 2): np.array([[0.]], dtype=np.complex64), (2, 3): np.array([[0. + 1j]], dtype=np.complex64) } reds = [[(1, 2), (2, 3)]] info = Oc.RedundantInfo() info.init_from_reds(reds, antpos) m, g, v = Oc.redcal(d, info, xtalk=x, uselogcal=False) self.assertEqual(g[1][0, 0], 1.) self.assertEqual(g[2][0, 0], 1.) self.assertEqual(g[3][0, 0], 1.) #2D array testing d = { (1, 2): np.array([[1., 2], [3., 4]], dtype=np.complex64), (2, 3): np.array([[1. + 1j, 2 + 2j], [3 + 3j, 4 + 4j]], dtype=np.complex64) } x = { (1, 2): np.array([[0., 2], [2., 3]], dtype=np.complex64), (2, 3): np.array([[0. + 1j, 1 + 2j], [2 + 3j, 3 + 4j]], dtype=np.complex64) } m, g, v = Oc.redcal(d, info, xtalk=x, uselogcal=False) self.assertEqual(g[1][0, 0], 1.) self.assertEqual(g[2][0, 0], 1.) self.assertEqual(g[3][0, 0], 1.) self.assertEqual(m['res'][(2, 3)][0][0], 0.)
def test_redcal(self): #check that logcal give 0 chi2 for all 20 testinfos for index in xrange(20): arrayinfopath = os.path.dirname( os.path.realpath(__file__)) + '/testinfo/test' + str( index + 1) + '_array_info.txt' c = Oc.RedundantCalibrator(56) c.compute_redundantinfo(arrayinfopath, tol=.1) info = c.Info npz = np.load(testdata % index) bls = [tuple(bl) for bl in npz['bls']] dd = dict(zip(bls, npz['vis'])) m, g, v = Oc.redcal(dd, info, removedegen=True, maxiter=50, stepsize=.2, computeUBLFit=True, conv=1e-5, uselogcal=True) calparpath = os.path.dirname(os.path.realpath( __file__)) + '/testinfo/test' + str(index + 1) + '_calpar.txt' with open(calparpath) as f: rawinfo = [[float(x) for x in line.split()] for line in f] temp = np.array(rawinfo[:-1]) correctcalpar = (np.array(temp[:, 0]) + 1.0j * np.array(temp[:, 1])) i = g.keys()[0] scalar = correctcalpar[i].real / g[i].real for i in xrange(56): if not g.has_key(i): continue self.assertAlmostEqual( np.abs(correctcalpar[i] - g[i] * scalar), 0, 4)
def test_redcal_xtalk(self): antpos = np.array([[0.,0,0],[1,0,0],[2,0,0],[3,0,0]]) d = {(1,2): np.array([[1.]], dtype=np.complex64), (2,3): np.array([[1.+1j]], dtype=np.complex64)} x = {(1,2): np.array([[0.]], dtype=np.complex64), (2,3): np.array([[0.+1j]], dtype=np.complex64)} reds = [[(1,2),(2,3)]] info = Oc.RedundantInfo(); info.init_from_reds(reds, antpos) m,g,v = Oc.redcal(d, info, xtalk=x, uselogcal=False) self.assertEqual(g[1][0,0], 1.) self.assertEqual(g[2][0,0], 1.) self.assertEqual(g[3][0,0], 1.) #2D array testing d = {(1,2): np.array([[1.,2],[3.,4]],dtype=np.complex64), (2,3): np.array([[1.+1j,2+2j],[3+3j,4+4j]],dtype=np.complex64)} x = {(1,2): np.array([[0.,2],[2.,3]],dtype=np.complex64), (2,3): np.array([[0.+1j,1+2j],[2+3j,3+4j]],dtype=np.complex64)} m,g,v = Oc.redcal(d, info, xtalk=x, uselogcal=False) self.assertEqual(g[1][0,0], 1.) self.assertEqual(g[2][0,0], 1.) self.assertEqual(g[3][0,0], 1.) self.assertEqual(m['res'][(2,3)][0][0],0.)
def test_redcal_xtalk(self): antpos = np.array([[0.,0,0],[1,0,0],[2,0,0],[3,0,0]]) d = {(1,2): np.array([[1.]], dtype=np.complex64), (2,3): np.array([[1.+1j]], dtype=np.complex64)} x = {(1,2): np.array([[0.]], dtype=np.complex64), (2,3): np.array([[0.+1j]], dtype=np.complex64)} reds = [[(1,2),(2,3)]] info = Oi.RedundantInfo(); info.init_from_reds(reds, antpos) m,g,v = Oc.redcal(d, info, xtalk=x, uselogcal=False) self.assertEqual(g[1][0,0], 1.) self.assertEqual(g[2][0,0], 1.) self.assertEqual(g[3][0,0], 1.)
def test_redcal(self): #check that logcal give 0 chi2 for all 20 testinfos for index in xrange(20): arrayinfopath = os.path.dirname(os.path.realpath(__file__)) + '/testinfo/test'+str(index+1)+'_array_info.txt' c = Oc.RedundantCalibrator(56) c.compute_redundantinfo(arrayinfopath, tol=.1) info = c.Info npz = np.load(testdata % index) bls = [tuple(bl) for bl in npz['bls']] dd = dict(zip(bls, npz['vis'])) m,g,v = Oc.redcal(dd, info, removedegen=True,maxiter=50,stepsize=.2,computeUBLFit=True,conv=1e-5,uselogcal=True) calparpath = os.path.dirname(os.path.realpath(__file__)) + '/testinfo/test'+str(index+1)+'_calpar.txt' with open(calparpath) as f: rawinfo = [[float(x) for x in line.split()] for line in f] temp = np.array(rawinfo[:-1]) correctcalpar = (np.array(temp[:,0]) + 1.0j*np.array(temp[:,1])) i = g.keys()[0] scalar = correctcalpar[i].real / g[i].real for i in xrange(56): if not g.has_key(i): continue self.assertAlmostEqual(np.abs(correctcalpar[i] - g[i] * scalar), 0, 4)