def testTwoPVTConstructors(self):
        """Test both two-PVT constructors:

        PVTCoord(equatPVT, polarPVT, tai, distPVT)
        PVTCoord(equatPVT, polarPVT, tai, distPVT, equatPM, polarPM, radVel, defOrient)
        """
        for equatAng in (0, 71, -123.4):
            for polarAng in (0, -75, -89.99, 89.99):
                for orient in (0, -45, 31.23):
                    sinOrient = coordConv.sind(orient)
                    cosOrient = coordConv.cosd(orient)
                    for vel in (0, 0.1, 0.23):
                        for tai in (500.5, 10001.3):
                            # coord0 = coordConv.Coord(equatAng, polarAng)
                            polarVel = vel * sinOrient
                            equatVel = vel * cosOrient / coordConv.cosd(polarAng)
                            equatPVT = coordConv.PVT(equatAng, equatVel, tai)
                            polarPVT = coordConv.PVT(polarAng, polarVel, tai)

                            pvtCoord = coordConv.PVTCoord(equatPVT, polarPVT)
                            self.assertAlmostEqual(pvtCoord.getTAI(), tai)
                            self.assertTrue(pvtCoord.isfinite())

                            gotEquatPVT = coordConv.PVT()
                            gotPolarPVT = coordConv.PVT()
                            pvtCoord.getSphPVT(gotEquatPVT, gotPolarPVT)
                            coordConv.assertPVTsAlmostEqual(equatPVT, gotEquatPVT, doWrap=True)
                            coordConv.assertPVTsAlmostEqual(polarPVT, gotPolarPVT, doWrap=False)

                            for parallax in (0, 0.012):
                                dist = coordConv.distanceFromParallax(parallax)
                                for distVel in (0, 10000):
                                    distPVT = coordConv.PVT(dist, distVel, tai)
                                    for equatPM in (0, 0.11):
                                        for polarPM in (0, -0.12):
                                            for radVel in (0, 0.13):
                                                pvtCoordPM = coordConv.PVTCoord(equatPVT, polarPVT, distPVT, equatPM, polarPM, radVel)
                                                self.assertAlmostEqual(pvtCoordPM.getTAI(), tai)
                                                self.assertTrue(pvtCoordPM.isfinite())

                                                gotEquatPVT = coordConv.PVT()
                                                gotPolarPVT = coordConv.PVT()
                                                pvtCoordPM.getSphPVT(gotEquatPVT, gotPolarPVT)
                                                coordConv.assertPVTsAlmostEqual(equatPVT, gotEquatPVT, doWrap=True)
                                                coordConv.assertPVTsAlmostEqual(polarPVT, gotPolarPVT, doWrap=False)

                                                coordToCheck = pvtCoordPM.getCoord()
                                                self.assertAlmostEqual(radVel, coordToCheck.getRadVel())
                                                atPole, checkEquatPM, checkPolarPM = coordToCheck.getPM()
                                                if not atPole:
                                                    self.assertAlmostEqual(equatPM, checkEquatPM)
                                                    self.assertAlmostEqual(polarPM, checkPolarPM)
                                                self.assertAlmostEqual(parallax, coordToCheck.getParallax())
                                                if parallax != 0:
                                                    self.assertAlmostEqual(dist, coordToCheck.getDistance(), places=5)
                                                    coordConv.assertPVTsAlmostEqual(distPVT, pvtCoordPM.getDistance(),
                                                        velPlaces = 5, posPlaces=5)
 def testDist(self):
     """Test distance
     """
     for parallax in (0, MinParallax / 0.899999999, MinParallax / 0.900000001, MinParallax, 1, 3.4, 75.3):
         adjParallax = max(parallax, MinParallax)
         predDist = distanceFromParallax(adjParallax)
         predAtInf = parallax < MinParallax / 0.9
         for coord in ( # test one with space motion, one without
             Coord(43, 23, parallax),
             Coord(-32, 89.99, parallax, 3, 5, 2),
         ):
             self.assertAlmostEqual(coord.getDistance(), predDist, 2)
             self.assertEqual(predAtInf, coord.atInfinity())
Exemple #3
0
 def testDist(self):
     """Test distance
     """
     for parallax in (0, MinParallax / 0.899999999,
                      MinParallax / 0.900000001, MinParallax, 1, 3.4, 75.3):
         adjParallax = max(parallax, MinParallax)
         predDist = distanceFromParallax(adjParallax)
         predAtInf = parallax < MinParallax / 0.9
         for coord in (  # test one with space motion, one without
                 Coord(43, 23, parallax),
                 Coord(-32, 89.99, parallax, 3, 5, 2),
         ):
             self.assertAlmostEqual(coord.getDistance(), predDist, 2)
             self.assertEqual(predAtInf, coord.atInfinity())
    def testTwoPVTConstructors(self):
        """Test both two-PVT constructors:

        PVTCoord(equatPVT, polarPVT, tai, distPVT)
        PVTCoord(equatPVT, polarPVT, tai, distPVT, equatPM, polarPM, radVel, defOrient)
        """
        for equatAng in (0, 71, -123.4):
            for polarAng in (0, -75, -89.99, 89.99):
                for orient in (0, -45, 31.23):
                    sinOrient = coordConv.sind(orient)
                    cosOrient = coordConv.cosd(orient)
                    for vel in (0, 0.1, 0.23):
                        for tai in (500.5, 10001.3):
                            # coord0 = coordConv.Coord(equatAng, polarAng)
                            polarVel = vel * sinOrient
                            equatVel = vel * cosOrient / coordConv.cosd(
                                polarAng)
                            equatPVT = coordConv.PVT(equatAng, equatVel, tai)
                            polarPVT = coordConv.PVT(polarAng, polarVel, tai)

                            pvtCoord = coordConv.PVTCoord(equatPVT, polarPVT)
                            self.assertAlmostEqual(pvtCoord.getTAI(), tai)
                            self.assertTrue(pvtCoord.isfinite())

                            gotEquatPVT = coordConv.PVT()
                            gotPolarPVT = coordConv.PVT()
                            pvtCoord.getSphPVT(gotEquatPVT, gotPolarPVT)
                            coordConv.assertPVTsAlmostEqual(equatPVT,
                                                            gotEquatPVT,
                                                            doWrap=True)
                            coordConv.assertPVTsAlmostEqual(polarPVT,
                                                            gotPolarPVT,
                                                            doWrap=False)

                            for parallax in (0, 0.012):
                                dist = coordConv.distanceFromParallax(parallax)
                                for distVel in (0, 10000):
                                    distPVT = coordConv.PVT(dist, distVel, tai)
                                    for equatPM in (0, 0.11):
                                        for polarPM in (0, -0.12):
                                            for radVel in (0, 0.13):
                                                pvtCoordPM = coordConv.PVTCoord(
                                                    equatPVT, polarPVT,
                                                    distPVT, equatPM, polarPM,
                                                    radVel)
                                                self.assertAlmostEqual(
                                                    pvtCoordPM.getTAI(), tai)
                                                self.assertTrue(
                                                    pvtCoordPM.isfinite())

                                                gotEquatPVT = coordConv.PVT()
                                                gotPolarPVT = coordConv.PVT()
                                                pvtCoordPM.getSphPVT(
                                                    gotEquatPVT, gotPolarPVT)
                                                coordConv.assertPVTsAlmostEqual(
                                                    equatPVT,
                                                    gotEquatPVT,
                                                    doWrap=True)
                                                coordConv.assertPVTsAlmostEqual(
                                                    polarPVT,
                                                    gotPolarPVT,
                                                    doWrap=False)

                                                coordToCheck = pvtCoordPM.getCoord(
                                                )
                                                self.assertAlmostEqual(
                                                    radVel,
                                                    coordToCheck.getRadVel())
                                                atPole, checkEquatPM, checkPolarPM = coordToCheck.getPM(
                                                )
                                                if not atPole:
                                                    self.assertAlmostEqual(
                                                        equatPM, checkEquatPM)
                                                    self.assertAlmostEqual(
                                                        polarPM, checkPolarPM)
                                                self.assertAlmostEqual(
                                                    parallax,
                                                    coordToCheck.getParallax())
                                                if parallax != 0:
                                                    self.assertAlmostEqual(
                                                        dist,
                                                        coordToCheck.
                                                        getDistance(),
                                                        places=5)
                                                    coordConv.assertPVTsAlmostEqual(
                                                        distPVT,
                                                        pvtCoordPM.getDistance(
                                                        ),
                                                        velPlaces=5,
                                                        posPlaces=5)