예제 #1
0
    def testLoadVersion0(self):
        """Test reading a pre-written format_version=0 (Jy flux) catalog.
        It should be converted to have nJy fluxes.
        """
        path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data',
                            'version0', 'ref_cats', 'cal_ref_cat')

        filenames = sorted(glob.glob(os.path.join(path, '????.fits')))

        loader = MockReferenceObjectLoaderFromFiles(filenames,
                                                    name='cal_ref_cat',
                                                    htmLevel=4)
        result = loader.loadSkyCircle(ingestIndexTestBase.make_coord(10, 20),
                                      5 * lsst.geom.degrees, 'a')

        self.assertTrue(hasNanojanskyFluxUnits(result.refCat.schema))
        catalog = afwTable.SimpleCatalog.readFits(filenames[0])
        self.assertFloatsEqual(catalog['a_flux'] * 1e9,
                               result.refCat['a_flux'])
        self.assertFloatsEqual(catalog['a_fluxSigma'] * 1e9,
                               result.refCat['a_fluxErr'])
        self.assertFloatsEqual(catalog['b_flux'] * 1e9,
                               result.refCat['b_flux'])
        self.assertFloatsEqual(catalog['b_fluxSigma'] * 1e9,
                               result.refCat['b_fluxErr'])
예제 #2
0
 def setUp(self):
     np.random.seed(12345)
     filenames = sorted(
         glob.glob(
             os.path.join(RefCatDir, 'ref_cats', 'cal_ref_cat',
                          '??????.fits')))
     self.refObjLoader = MockReferenceObjectLoaderFromFiles(filenames,
                                                            htmLevel=8)
     center = lsst.geom.SpherePoint(215.5, 53.0, lsst.geom.degrees)
     radius = 0.5 * lsst.geom.degrees
     self.filter = "r"
     self.references = self.refObjLoader.loadSkyCircle(
         center, radius, self.filter).refCat
예제 #3
0
    def setUp(self):

        # Load sample input from disk
        testDir = os.path.dirname(__file__)
        self.srcCat = afwTable.SourceCatalog.readFits(
            os.path.join(testDir, "data", "v695833-e0-c000.xy.fits"))

        self.srcCat["slot_ApFlux_instFluxErr"] = 1
        self.srcCat["slot_PsfFlux_instFluxErr"] = 1

        # The .xy.fits file has sources in the range ~ [0,2000],[0,4500]
        # which is bigger than the exposure
        self.bbox = geom.Box2I(geom.Point2I(0, 0), geom.Extent2I(2048, 4612))
        smallExposure = afwImage.ExposureF(
            os.path.join(testDir, "data", "v695833-e0-c000-a00.sci.fits"))
        self.exposure = afwImage.ExposureF(self.bbox)
        self.exposure.setWcs(smallExposure.getWcs())
        self.exposure.setFilter(
            afwImage.FilterLabel(band="i", physical="test-i"))
        self.exposure.setPhotoCalib(smallExposure.getPhotoCalib())

        coordKey = self.srcCat.getCoordKey()
        centroidKey = self.srcCat.getCentroidSlot().getMeasKey()
        wcs = self.exposure.getWcs()
        for src in self.srcCat:
            src.set(coordKey, wcs.pixelToSky(src.get(centroidKey)))

        # Make a reference loader
        filenames = sorted(
            glob.glob(
                os.path.join(RefCatDir, 'ref_cats', 'cal_ref_cat',
                             '??????.fits')))
        self.refObjLoader = MockReferenceObjectLoaderFromFiles(filenames,
                                                               htmLevel=8)
        self.log = logging.getLogger('lsst.testPhotoCal')
        self.log.setLevel(TRACE)

        self.config = PhotoCalConfig()
        self.config.match.matchRadius = 0.5
        self.config.match.referenceSelection.doMagLimit = True
        self.config.match.referenceSelection.magLimit.maximum = 22.0
        self.config.match.referenceSelection.magLimit.fluxField = "i_flux"
        self.config.match.referenceSelection.doFlags = True
        self.config.match.referenceSelection.flags.good = ['photometric']
        self.config.match.referenceSelection.flags.bad = ['resolved']
        self.config.match.sourceSelection.doUnresolved = False  # Don't have star/galaxy in the srcCat

        # The test and associated data have been prepared on the basis that we
        # use the PsfFlux to perform photometry.
        self.config.fluxField = "base_PsfFlux_instFlux"
예제 #4
0
    def setUp(self):
        refCatDir = os.path.join(os.path.dirname(__file__), "data",
                                 "sdssrefcat")

        self.bbox = lsst.geom.Box2I(lsst.geom.Point2I(0, 0),
                                    lsst.geom.Extent2I(3001, 3001))
        crpix = lsst.geom.Box2D(self.bbox).getCenter()
        self.tanWcs = afwGeom.makeSkyWcs(
            crpix=crpix,
            crval=lsst.geom.SpherePoint(215.5, 53.0, lsst.geom.degrees),
            cdMatrix=afwGeom.makeCdMatrix(scale=5.1e-5 * lsst.geom.degrees))
        self.exposure = afwImage.ExposureF(self.bbox)
        self.exposure.setWcs(self.tanWcs)
        self.exposure.setFilter(
            afwImage.FilterLabel(band="r", physical="rTest"))
        filenames = sorted(
            glob.glob(
                os.path.join(refCatDir, 'ref_cats', 'cal_ref_cat',
                             '??????.fits')))
        self.refObjLoader = MockReferenceObjectLoaderFromFiles(filenames,
                                                               htmLevel=8)
    def setUp(self):
        # Load sample input from disk
        testDir = os.path.dirname(__file__)

        self.srcSet = SourceCatalog.readFits(
            os.path.join(testDir, "v695833-e0-c000.xy.fits"))

        self.bbox = lsst.geom.Box2I(lsst.geom.Point2I(0, 0),
                                    lsst.geom.Extent2I(2048,
                                                       4612))  # approximate
        # create an exposure with the right metadata; the closest thing we have is
        # apparently v695833-e0-c000-a00.sci.fits, which is much too small
        smallExposure = ExposureF(
            os.path.join(testDir, "v695833-e0-c000-a00.sci.fits"))
        self.exposure = ExposureF(self.bbox)
        self.exposure.setWcs(smallExposure.getWcs())
        self.exposure.setFilter(smallExposure.getFilter())
        # copy the pixels we can, in case the user wants a debug display
        mi = self.exposure.getMaskedImage()
        mi.assign(smallExposure.getMaskedImage(), smallExposure.getBBox())

        logLevel = logging.INFO
        refCatDir = os.path.join(testDir, "data", "sdssrefcat")
        filenames = sorted(
            glob.glob(
                os.path.join(refCatDir, 'ref_cats', 'cal_ref_cat',
                             '??????.fits')))
        refObjLoader = MockReferenceObjectLoaderFromFiles(filenames,
                                                          htmLevel=8)
        astrometryConfig = AstrometryTask.ConfigClass()
        self.astrom = AstrometryTask(config=astrometryConfig,
                                     refObjLoader=refObjLoader)
        self.astrom.log.setLevel(logLevel)
        # Since our sourceSelector is a registry object we have to wait for it to be created
        # before setting default values.
        self.astrom.sourceSelector.config.minSnr = 0