Exemple #1
0
    def testTransformWcsPixels(self):
        filename = os.path.join(os.path.dirname(__file__),
                                'imgCharSources-v85501867-R01-S00.sipheader')
        wcs1 = lsst.afw.image.makeWcs(lsst.afw.image.readMetadata(filename))
        s = makeRandomAffineTransform()
        wcs2 = transformWcsPixels(wcs1, s)
        crval = wcs1.getSkyOrigin().getPosition(lsst.afw.geom.degrees)

        def t1a(p):
            sky = lsst.afw.coord.IcrsCoord(crval + lsst.afw.geom.Extent2D(p),
                                           lsst.afw.geom.degrees)
            return s(wcs1.skyToPixel(sky))

        def t2a(p):
            sky = lsst.afw.coord.IcrsCoord(crval + lsst.afw.geom.Extent2D(p),
                                           lsst.afw.geom.degrees)
            return wcs2.skyToPixel(sky)

        self.assertTransformsAlmostEqual(t1a, t2a)

        def t1b(p):
            sky = wcs1.pixelToSky(s.invert()(p))
            return sky.getPosition(lsst.afw.geom.degrees)

        def t2b(p):
            sky = wcs2.pixelToSky(p)
            return sky.getPosition(lsst.afw.geom.degrees)

        self.assertTransformsAlmostEqual(t1b, t2b)
    def testTransformWcsPixels(self):
        filename = os.path.join(os.path.dirname(__file__),
                                'imgCharSources-v85501867-R01-S00.sipheader')
        wcs1 = lsst.afw.geom.makeSkyWcs(readMetadata(filename))
        s = makeRandomAffineTransform()
        wcs2 = transformWcsPixels(wcs1, s)
        crvalDeg = wcs1.getSkyOrigin().getPosition(lsst.afw.geom.degrees)

        def t1a(p):
            raDeg, decDeg = crvalDeg + lsst.afw.geom.Extent2D(p)
            sky = lsst.afw.geom.SpherePoint(raDeg, decDeg, lsst.afw.geom.degrees)
            return s(wcs1.skyToPixel(sky))

        def t2a(p):
            raDeg, decDeg = crvalDeg + lsst.afw.geom.Extent2D(p)
            sky = lsst.afw.geom.SpherePoint(raDeg, decDeg, lsst.afw.geom.degrees)
            return wcs2.skyToPixel(sky)

        self.assertTransformsAlmostEqual(t1a, t2a)

        def t1b(p):
            sky = wcs1.pixelToSky(s.inverted()(p))
            return sky.getPosition(lsst.afw.geom.degrees)

        def t2b(p):
            sky = wcs2.pixelToSky(p)
            return sky.getPosition(lsst.afw.geom.degrees)

        self.assertTransformsAlmostEqual(t1b, t2b)