コード例 #1
0
    def test_find_scan_through_invalid_pixel(self):
        scanset = ScanSet('test.hdf5')

        images = scanset.calculate_images()
        ysize, xsize = images['Feed0_RCP'].shape
        _, _, _, _, _, _, _, coord = \
            scanset.find_scans_through_pixel(xsize//2, -2, test=True)
        assert coord == {}
        _, _, _, _, _, _, _, coord = \
            scanset.find_scans_through_pixel(xsize//2, ysize + 2, test=True)
        assert coord == {}
コード例 #2
0
    def test_find_scan_through_pixel_bad_scan(self, logger, caplog):
        scanset = ScanSet('test.hdf5')
        images = scanset.calculate_images()
        ysize, xsize = images['Feed0_RCP'].shape
        x, y = xsize // 2, 0
        good_entries = np.logical_and(
            np.abs(scanset['x'][:, 0] - x) < 1,
            np.abs(scanset['y'][:, 0] - y) < 1)

        sids = list(set(scanset['Scan_id'][good_entries]))
        scanset.scan_list[sids[0]] = 'skd'
        scanset.find_scans_through_pixel(x, y, test=True)
        assert "Errors while opening scan skd" in caplog.text
コード例 #3
0
    def test_update_scan_zap(self):
        scanset = ScanSet('test.hdf5')

        images = scanset.calculate_images()
        ysize, xsize = images['Feed0_RCP'].shape
        ra_xs, ra_ys, dec_xs, dec_ys, scan_ids, ra_masks, dec_masks, coord = \
            scanset.find_scans_through_pixel(xsize//2, 0, test=True)

        sname = sorted(list(dec_xs.keys()))[0]
        s = Scan(sname)

        info = {sname: copy.copy(self.stdinfo)}
        info[sname]['zap'].xs = [np.float(s['dec'][0]), np.float(s['dec'][10])]
        sid = scan_ids[sname]
        mask = scanset['Scan_id'] == sid
        before = scanset['Feed0_RCP-filt'][mask]
        scanset.update_scan(sname,
                            scan_ids[sname],
                            coord[sname],
                            info[sname]['zap'],
                            info[sname]['fitpars'],
                            info[sname]['FLAG'],
                            test=True)
        after = scanset['Feed0_RCP-filt'][mask]

        assert np.all(before[:10] != after[:10])
        s = Scan(sname)

        assert np.all(
            np.array(after, dtype=bool) == np.array(s['Feed0_RCP-filt'],
                                                    dtype=bool))
        os.unlink(sname.replace('fits', 'hdf5'))
コード例 #4
0
    def test_update_scan_fit(self):
        scanset = ScanSet('test.hdf5')

        images = scanset.calculate_images()
        ysize, xsize = images['Feed0_RCP'].shape
        ra_xs, ra_ys, dec_xs, dec_ys, scan_ids, ra_masks, dec_masks, coord = \
            scanset.find_scans_through_pixel(xsize//2, 0, test=True)

        sname = list(scan_ids.keys())[0]

        info = {sname: copy.copy(self.stdinfo)}
        info[sname]['fitpars'] = np.array([0.1, 0.3])
        sid = scan_ids[sname]
        mask = scanset['Scan_id'] == sid
        before = scanset['Feed0_RCP'][mask]
        scanset.update_scan(sname,
                            scan_ids[sname],
                            coord[sname],
                            info[sname]['zap'],
                            info[sname]['fitpars'],
                            info[sname]['FLAG'],
                            test=True)
        after = scanset['Feed0_RCP'][mask]
        assert np.all(before != after)
        s = Scan(sname)
        assert np.all(after == s['Feed0_RCP'])
        os.unlink(sname.replace('fits', 'hdf5'))
コード例 #5
0
    def test_find_scan_through_pixel0(self):
        scanset = ScanSet('test.hdf5')

        images = scanset.calculate_images()
        ysize, xsize = images['Ch0'].shape
        _, _, _, _, _, _, _, coord = \
            scanset.find_scans_through_pixel(xsize//2, ysize-1, test=True)

        dec_scan = os.path.join(self.obsdir_dec,
                                self.dec_scans[self.n_dec_scans // 2])
        assert dec_scan in coord
        assert coord[dec_scan] == 'dec'
        ra_scan = os.path.join(self.obsdir_ra, self.ra_scans[self.n_ra_scans])
        assert ra_scan in coord
        assert coord[ra_scan] == 'ra'
コード例 #6
0
    def test_find_scan_through_pixel1(self):
        scanset = ScanSet('test.hdf5')
        for i in scanset.chan_columns:
            scanset.remove_column(i + '-filt')

        images = scanset.calculate_images()
        ysize, xsize = images['Feed0_RCP'].shape
        _, _, _, _, _, _, _, coord = \
            scanset.find_scans_through_pixel(xsize//2, 0, test=True)

        dec_scan = os.path.join(self.obsdir_dec,
                                self.dec_scans[self.n_dec_scans // 2])
        assert dec_scan in coord
        assert coord[dec_scan] == 'dec'
        ra_scan = os.path.join(self.obsdir_ra, 'Ra0.fits')
        assert ra_scan in coord
        assert coord[ra_scan] == 'ra'
コード例 #7
0
    def test_update_scan_invalid(self):
        scanset = ScanSet('test.hdf5')

        images = scanset.calculate_images()
        ysize, xsize = images['Feed0_RCP'].shape
        ra_xs, ra_ys, dec_xs, dec_ys, scan_ids, ra_masks, dec_masks, coord = \
            scanset.find_scans_through_pixel(xsize//2, 0, test=True)

        sname = 'xkd'
        coord['xkd'] = None
        scan_ids['xkd'] = None

        info = {sname: copy.copy(self.stdinfo)}
        info[sname]['FLAG'] = True
        scanset.update_scan(sname,
                            scan_ids[sname],
                            coord[sname],
                            info[sname]['zap'],
                            info[sname]['fitpars'],
                            info[sname]['FLAG'],
                            test=True)