Exemple #1
0
    def test_SphMapBasics(self):
        sphmap = ast.SphMap()
        self.assertEqual(sphmap.className, "SphMap")
        self.assertEqual(sphmap.nIn, 3)
        self.assertEqual(sphmap.nOut, 2)
        self.assertEqual(sphmap.polarLong, 0)
        self.assertFalse(sphmap.unitRadius)

        self.checkCopy(sphmap)
        # SphMap followed by an inverse, simplified, is a compound map,
        # not a UnitMap, since data only round trips for unit vectors.
        # Hence the following test instead of checkBasicSimplify:
        simplified = sphmap.then(sphmap.inverted()).simplified()
        self.assertTrue(isinstance(simplified, ast.CmpMap))

        # for data to round trip, all inputs must be unit vectors
        indata = np.array([
            [1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0 / math.sqrt(3.0)],
            [0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 / math.sqrt(3.0)],
            [0.0, 0.0, 1.0, 0.0, 0.0, -1.0, 1.0 / math.sqrt(3.0)],
        ], dtype=float)
        halfpi = math.pi / 2.0
        pred_outdata = np.array([
            [0.0, halfpi, 0.0, math.pi, -halfpi, 0.0, math.pi / 4.0],
            [0.0, 0.0, halfpi, 0.0, 0.0, -halfpi, math.atan(1.0 / math.sqrt(2.0))],
        ], dtype=float)
        outdata = sphmap.applyForward(indata)
        assert_allclose(outdata, pred_outdata)

        self.checkRoundTrip(sphmap, indata)
        self.checkMappingPersistence(sphmap, indata)
Exemple #2
0
    def test_SphMapBasics(self):
        sphmap = astshim.SphMap()
        self.assertEqual(sphmap.className, "SphMap")
        self.assertEqual(sphmap.nIn, 3)
        self.assertEqual(sphmap.nOut, 2)
        self.assertEqual(sphmap.polarLong, 0)
        self.assertFalse(sphmap.unitRadius)

        self.checkCopy(sphmap)
        self.checkPersistence(sphmap)

        indata = np.array([
            [1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0 / math.sqrt(3.0)],
            [0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 / math.sqrt(3.0)],
            [0.0, 0.0, 1.0, 0.0, 0.0, -1.0, 1.0 / math.sqrt(3.0)],
        ],
                          dtype=float)
        halfpi = math.pi / 2.0
        pred_outdata = np.array([
            [0.0, halfpi, 0.0, math.pi, -halfpi, 0.0, math.pi / 4.0],
            [
                0.0, 0.0, halfpi, 0.0, 0.0, -halfpi,
                math.atan(1.0 / math.sqrt(2.0))
            ],
        ],
                                dtype=float)
        outdata = sphmap.applyForward(indata)
        assert_allclose(outdata, pred_outdata)

        self.checkRoundTrip(sphmap, indata)
Exemple #3
0
 def test_SphMapAttributes(self):
     sphmap = ast.SphMap("PolarLong=0.5, UnitRadius=1")
     self.assertEqual(sphmap.polarLong, 0.5)
     self.assertTrue(sphmap.unitRadius)