def setup_class(klass):
        import os

        klass.curdir = os.path.dirname(__file__)
        klass.datadir = os.path.join(klass.curdir, 'data')

        klass.config_file = \
            os.path.abspath(os.path.join(klass.datadir, "calibrators.ini"))

        klass.config_file_empty = \
            os.path.abspath(os.path.join(klass.datadir,
                                         "calibrators_nocal.ini"))

        klass.config = read_config(klass.config_file)
        klass.caldir = os.path.join(klass.datadir, 'sim', 'calibration')
        klass.caldir2 = os.path.join(klass.datadir, 'sim', 'calibration2')
        klass.caldir3 = os.path.join(klass.datadir, 'sim', 'calibration_bad')
        klass.crossdir = os.path.join(klass.datadir, 'sim', 'crossscans')
        if not os.path.exists(klass.caldir):
            print('Fake calibrators: DummyCal, 1 Jy.')
            mkdir_p(klass.caldir)
            sim_crossscans(5, klass.caldir)
        if not os.path.exists(klass.caldir2):
            print('Fake calibrators: DummyCal2, 1 Jy.')
            mkdir_p(klass.caldir2)
            sim_crossscans(5, klass.caldir2, srcname='DummyCal2')
        if not os.path.exists(klass.caldir3):
            print('Fake calibrators: DummyCal2, wrong flux 0.52 Jy.')
            mkdir_p(klass.caldir3)
            sim_crossscans(1,
                           klass.caldir3,
                           srcname='DummyCal2',
                           scan_func=source_scan_func)
        if not os.path.exists(klass.crossdir):
            print('Fake cross scans: DummySrc, 0.52 Jy.')
            mkdir_p(klass.crossdir)
            sim_crossscans(5,
                           klass.crossdir,
                           srcname='DummySrc',
                           scan_func=source_scan_func)

        klass.scan_list = \
            list_scans(klass.caldir, ['./']) + \
            list_scans(klass.caldir2, ['./']) + \
            list_scans(klass.crossdir, ['./'])

        klass.scan_list.sort()
        caltable = CalibratorTable()
        caltable.from_scans(klass.scan_list)
        caltable.update()

        klass.calfile = os.path.join(klass.curdir, 'test_calibration.hdf5')
        caltable.write(klass.calfile, overwrite=True)
        caltable.write(klass.calfile.replace('hdf5', 'csv'))
Esempio n. 2
0
    def test_check_consistency_fails_with_bad_data(self):
        scan_list = \
            list_scans(self.caldir, ['./']) + \
            list_scans(self.caldir2, ['./']) + \
            list_scans(self.caldir3, ['./']) + \
            list_scans(self.crossdir, ['./'])

        scan_list.sort()
        caltable = CalibratorTable()
        caltable.from_scans(scan_list)
        caltable.update()
        res = caltable.check_consistency(channel='Feed0_LCP')
        assert not np.all(res)