Пример #1
0
    def test_fgcmLoadReference(self):
        """
        Test loading of the fgcm reference catalogs.
        """

        filterList = ['r', 'i']

        config = fgcmcal.FgcmLoadReferenceCatalogConfig()
        config.applyColorTerms = True
        config.refObjLoader.ref_dataset_name = 'ps1_pv3_3pi_20170110'
        config.refFilterMap = {'r': 'r', 'i': 'i'}
        config.colorterms.data = {}
        config.colorterms.data['ps1*'] = lsst.pipe.tasks.colorterms.ColortermDict()
        config.colorterms.data['ps1*'].data = {}
        config.colorterms.data['ps1*'].data['r'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['ps1*'].data['r'].primary = 'r'
        config.colorterms.data['ps1*'].data['r'].secondary = 'i'
        config.colorterms.data['ps1*'].data['r'].c0 = -0.000144
        config.colorterms.data['ps1*'].data['r'].c1 = 0.001369
        config.colorterms.data['ps1*'].data['r'].c2 = -0.008380
        config.colorterms.data['ps1*'].data['i'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['ps1*'].data['i'].primary = 'i'
        config.colorterms.data['ps1*'].data['i'].secondary = 'z'
        config.colorterms.data['ps1*'].data['i'].c0 = 0.000643
        config.colorterms.data['ps1*'].data['i'].c1 = -0.130078
        config.colorterms.data['ps1*'].data['i'].c2 = -0.006855

        butler = dafPersist.Butler(self.inputDir)
        loadCat = fgcmcal.FgcmLoadReferenceCatalogTask(butler, config=config)

        ra = 337.656174
        dec = 0.823595
        rad = 0.1

        refCat = loadCat.getFgcmReferenceStarsSkyCircle(ra, dec, rad, filterList)

        # Check the number of mags and ranges
        self.assertEqual(len(filterList), refCat['refMag'].shape[1])
        self.assertEqual(len(filterList), refCat['refMagErr'].shape[1])
        self.assertLess(np.max(refCat['refMag'][:, 0]), 99.1)
        self.assertLess(np.max(refCat['refMag'][:, 1]), 99.1)
        self.assertLess(np.max(refCat['refMagErr'][:, 0]), 99.1)
        self.assertLess(np.max(refCat['refMagErr'][:, 1]), 99.1)
        test, = np.where((refCat['refMag'][:, 0] < 30.0) &
                         (refCat['refMag'][:, 1] < 30.0))
        self.assertGreater(test.size, 0)

        # Check the separations from the center
        self.assertLess(np.max(esutil.coords.sphdist(ra, dec, refCat['ra'], refCat['dec'])), rad)

        # And load a healpixel
        nside = 256
        pixel = 387520

        refCat = loadCat.getFgcmReferenceStarsHealpix(nside, pixel, filterList)

        ipring = hp.ang2pix(nside, np.radians(90.0 - refCat['dec']), np.radians(refCat['ra']))
        self.assertEqual(pixel, np.max(ipring))
        self.assertEqual(pixel, np.min(ipring))
Пример #2
0
    def test_fgcmLoadReferenceOtherFilters(self):
        """
        Test loading of the fgcm reference catalogs using unmatched filter names.
        """

        filterList = ['r2', 'i2']

        config = fgcmcal.FgcmLoadReferenceCatalogConfig()
        config.applyColorTerms = True
        config.refObjLoader.ref_dataset_name = 'ps1_pv3_3pi_20170110'
        config.refFilterMap = {'r2': 'r', 'i2': 'i'}
        config.colorterms.data = {}
        config.colorterms.data['ps1*'] = lsst.pipe.tasks.colorterms.ColortermDict()
        config.colorterms.data['ps1*'].data = {}
        config.colorterms.data['ps1*'].data['r2'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['ps1*'].data['r2'].primary = 'r'
        config.colorterms.data['ps1*'].data['r2'].secondary = 'i'
        config.colorterms.data['ps1*'].data['r2'].c0 = -0.000032
        config.colorterms.data['ps1*'].data['r2'].c1 = -0.002866
        config.colorterms.data['ps1*'].data['r2'].c2 = -0.012638
        config.colorterms.data['ps1*'].data['i2'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['ps1*'].data['i2'].primary = 'i'
        config.colorterms.data['ps1*'].data['i2'].secondary = 'z'
        config.colorterms.data['ps1*'].data['i2'].c0 = 0.001625
        config.colorterms.data['ps1*'].data['i2'].c1 = -0.200406
        config.colorterms.data['ps1*'].data['i2'].c2 = -0.013666

        butler = dafPersist.Butler(self.inputDir)
        loadCat = fgcmcal.FgcmLoadReferenceCatalogTask(butler, config=config)

        ra = 337.656174
        dec = 0.823595
        rad = 0.1

        refCat = loadCat.getFgcmReferenceStarsSkyCircle(ra, dec, rad, filterList)

        self.assertEqual(len(filterList), refCat['refMag'].shape[1])
        self.assertEqual(len(filterList), refCat['refMagErr'].shape[1])
        test, = np.where((refCat['refMag'][:, 0] < 30.0) &
                         (refCat['refMag'][:, 1] < 30.0))
        self.assertGreater(test.size, 0)
Пример #3
0
    def test_fgcmLoadReference(self):
        """
        Test loading of the fgcm reference catalogs.
        """

        filterList = ['r', 'i']

        config = fgcmcal.FgcmLoadReferenceCatalogConfig()
        config.applyColorTerms = True
        config.refObjLoader.ref_dataset_name = 'sdss-dr9-fink-v5b'
        config.colorterms.data = {}
        config.colorterms.data[
            'sdss*'] = lsst.pipe.tasks.colorterms.ColortermDict()
        config.colorterms.data['sdss*'].data = {}
        config.colorterms.data['sdss*'].data[
            'g'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['sdss*'].data['g'].primary = 'g'
        config.colorterms.data['sdss*'].data['g'].secondary = 'r'
        config.colorterms.data['sdss*'].data['g'].c0 = -0.00816446
        config.colorterms.data['sdss*'].data['g'].c1 = -0.08366937
        config.colorterms.data['sdss*'].data['g'].c2 = -0.00726883
        config.colorterms.data['sdss*'].data[
            'r'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['sdss*'].data['r'].primary = 'r'
        config.colorterms.data['sdss*'].data['r'].secondary = 'i'
        config.colorterms.data['sdss*'].data['r'].c0 = 0.0013181
        config.colorterms.data['sdss*'].data['r'].c1 = 0.01284177
        config.colorterms.data['sdss*'].data['r'].c2 = -0.03068248
        config.colorterms.data['sdss*'].data[
            'i'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['sdss*'].data['i'].primary = 'i'
        config.colorterms.data['sdss*'].data['i'].secondary = 'z'
        config.colorterms.data['sdss*'].data['i'].c0 = 0.00130204
        config.colorterms.data['sdss*'].data['i'].c1 = -0.16922042
        config.colorterms.data['sdss*'].data['i'].c2 = -0.01374245

        butler = dafPersist.Butler(self.inputDir)
        loadCat = fgcmcal.FgcmLoadReferenceCatalogTask(butler, config=config)

        ra = 320.0
        dec = 0.0
        rad = 0.1

        refCat = loadCat.getFgcmReferenceStarsSkyCircle(
            ra, dec, rad, filterList)

        # Check the number of mags and ranges
        self.assertEqual(len(filterList), refCat['refMag'].shape[1])
        self.assertEqual(len(filterList), refCat['refMagErr'].shape[1])
        self.assertLess(np.max(refCat['refMag'][:, 0]), 99.1)
        self.assertLess(np.max(refCat['refMag'][:, 1]), 99.1)
        self.assertLess(np.max(refCat['refMagErr'][:, 0]), 99.1)
        self.assertLess(np.max(refCat['refMagErr'][:, 1]), 99.1)

        # Check the separations from the center
        self.assertLess(
            np.max(esutil.coords.sphdist(ra, dec, refCat['ra'],
                                         refCat['dec'])), rad)

        # And load a healpixel
        nside = 256
        pixel = 393614

        refCat = loadCat.getFgcmReferenceStarsHealpix(nside, pixel, filterList)

        ipring = hp.ang2pix(nside, np.radians(90.0 - refCat['dec']),
                            np.radians(refCat['ra']))
        self.assertEqual(pixel, np.max(ipring))
        self.assertEqual(pixel, np.min(ipring))
Пример #4
0
    def test_fgcmLoadReference(self):
        """
        Test loading of the fgcm reference catalogs.
        """

        filterList = ['HSC-R', 'HSC-I']

        config = fgcmcal.FgcmLoadReferenceCatalogConfig()
        config.applyColorTerms = True
        config.filterMap = {'HSC-R': 'r', 'HSC-I': 'i'}
        config.colorterms.data = {}
        config.colorterms.data[
            'ps1*'] = lsst.pipe.tasks.colorterms.ColortermDict()
        config.colorterms.data['ps1*'].data = {}
        config.colorterms.data['ps1*'].data[
            'HSC-R'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['ps1*'].data['HSC-R'].primary = 'r'
        config.colorterms.data['ps1*'].data['HSC-R'].secondary = 'i'
        config.colorterms.data['ps1*'].data['HSC-R'].c0 = -0.000144
        config.colorterms.data['ps1*'].data['HSC-R'].c1 = 0.001369
        config.colorterms.data['ps1*'].data['HSC-R'].c2 = -0.008380
        config.colorterms.data['ps1*'].data[
            'HSC-I'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['ps1*'].data['HSC-I'].primary = 'i'
        config.colorterms.data['ps1*'].data['HSC-I'].secondary = 'z'
        config.colorterms.data['ps1*'].data['HSC-I'].c0 = 0.000643
        config.colorterms.data['ps1*'].data['HSC-I'].c1 = -0.130078
        config.colorterms.data['ps1*'].data['HSC-I'].c2 = -0.006855

        refCatName = 'ps1_pv3_3pi_20170110'

        butler = lsst.daf.butler.Butler(
            self.repo,
            instrument='HSC',
            collections=['HSC/testdata', 'refcats/gen2'])
        refs = set(butler.registry.queryDatasets(refCatName))
        dataIds = [butler.registry.expandDataId(ref.dataId) for ref in refs]
        refCats = [butler.getDirectDeferred(ref) for ref in refs]

        refConfig = LoadReferenceObjectsConfig()
        refConfig.filterMap = config.filterMap

        refObjLoader = ReferenceObjectLoader(dataIds=dataIds,
                                             refCats=refCats,
                                             config=refConfig)

        loadCat = fgcmcal.FgcmLoadReferenceCatalogTask(
            refObjLoader=refObjLoader, refCatName=refCatName, config=config)

        ra = 337.656174
        dec = 0.823595
        rad = 0.1

        refCat = loadCat.getFgcmReferenceStarsSkyCircle(
            ra, dec, rad, filterList)

        # Check the number of mags and ranges
        self.assertEqual(len(filterList), refCat['refMag'].shape[1])
        self.assertEqual(len(filterList), refCat['refMagErr'].shape[1])
        self.assertLess(np.max(refCat['refMag'][:, 0]), 99.1)
        self.assertLess(np.max(refCat['refMag'][:, 1]), 99.1)
        self.assertLess(np.max(refCat['refMagErr'][:, 0]), 99.1)
        self.assertLess(np.max(refCat['refMagErr'][:, 1]), 99.1)
        test, = np.where((refCat['refMag'][:, 0] < 30.0)
                         & (refCat['refMag'][:, 1] < 30.0))
        self.assertGreater(test.size, 0)

        # Check the separations from the center
        self.assertLess(
            np.max(esutil.coords.sphdist(ra, dec, refCat['ra'],
                                         refCat['dec'])), rad)

        # And load a healpixel
        nside = 256
        pixel = 387520

        refCat = loadCat.getFgcmReferenceStarsHealpix(nside, pixel, filterList)

        ipring = hp.ang2pix(nside, np.radians(90.0 - refCat['dec']),
                            np.radians(refCat['ra']))
        self.assertEqual(pixel, np.max(ipring))
        self.assertEqual(pixel, np.min(ipring))
Пример #5
0
    def test_fgcmLoadReferenceOtherFilters(self):
        """
        Test loading of the fgcm reference catalogs using unmatched filter names.
        """

        filterList = ['HSC-R2', 'HSC-I2']

        config = fgcmcal.FgcmLoadReferenceCatalogConfig()
        config.applyColorTerms = True
        config.filterMap = {'HSC-R2': 'r', 'HSC-I2': 'i'}
        config.colorterms.data = {}
        config.colorterms.data[
            'ps1*'] = lsst.pipe.tasks.colorterms.ColortermDict()
        config.colorterms.data['ps1*'].data = {}
        config.colorterms.data['ps1*'].data[
            'HSC-R2'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['ps1*'].data['HSC-R2'].primary = 'r'
        config.colorterms.data['ps1*'].data['HSC-R2'].secondary = 'i'
        config.colorterms.data['ps1*'].data['HSC-R2'].c0 = -0.000032
        config.colorterms.data['ps1*'].data['HSC-R2'].c1 = -0.002866
        config.colorterms.data['ps1*'].data['HSC-R2'].c2 = -0.012638
        config.colorterms.data['ps1*'].data[
            'HSC-I2'] = lsst.pipe.tasks.colorterms.Colorterm()
        config.colorterms.data['ps1*'].data['HSC-I2'].primary = 'i'
        config.colorterms.data['ps1*'].data['HSC-I2'].secondary = 'z'
        config.colorterms.data['ps1*'].data['HSC-I2'].c0 = 0.001625
        config.colorterms.data['ps1*'].data['HSC-I2'].c1 = -0.200406
        config.colorterms.data['ps1*'].data['HSC-I2'].c2 = -0.013666

        refCatName = 'ps1_pv3_3pi_20170110'

        butler = lsst.daf.butler.Butler(
            self.repo,
            instrument='HSC',
            collections=['HSC/testdata', 'refcats/gen2'])
        refs = set(butler.registry.queryDatasets(refCatName))
        dataIds = [butler.registry.expandDataId(ref.dataId) for ref in refs]
        refCats = [butler.getDirectDeferred(ref) for ref in refs]

        refConfig = LoadReferenceObjectsConfig()
        refConfig.filterMap = config.filterMap

        refObjLoader = ReferenceObjectLoader(dataIds=dataIds,
                                             refCats=refCats,
                                             config=refConfig)

        loadCat = fgcmcal.FgcmLoadReferenceCatalogTask(
            refObjLoader=refObjLoader, refCatName=refCatName, config=config)

        ra = 337.656174
        dec = 0.823595
        rad = 0.1

        refCat = loadCat.getFgcmReferenceStarsSkyCircle(
            ra, dec, rad, filterList)

        self.assertEqual(len(filterList), refCat['refMag'].shape[1])
        self.assertEqual(len(filterList), refCat['refMagErr'].shape[1])
        test, = np.where((refCat['refMag'][:, 0] < 30.0)
                         & (refCat['refMag'][:, 1] < 30.0))
        self.assertGreater(test.size, 0)