Exemplo n.º 1
0
 def test_bl_order(self):
     antpos = np.array([[0.,0,0],[1,0,0],[2,0,0],[3,0,0]])
     reds = [[(0,1),(1,2),(2,3)],[(0,2),(1,3)]]
     i = Oi.RedundantInfoLegacy()
     i.init_from_reds(reds,antpos)
     self.assertEqual(i.bl_order(), [bl for ublgp in reds for bl in ublgp])
     i = Oi.RedundantInfoLegacy()
     i.fromfile_txt(redinfo_psa32)
     self.assertEqual(i.bl_order()[:5], [(0,4),(1,4),(2,4),(3,4),(0,5)])
Exemplo n.º 2
0
 def setUp(self):
     #self.i = _O.RedundantInfo()
     self.i = Oi.RedundantInfoLegacy(
     )  # not ideal to require higher-level RedundantInfo object here, but no other way to read txt file
     self.i.fromfile_txt(
         os.path.dirname(os.path.realpath(__file__)) +
         '/../doc/redundantinfo_PSA32.txt')
Exemplo n.º 3
0
 def test_tofromnpz(self):
     i1 = Oi.RedundantInfoLegacy()
     i1.fromfile_txt(redinfo_psa32)
     i2 = Oi.RedundantInfo()
     i1.to_npz(tmpnpz)
     i2.from_npz(tmpnpz)
     self.assertTrue(i1.get_reds() == i2.get_reds())
Exemplo n.º 4
0
 def test_readredundantinfo(self):
     i = Oi.RedundantInfoLegacy()
     #i = _O.RedundantInfo()
     i.fromfile_txt(os.path.dirname(os.path.realpath(__file__)) + '/../doc/redundantinfo_PSA32.txt')
     #i.readredundantinfo(os.path.dirname(os.path.realpath(__file__)) + '/../doc/redundantinfo_PSA32.txt')
     self.assertEqual(i.nAntenna, 32)
     self.assertEqual(i.subsetant.shape, (32,))
Exemplo n.º 5
0
 def test_tofrom_reds(self):
     i1 = Oi.RedundantInfoLegacy()
     i1.fromfile_txt(redinfo_psa32)
     reds = i1.get_reds()
     antpos = i1.get_antpos()
     i2 = Oi.RedundantInfo()
     i2.init_from_reds(reds, antpos)
     self.assertTrue(np.all(i1.antloc == i2.antloc))
     self.assertTrue(np.all(i1.bl2d[i1.ublindex] == i2.bl2d[i2.ublindex]))
Exemplo n.º 6
0
 def test_init(self):
     i = Oi.RedundantInfoLegacy(threshold=64)
     self.assertEqual(i.threshold, 64)
     class RedInf(Oi.RedundantInfo):
         testcase = False
         def from_npz(self, filename):
             self.testcase = True
     i = RedInf(filename='whatever')
     self.assertTrue(i.testcase)
Exemplo n.º 7
0
 def setUp(self):
     #self.i = _O.RedundantInfo()
     self.i = Oi.RedundantInfoLegacy() # not ideal to require higher-level RedundantInfo object here, but no other way to read txt file
     self.i.fromfile_txt(os.path.dirname(os.path.realpath(__file__)) + '/../doc/redundantinfo_PSA32.txt')
 #    self.i.readredundantinfo(os.path.dirname(os.path.realpath(__file__)) + '/../doc/redundantinfo_PSA32.txt')
     self.n_ant = self.i.nAntenna
     self.n_ubl = self.i.ublcount.size
     self.calpar_size = 3 + 2*(self.n_ant + self.n_ubl) + self.n_ant
     self.start_ubl = 3 + 2*self.n_ant
     self.end_ubl = self.start_ubl + 2*self.n_ubl
Exemplo n.º 8
0
    def setUp(self):
        self.info = Oi.RedundantInfoLegacy(filename=redinfo_psa32,
                                           txtmode=True)

        self.info2 = Oc.RedundantInfo()
        self.info2.init_from_reds([[
            (0, 4), (1, 5), (2, 6), (3, 7), (4, 8), (5, 9)
        ], [(0, 3), (1, 4), (2, 5), (3, 6), (4, 7), (5, 8),
            (6, 9)], [(0, 6), (1, 7), (2, 8),
                      (3, 9)], [(0, 5), (1, 6), (2, 7), (3, 8),
                                (4, 9)], [(0, 8),
                                          (1, 9)], [(0, 7), (1, 8), (2, 9)],
                                   [(0, 2), (1, 3), (2, 4), (3, 5), (4, 6),
                                    (5, 7), (6, 8), (7, 9)],
                                   [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5),
                                    (5, 6), (6, 7), (7, 8), (8, 9)]],
                                  np.array([[0., 0., 1.], [0., 50., 1.],
                                            [0., 100., 1.], [0., 150., 1.],
                                            [0., 200., 1.], [0., 250., 1.],
                                            [0., 300., 1.], [0., 350., 1.],
                                            [0., 400., 1.], [0., 450., 1.]]))

        self.freqs = np.linspace(.1, .2, 16)
        self.times = np.arange(4)
        self.reds = self.info2.get_reds()
        self.true_vis = {}
        for i, rg in enumerate(self.reds):
            rd = np.array(
                np.random.randn(self.times.size, self.freqs.size) +
                1j * np.random.randn(self.times.size, self.freqs.size),
                dtype=np.complex64)
            self.true_vis[rg[0]] = rd
        self.true_gains = {
            i: np.ones((self.times.size, self.freqs.size), dtype=np.complex64)
            for i in self.info2.subsetant
        }
        self.data = {}
        self.bl2red = {}
        for rg in self.reds:
            for r in rg:
                self.bl2red[r] = rg[0]
        for redgp in self.reds:
            for ai, aj in redgp:
                self.data[ai, aj] = self.true_vis[self.bl2red[
                    ai, aj]] * self.true_gains[ai] * np.conj(
                        self.true_gains[aj])
        self.unitgains = {
            ant: np.ones((self.times.size, self.freqs.size),
                         dtype=np.complex64)
            for ant in self.info2.subsetant
        }
        self.unitdata = {(ai, aj): np.ones((self.times.size, self.freqs.size),
                                           dtype=np.complex64)
                         for ai, aj in self.info2.bl_order()}
Exemplo n.º 9
0
 def test_compare(self):
     i = Oi.RedundantInfoLegacy()
     self.assertTrue(i.compare(i, verbose=VERBOSE))
Exemplo n.º 10
0
 def setUp(self):
     self.info = Oi.RedundantInfoLegacy(filename=redinfo_psa32,
                                        txtmode=True)
Exemplo n.º 11
0
 def setUp(self):
     self.legacy_info = Oi.RedundantInfoLegacy(filename=redinfo_psa32,
                                               txtmode=True)
     self.info = Oc.RedundantInfo()
     self.info.init_from_reds(self.legacy_info.get_reds(),
                              self.legacy_info.antloc)