Пример #1
0
    def testCoordAliases(self):
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.ExtentI(), lsst.geom.ExtentI)
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.Extent2I(), lsst.geom.Extent2I)
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.Extent3I(), lsst.geom.Extent3I)

        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.ExtentD(), lsst.geom.ExtentD)
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.Extent2D(), lsst.geom.Extent2D)
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.Extent3D(), lsst.geom.Extent3D)

        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.PointI(), lsst.geom.PointI)
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.Point2I(), lsst.geom.Point2I)
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.Point3I(), lsst.geom.Point3I)

        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.PointD(), lsst.geom.PointD)
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.Point2D(), lsst.geom.Point2D)
        with self.assertWarns(FutureWarning):
            self.assertIsInstance(afwGeom.Point3D(), lsst.geom.Point3D)
Пример #2
0
    def initialWcs(self, matches, wcs):
        """Generate a guess Wcs from the astrometric matches

        We create a Wcs anchored at the center of the matches, with the scale
        of the input Wcs.  This is necessary because matching returns only
        matches with no estimated Wcs, and the input Wcs is a wild guess.
        We're using the best of each: positions from the matches, and scale
        from the input Wcs.
        """
        crpix = afwGeom.Extent2D(0, 0)
        crval = afwGeom.Extent3D(0, 0, 0)
        for mm in matches:
            crpix += afwGeom.Extent2D(mm.second.getCentroid())
            crval += afwGeom.Extent3D(mm.first.getCoord().toIcrs().getVector())
        crpix /= len(matches)
        crval /= len(matches)
        newWcs = afwImage.Wcs(
            afwCoord.IcrsCoord(afwGeom.Point3D(crval)).getPosition(),
            afwGeom.Point2D(crpix), wcs.getCDMatrix())
        return newWcs
Пример #3
0
 def setUp(self):
     x, y, z = 1, 1, 1
     self.data = afwGeom.Extent3D(x, y, z)
Пример #4
0
    def testConstructors(self):
        #test extent from extent 2-d
        e1 = geom.Extent2I(1, 2)
        e2 = geom.Extent2I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Extent2D(1.2, 3.4)
        e2 = geom.Extent2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Extent2I(1, 2)
        e2 = geom.Extent2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test extent from extent 3-d
        e1 = geom.Extent3I(1, 2, 3)
        e2 = geom.Extent3I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Extent3D(1.2, 3.4, 5.6)
        e2 = geom.Extent3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Extent3I(1, 2, 3)
        e2 = geom.Extent3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test extent from point 2-d
        e1 = geom.Point2I(1, 2)
        e2 = geom.Extent2I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point2D(1.2, 3.4)
        e2 = geom.Extent2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point2I(1, 2)
        e2 = geom.Extent2D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test extent from point 3-d
        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Extent3I(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point3D(1.2, 3.4, 5.6)
        e2 = geom.Extent3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Extent3D(e1)
        self.assertClose(tuple(e1), tuple(e2))

        #test invalid constructors
        try:
            e1 = geom.Extent2D(1.2, 3.4)
            e2 = geom.Extent2I(e1)
        except:
            pass
        else:
            self.fail("Should not allow conversion Extent2D to Extent2I")
        try:
            e1 = geom.Extent3D(1.2, 3.4, 5.6)
            e2 = geom.Extent3I(e1)
        except:
            pass
        else:
            self.fail("Should not allow conversion Extent3D to Extent3I")

        try:
            e1 = geom.Point2D(1.2, 3.4)
            e2 = geom.Extent2I(e1)
        except:
            pass
        else:
            self.fail("Should not allow conversion Point2D to Extent 2I")
        try:
            e1 = geom.Point3D(1.2, 3.4, 5.6)
            e2 = geom.Extent3I(e1)
        except:
            pass
        else:
            self.fail("Should not allow conversion Point3D to Extent3I")
Пример #5
0
    def testConstructors(self):
        # test extent from extent 2-d
        e1 = geom.Extent2I(1, 2)
        e2 = geom.Extent2I(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Extent2D(1.2, 3.4)
        e2 = geom.Extent2D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Extent2I(1, 2)
        e2 = geom.Extent2D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        # test extent from extent 3-d
        e1 = geom.Extent3I(1, 2, 3)
        e2 = geom.Extent3I(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Extent3D(1.2, 3.4, 5.6)
        e2 = geom.Extent3D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Extent3I(1, 2, 3)
        e2 = geom.Extent3D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        # test extent from point 2-d
        e1 = geom.Point2I(1, 2)
        e2 = geom.Extent2I(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Point2D(1.2, 3.4)
        e2 = geom.Extent2D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Point2I(1, 2)
        e2 = geom.Extent2D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        # test extent from point 3-d
        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Extent3I(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Point3D(1.2, 3.4, 5.6)
        e2 = geom.Extent3D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        e1 = geom.Point3I(1, 2, 3)
        e2 = geom.Extent3D(e1)
        self.assertAlmostEqual(tuple(e1), tuple(e2))

        # test invalid constructors
        e1 = geom.Extent2D(1.2, 3.4)
        with self.assertRaises(TypeError):
            e2 = geom.Extent2I(e1)

        e1 = geom.Extent3D(1.2, 3.4, 5.6)
        with self.assertRaises(TypeError):
            e2 = geom.Extent3I(e1)

        e1 = geom.Point2D(1.2, 3.4)
        with self.assertRaises(TypeError):
            e2 = geom.Extent2I(e1)

        e1 = geom.Point3D(1.2, 3.4, 5.6)
        with self.assertRaises(TypeError):
            e2 = geom.Extent3I(e1)