コード例 #1
0
    def testCandidateList(self):
        self.assertFalse(self.cellSet.getCellList()[0].empty())
        self.assertTrue(self.cellSet.getCellList()[1].empty())
        self.assertFalse(self.cellSet.getCellList()[2].empty())
        self.assertTrue(self.cellSet.getCellList()[3].empty())

        stamps = []
        for cell in self.cellSet.getCellList():
            for cand in cell:
                #
                # Swig doesn't know that we inherited from SpatialCellMaskedImageCandidate;  all
                # it knows is that we have a SpatialCellCandidate, and SpatialCellCandidates
                # don't know about getMaskedImage;  so cast the pointer to SpatialCellMaskedImageCandidate<float>
                # and all will be well
                #
                cand = afwMath.cast_SpatialCellMaskedImageCandidateF(cell[0])
                width, height = 29, 25
                cand.setWidth(width); cand.setHeight(height);

                im = cand.getMaskedImage()
                stamps.append(im)

                self.assertEqual(im.getWidth(), width)
                self.assertEqual(im.getHeight(), height)

        if False and display:
            mos = displayUtils.Mosaic()
            mos.makeMosaic(stamps, frame=2)
コード例 #2
0
ファイル: psfIO.py プロジェクト: rpmunoz/meas_algorithms
    def testCandidateList(self):
        if False and display:
            ds9.mtv(self.mi)

            for cell in self.cellSet.getCellList():
                x0, y0, x1, y1 = (cell.getBBox().getX0(),
                                  cell.getBBox().getY0(),
                                  cell.getBBox().getX1(),
                                  cell.getBBox().getY1())
                print x0, y0, " ", x1, y1
                x0 -= 0.5
                y0 -= 0.5
                x1 += 0.5
                y1 += 0.5

                ds9.line([(x0, y0), (x1, y0), (x1, y1), (x0, y1), (x0, y0)],
                         ctype=ds9.RED)

        self.assertFalse(self.cellSet.getCellList()[0].empty())
        self.assertTrue(self.cellSet.getCellList()[1].empty())
        self.assertFalse(self.cellSet.getCellList()[2].empty())

        stamps = []
        for cell in self.cellSet.getCellList():
            for cand in cell:
                #
                # Swig doesn't know that we inherited from SpatialCellMaskedImageCandidate;  all
                # it knows is that we have a SpatialCellCandidate, and SpatialCellCandidates
                # don't know about getMaskedImage;  so cast the pointer to
                # SpatialCellMaskedImageCandidate<float> and all will be well
                #
                cand = afwMath.cast_SpatialCellMaskedImageCandidateF(cell[0])
                width, height = 15, 17
                cand.setWidth(width)
                cand.setHeight(height)

                im = cand.getMaskedImage()
                stamps.append(im)

                self.assertEqual(im.getWidth(), width)
                self.assertEqual(im.getHeight(), height)

        if display:
            mos = displayUtils.Mosaic()
            ds9.mtv(mos.makeMosaic(stamps), frame=1)
コード例 #3
0
ファイル: psfIO.py プロジェクト: rpmunoz/meas_algorithms
    def testCandidateList(self):
        if False and display:
            ds9.mtv(self.mi)

            for cell in self.cellSet.getCellList():
                x0, y0, x1, y1 = (
                    cell.getBBox().getX0(), cell.getBBox().getY0(),
                    cell.getBBox().getX1(), cell.getBBox().getY1())
                print x0, y0, " ", x1, y1
                x0 -= 0.5
                y0 -= 0.5
                x1 += 0.5
                y1 += 0.5

                ds9.line([(x0, y0), (x1, y0), (x1, y1), (x0, y1), (x0, y0)], ctype=ds9.RED)

        self.assertFalse(self.cellSet.getCellList()[0].empty())
        self.assertTrue(self.cellSet.getCellList()[1].empty())
        self.assertFalse(self.cellSet.getCellList()[2].empty())

        stamps = []
        for cell in self.cellSet.getCellList():
            for cand in cell:
                #
                # Swig doesn't know that we inherited from SpatialCellMaskedImageCandidate;  all
                # it knows is that we have a SpatialCellCandidate, and SpatialCellCandidates
                # don't know about getMaskedImage;  so cast the pointer to
                # SpatialCellMaskedImageCandidate<float> and all will be well
                #
                cand = afwMath.cast_SpatialCellMaskedImageCandidateF(cell[0])
                width, height = 15, 17
                cand.setWidth(width)
                cand.setHeight(height)

                im = cand.getMaskedImage()
                stamps.append(im)

                self.assertEqual(im.getWidth(), width)
                self.assertEqual(im.getHeight(), height)

        if display:
            mos = displayUtils.Mosaic()
            ds9.mtv(mos.makeMosaic(stamps), frame=1)
コード例 #4
0
    def testInsertCandidate(self):
        """Test that we can use SpatialCellMaskedImageCandidate"""

        flux = 10
        self.cellSet.insertCandidate(testLib.TestMaskedImageCandidate(0, 0, flux))

        cand = self.cellSet.getCellList()[0][0]
        #
        # Swig doesn't know that we're a SpatialCellMaskedImageCandidate;  all it knows is that we have
        # a SpatialCellCandidate, and SpatialCellCandidates don't know about getMaskedImage;  so cast the
        # pointer to SpatialCellMaskedImageCandidate<Image<float> > and all will be well;
        #

        cand = afwMath.cast_SpatialCellMaskedImageCandidateF(cand)

        width, height = 15, 21
        cand.setWidth(width)
        cand.setHeight(height)

        im = cand.getMaskedImage().getImage()
        self.assertEqual(im.get(0, 0), flux)  # This is how TestMaskedImageCandidate sets its pixels
        self.assertEqual(im.getWidth(), width)
        self.assertEqual(im.getHeight(), height)