Esempio n. 1
0
 def test_overlapping_time(self):
     series = [
         (0, 10),
         (5, 20),
         (15, 30),
         (35, 60),
         (40, 50),
         (200, 300),
         (290, 300),
         (310, 320),
         (310, 311),
         (315, 320),
         (319, 320),
         (319, 320),
     ]
     answer = 165
     self.assertEqual(LofarCasaImage.non_overlapping_time(series), answer)
Esempio n. 2
0
 def setUp(self):
     self.accessor = LofarCasaImage(casatable)
Esempio n. 3
0
class TestLofarCasaImage(unittest.TestCase):
    def setUp(self):
        self.accessor = LofarCasaImage(casatable)

    def test_casaimage(self):
        self.assertTrue(isinstance(self.accessor, LofarAccessor))
        results = self.accessor.extract_metadata()
        sfimage = accessors.sourcefinder_image_from_accessor(self.accessor)

        known_bmaj, known_bmin, known_bpa = 2.64, 1.85, 1.11
        bmaj, bmin, bpa = self.accessor.beam
        self.assertAlmostEqual(known_bmaj, bmaj, 2)
        self.assertAlmostEqual(known_bmin, bmin, 2)
        self.assertAlmostEqual(known_bpa, bpa, 2)

    def test_phase_centre(self):
        known_ra, known_decl = 212.836, 52.203
        self.assertAlmostEqual(self.accessor.centre_ra, known_ra, 2)
        self.assertAlmostEqual(self.accessor.centre_decl, known_decl, 2)

    def test_wcs(self):
        known_ra, known_dec = 212.82677, 52.2025
        known_x, known_y = 256.5, 256.0
        calc_x, calc_y = self.accessor.wcs.s2p([known_ra, known_dec])
        calc_ra, calc_dec = self.accessor.wcs.p2s([known_x, known_y])

        self.assertAlmostEqual(known_ra, calc_ra, 3)
        self.assertAlmostEqual(known_dec, calc_dec, 3)
        self.assertAlmostEqual(known_x, calc_x, 3)
        self.assertAlmostEqual(known_y, calc_y, 3)

    def test_pix_scale(self):
        p1_sky = (self.accessor.centre_ra, self.accessor.centre_decl)
        p1_pix = self.accessor.wcs.s2p(p1_sky)

        pixel_sep = 10  # Along a single axis
        p2_pix = (p1_pix[0], p1_pix[1] + pixel_sep)
        p2_sky = self.accessor.wcs.p2s(p2_pix)

        coord_dist_deg = angsep(p1_sky[0], p1_sky[1], p2_sky[0], p2_sky[1]) / 3600.0
        pix_dist_deg = pixel_sep * self.accessor.pixelsize[1]

        # 6 decimal places => 1e-6*degree / 10pix => 1e-7*degree / 1pix
        #  => Approx 0.15 arcseconds drift across 512 pixels
        # (Probably OK).
        self.assertAlmostEqual(abs(coord_dist_deg), abs(pix_dist_deg), places=6)

    def test_stations(self):
        self.assertEqual(self.accessor.ncore, 42)
        self.assertEqual(self.accessor.nremote, 3)
        self.assertEqual(self.accessor.nintl, 0)

    def test_overlapping_time(self):
        series = [
            (0, 10),
            (5, 20),
            (15, 30),
            (35, 60),
            (40, 50),
            (200, 300),
            (290, 300),
            (310, 320),
            (310, 311),
            (315, 320),
            (319, 320),
            (319, 320),
        ]
        answer = 165
        self.assertEqual(LofarCasaImage.non_overlapping_time(series), answer)

    def test_parse_tautime(self):
        """
        Insert some mock data in self.subtables, check it parses correctly.
        """

        class MockOriginTable:
            def col(self, name):
                if name == "START":
                    return [100, 100, 200]
                elif name == "END":
                    return [150, 175, 300]

        self.accessor.subtables = {"LOFAR_ORIGIN": MockOriginTable()}
        self.assertEqual(self.accessor.parse_tautime(), 175)
Esempio n. 4
0
 def test_overlapping_time(self):
     series = [(0, 10), (5, 20), (15, 30), (35, 60), (40, 50), (200, 300),
               (290, 300), (310, 320), (310, 311), (315, 320), (319, 320),
               (319, 320)]
     answer = 165
     self.assertEqual(LofarCasaImage.non_overlapping_time(series), answer)
Esempio n. 5
0
 def setUp(self):
     self.accessor = LofarCasaImage(casatable)
Esempio n. 6
0
class TestLofarCasaImage(unittest.TestCase):
    def setUp(self):
        self.accessor = LofarCasaImage(casatable)

    def test_casaimage(self):
        self.assertTrue(isinstance(self.accessor, LofarAccessor))
        results = self.accessor.extract_metadata()
        sfimage = accessors.sourcefinder_image_from_accessor(self.accessor)

        known_bmaj, known_bmin, known_bpa = 2.64, 1.85, 1.11
        bmaj, bmin, bpa = self.accessor.beam
        self.assertAlmostEqual(known_bmaj, bmaj, 2)
        self.assertAlmostEqual(known_bmin, bmin, 2)
        self.assertAlmostEqual(known_bpa, bpa, 2)

    def test_phase_centre(self):
        known_ra, known_decl = 212.836, 52.203
        self.assertAlmostEqual(self.accessor.centre_ra, known_ra, 2)
        self.assertAlmostEqual(self.accessor.centre_decl, known_decl, 2)

    def test_wcs(self):
        known_ra, known_dec = 212.82677, 52.2025
        known_x, known_y = 256.5, 256.0
        calc_x, calc_y = self.accessor.wcs.s2p([known_ra, known_dec])
        calc_ra, calc_dec = self.accessor.wcs.p2s([known_x, known_y])

        self.assertAlmostEqual(known_ra, calc_ra, 3)
        self.assertAlmostEqual(known_dec, calc_dec, 3)
        self.assertAlmostEqual(known_x, calc_x, 3)
        self.assertAlmostEqual(known_y, calc_y, 3)

    def test_pix_scale(self):
        p1_sky = (self.accessor.centre_ra, self.accessor.centre_decl)
        p1_pix = self.accessor.wcs.s2p(p1_sky)

        pixel_sep = 10 #Along a single axis
        p2_pix = (p1_pix[0], p1_pix[1] + pixel_sep)
        p2_sky = self.accessor.wcs.p2s(p2_pix)

        coord_dist_deg = angsep(p1_sky[0], p1_sky[1], p2_sky[0], p2_sky[1]) / 3600.0
        pix_dist_deg = pixel_sep * self.accessor.pixelsize[1]

        #6 decimal places => 1e-6*degree / 10pix => 1e-7*degree / 1pix
        #  => Approx 0.15 arcseconds drift across 512 pixels
        # (Probably OK).
        self.assertAlmostEqual(abs(coord_dist_deg), abs(pix_dist_deg), places=6)

    def test_stations(self):
        self.assertEqual(self.accessor.ncore, 42)
        self.assertEqual(self.accessor.nremote, 3)
        self.assertEqual(self.accessor.nintl, 0)

    def test_overlapping_time(self):
        series = [(0, 10), (5, 20), (15, 30), (35, 60), (40, 50), (200, 300),
                  (290, 300), (310, 320), (310, 311), (315, 320), (319, 320),
                  (319, 320)]
        answer = 165
        self.assertEqual(LofarCasaImage.non_overlapping_time(series), answer)

    def test_parse_tautime(self):
        """
        Insert some mock data in self.subtables, check it parses correctly.
        """
        class MockOriginTable:
            def col(self, name):
                if name == 'START': return [100, 100, 200]
                elif name == 'END': return [150, 175, 300]
        subtables = {'LOFAR_ORIGIN': MockOriginTable()}
        self.assertEqual(self.accessor.parse_tautime(subtables), 175)
Esempio n. 7
0
 def test_lofar_casatable_pickle(self):
     accessor = LofarCasaImage(CASA_TABLE)
     pickled = cPickle.dumps(accessor)
     unpickled = cPickle.loads(pickled)
     self.assertEqual(type(unpickled), type(accessor))