Exemplo n.º 1
0
    def _test_table_row(self, targets):
        """Test cuts work with tables from several I/O libraries
        """
        # ADM add the DR7/DR8 data columns if they aren't there yet.
        # ADM can remove this once DR8 is finalized.
        if "MASKBITS" not in targets.dtype.names:
            targets = io.add_dr8_columns(targets)

        cmx, pshift = cuts.apply_cuts(targets, cmxdir=self.cmxdir)
        self.assertEqual(len(cmx), len(targets))

        cmx, pshift = cuts.apply_cuts(targets[0], cmxdir=self.cmxdir)
        self.assertTrue(isinstance(cmx, numbers.Integral),
                        'CMX_TARGET mask not an int')
Exemplo n.º 2
0
    def test_cuts_basic(self):
        """Test cuts work with either data or filenames
        """
        # ADM test for tractor files
        cmx, pshift = cuts.apply_cuts(self.tractorfiles[0], cmxdir=self.cmxdir)
        data = io.read_tractor(self.tractorfiles[0])
        cmx2, pshift2 = cuts.apply_cuts(data, cmxdir=self.cmxdir)
        self.assertTrue(np.all(cmx == cmx2))
        self.assertTrue(np.all(pshift == pshift2))

        # ADM test for sweeps files
        cmx, pshift = cuts.apply_cuts(self.sweepfiles[0], cmxdir=self.cmxdir)
        data = io.read_tractor(self.sweepfiles[0])
        cmx2, pshift2 = cuts.apply_cuts(data, cmxdir=self.cmxdir)
        self.assertTrue(np.all(cmx == cmx2))
        self.assertTrue(np.all(pshift == pshift2))
Exemplo n.º 3
0
    def test_cuts_basic(self):
        """Test cuts work with either data or filenames
        """
        # ADM test for tractor files.
        # ADM No QSO cuts for speed. This doesn't affect coverage.
        cmx, pshift = cuts.apply_cuts(self.tractorfiles[0],
                                      cmxdir=self.cmxdir,
                                      noqso=True)
        data = io.read_tractor(self.tractorfiles[0])
        cmx2, pshift2 = cuts.apply_cuts(data, cmxdir=self.cmxdir, noqso=True)
        self.assertTrue(np.all(cmx == cmx2))
        self.assertTrue(np.all(pshift == pshift2))

        # ADM test for sweeps files.
        # ADM No QSO cuts for speed. This doesn't affect coverage.
        cmx, pshift = cuts.apply_cuts(self.sweepfiles[0],
                                      cmxdir=self.cmxdir,
                                      noqso=True)
        data = io.read_tractor(self.sweepfiles[0])
        cmx2, pshift2 = cuts.apply_cuts(data, cmxdir=self.cmxdir, noqso=True)
        self.assertTrue(np.all(cmx == cmx2))
        self.assertTrue(np.all(pshift == pshift2))
Exemplo n.º 4
0
        fitsio.write('t/' + basename(filepath),
                     data[keep],
                     header=hdr,
                     clobber=True)
        print('made Tractor file for brick {}...t={:.2f}s'.format(
            brick,
            time() - start))

    sweepdir = '/global/cfs/cdirs/cosmo/data/legacysurvey/dr8/south/sweep/8.0/'
    # sweepdir = '/project/projectdirs/cosmo/data/legacysurvey/dr7/sweep/7.1/'
    # sweepdir = '/project/projectdirs/cosmo/data/legacysurvey/dr3.1/sweep/3.1'
    # sweepdir = '/data/legacysurvey/dr2p/sweep/'
    for radec in ['310m005-320p000', '320m005-330p000', '330m005-340p000']:
        filepath = '{}/sweep-{}.fits'.format(sweepdir, radec)
        desi_target, bgs_target, mws_target = apply_cuts(filepath)
        cmx_target = cmx_cuts.apply_cuts(filepath)

        # ADM as nobody is testing the MWS in the sandbox, yet, we need to.
        # ADM ensure we ignore MWS targets for testing the main algorithms.
        yes = np.where((desi_target != 0) & (mws_target == 0))[0]
        no = np.where(desi_target == 0)[0]
        keep = np.concatenate([yes[0:3], no[0:3]])
        data, hdr = read_tractor(filepath, header=True)

        # ADM the "CONTINUE" comment keyword is not yet implemented
        # ADM in fitsio, so delete it to prevent fitsio barfing on headers.
        hdr.delete("CONTINUE")

        fitsio.write('t/' + basename(filepath),
                     data[keep],
                     header=hdr,