Example #1
0
    def testBasics(self):
        """Test basic functionality of Site
        """
        for long in (54.3, -134.5):
            for lat in (-23.4, 12.3):
                for elev in (2789, 6543):
                    site = coordConv.Site(long, lat, elev)
                    self.assertEqual(long, site.meanLong)
                    self.assertEqual(lat, site.meanLat)
                    self.assertEqual(elev, site.elev)
                    self.assertAlmostEqual(long, site.corrLong)
                    self.assertAlmostEqual(lat, site.corrLat)
                    site.setPoleWander(0, 0)
                    self.assertAlmostEqual(long, site.corrLong)
                    self.assertAlmostEqual(lat, site.corrLat)
                    for xArcsec in (-0.3, 0, 0.3):
                        x = xArcsec / 3600.0
                        for yArcsec in (-0.3, 0, 0.3):
                            y = yArcsec / 3600.0
                            site.setPoleWander(x, y)
                            # the following is an approximation given in the header of slaPolmo
                            approxCorrLong = long + (x * coordConv.cosd(long)
                                                     ) - (y *
                                                          coordConv.sind(long))
                            approxCorrLat = lat + (
                                ((x * coordConv.sind(long)) +
                                 (y * coordConv.cosd(long))) *
                                coordConv.tand(lat))
                            self.assertAlmostEqual(approxCorrLong,
                                                   site.corrLong, 3)
                            self.assertAlmostEqual(approxCorrLat, site.corrLat,
                                                   3)

                            siteCopy = coordConv.Site(site)
                            self.assertEqual(repr(site), repr(siteCopy))
def processOutput(outputVec):
    return (
        outputVec[0],
        sind(outputVec[1]),
        cosd(outputVec[2]),
        outputVec[2],
        sind(outputVec[3]),
        cosd(outputVec[3]),
    )
Example #3
0
    def testWrap(self):
        for wrap in (-1000, -10, -1, 0, 1, 10, 1000):
            for offset in (-360, -180, -90, 0, 90, 180, 270, 360):
                for epsMult in (-3, -2, -1, 0, 1, 2, 3):
                    ang = offset + (wrap * 360)
                    ang += ang * DoubleEpsilon * epsMult
                    sinAng = sind(ang)
                    cosAng = cosd(ang)
                    pvt = PVT(ang, ang, 35.0)  # pick anything for vel and time

                    posAng = wrapPos(ang)
                    self.assertGreaterEqual(posAng, 0.0)
                    self.assertLess(posAng, 360.0)
                    # prove that posAng and ang are the same angle
                    # sin and cos are a sanity check on wrapCtr
                    self.assertAlmostEqual(wrapCtr(posAng - ang), 0)
                    self.assertAlmostEqual(sind(posAng), sinAng)
                    self.assertAlmostEqual(cosd(posAng), cosAng)

                    posPvt = wrapPos(pvt)
                    self.assertEqual(posPvt.pos, posAng)
                    self.assertEqual(posPvt.vel, pvt.vel)
                    self.assertEqual(posPvt.t, pvt.t)

                    ctrAng = wrapCtr(ang)
                    self.assertGreaterEqual(ctrAng, -180.0)
                    self.assertLess(ctrAng, 180.0)
                    # prove that ctrAng and ang are the same angle
                    self.assertAlmostEqual(wrapCtr(ctrAng - ang), 0)
                    self.assertAlmostEqual(sind(ctrAng), sinAng)
                    self.assertAlmostEqual(cosd(ctrAng), cosAng)

                    ctrPvt = wrapCtr(pvt)
                    self.assertEqual(ctrPvt.pos, ctrAng)
                    self.assertEqual(ctrPvt.vel, pvt.vel)
                    self.assertEqual(ctrPvt.t, pvt.t)

                    for refAngBase in (-180, 0, 180, 360):
                        for refEpsMult in (-3, -2, -1, 0, 1, 2, 3):
                            refAng = refAngBase
                            refAng += refAng * refEpsMult * DoubleEpsilon
                            nearAng = wrapNear(ang, refAng)
                            self.assertGreaterEqual(nearAng - refAng, -180)
                            self.assertLess(nearAng - refAng, 180)
                            # prove that nearAng and ang are the same angle
                            self.assertAlmostEqual(wrapCtr(nearAng - ang), 0)
                            self.assertAlmostEqual(sind(nearAng), sinAng)
                            self.assertAlmostEqual(cosd(nearAng), cosAng)
    def testWrap(self):
        for wrap in (-1000, -10, -1, 0, 1, 10, 1000):
            for offset in (-360, -180, -90, 0, 90, 180, 270, 360):
                for epsMult in (-3, -2, -1, 0, 1, 2, 3):
                    ang = offset + (wrap * 360)
                    ang += ang * DoubleEpsilon * epsMult
                    sinAng = sind(ang)
                    cosAng = cosd(ang)
                    pvt = PVT(ang, ang, 35.0) # pick anything for vel and time

                    posAng = wrapPos(ang)
                    self.assertGreaterEqual(posAng, 0.0)
                    self.assertLess(posAng, 360.0)
                    # prove that posAng and ang are the same angle
                    # sin and cos are a sanity check on wrapCtr
                    self.assertAlmostEqual(wrapCtr(posAng - ang), 0)
                    self.assertAlmostEqual(sind(posAng), sinAng)
                    self.assertAlmostEqual(cosd(posAng), cosAng)

                    posPvt = wrapPos(pvt)
                    self.assertEqual(posPvt.pos, posAng)
                    self.assertEqual(posPvt.vel, pvt.vel)
                    self.assertEqual(posPvt.t, pvt.t)

                    ctrAng = wrapCtr(ang)
                    self.assertGreaterEqual(ctrAng, -180.0)
                    self.assertLess(ctrAng, 180.0)
                    # prove that ctrAng and ang are the same angle
                    self.assertAlmostEqual(wrapCtr(ctrAng - ang), 0)
                    self.assertAlmostEqual(sind(ctrAng), sinAng)
                    self.assertAlmostEqual(cosd(ctrAng), cosAng)

                    ctrPvt = wrapCtr(pvt)
                    self.assertEqual(ctrPvt.pos, ctrAng)
                    self.assertEqual(ctrPvt.vel, pvt.vel)
                    self.assertEqual(ctrPvt.t, pvt.t)
                    
                    for refAngBase in (-180, 0, 180, 360):
                        for refEpsMult in (-3, -2, -1, 0, 1, 2, 3):
                            refAng = refAngBase
                            refAng += refAng * refEpsMult * DoubleEpsilon
                            nearAng = wrapNear(ang, refAng)
                            self.assertGreaterEqual(nearAng - refAng, -180)
                            self.assertLess(nearAng - refAng, 180)
                            # prove that nearAng and ang are the same angle
                            self.assertAlmostEqual(wrapCtr(nearAng - ang), 0)
                            self.assertAlmostEqual(sind(nearAng), sinAng)
                            self.assertAlmostEqual(cosd(nearAng), cosAng)
    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)
Example #6
0
    def testOffsetSmall(self):
        """Test offset, angularSeparation and orientationTo for small offsets not too near the pole
        
        In this regime delta-long = dist along long / cos(lat) is a reasonable approximation
        but I have no simple way to compute toOrient, except if dist very small then toOrient = fromOrient
        """
        for fromPolarAng in (-40.0, 0.43, 36.7):
            cosPolarAng = cosd(fromPolarAng)
            for fromEquatAng in (0, 41.0):  # should not matter
                fromCoord = Coord(fromEquatAng, fromPolarAng)
                for fromOrient in (-90, -72, -45.0, -30, 0.01, 12.5, 31, 47,
                                   56, 68, 89):
                    cosFromOrient = cosd(fromOrient)
                    sinFromOrient = sind(fromOrient)
                    for dist in (0, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7,
                                 1e-5, 0.001, 0.01, 0.13):
                        predEquatAng = fromEquatAng + (dist * cosFromOrient /
                                                       cosPolarAng)
                        predPolarAng = fromPolarAng + (dist * sinFromOrient)

                        toCoord, toOrient = fromCoord.offset(fromOrient, dist)
                        atPole, toEquatAng, toPolarAng = toCoord.getSphPos()
                        if abs(dist) > 0.1:
                            places = 3
                        else:
                            places = 5
                        if abs(dist) < 0.0001:
                            orientPlaces = 4
                        else:
                            orientPlaces = 7
                        self.assertAlmostEqual(toEquatAng,
                                               predEquatAng,
                                               places=places)
                        self.assertAlmostEqual(toPolarAng,
                                               predPolarAng,
                                               places=places)
                        fromCoord = Coord(fromEquatAng, fromPolarAng)
                        toCoord = Coord(toEquatAng, toPolarAng)
                        self.assertAlmostEqual(
                            dist, fromCoord.angularSeparation(toCoord))
                        predFromOrient = fromCoord.orientationTo(toCoord)
                        if numpy.isfinite(predFromOrient):
                            self.assertAlmostEqual(fromOrient,
                                                   predFromOrient,
                                                   places=orientPlaces)
                            self.assertAlmostEqual(
                                toOrient,
                                wrapNear(
                                    180 + toCoord.orientationTo(fromCoord),
                                    toOrient),
                                places=orientPlaces)
                        else:
                            self.assertLess(dist, 1e-7)
                            self.assertAlmostEqual(fromEquatAng, toEquatAng)
                            self.assertAlmostEqual(fromPolarAng, toPolarAng)
                            self.assertAlmostEqual(fromOrient, toOrient)
 def testRightTriangle(self):
     """
     right triangle: B = 90, a and c vary but avoid poles
     tan C = tan c / sin a
     tan c = (tan a / sinA * sinb)
     with some tweaks to handle the other quadrants
     """
     ang_B = 90.0
     for side_aa in (1.0, 20.0, 45.0, 90, 110.0, 179.0):
         for side_cc in (1.0, 20.0, 45.0, 90.0, 110.0, 179.0):
             ang_A = atan2d(tand(side_aa), sind(side_cc))
             ang_C = atan2d(tand(side_cc), sind(side_aa))
             side_bb = atan2d(tand(side_aa), sind(ang_A) * cosd(side_cc))
             # these tweaks handle other quadrants; they're based on what works, so are somewhat suspect
             if side_bb < 0:
                 side_bb = -side_bb
             if ang_A < 0:
                 ang_A = 180.0 + ang_A
             if ang_C < 0:
                 ang_C = 180.0 + ang_C
             self.checkOne((side_aa, ang_B, side_cc),
                           (ang_A, side_bb, ang_C))
Example #8
0
 def testTrig(self):
     """Test degrees-based trig functions
     """
     for ang in (0, -1, 31.2, -235, 234324):
         angRad = ang * coordConv.RadPerDeg
         self.assertAlmostEqual(coordConv.sind(ang), math.sin(angRad))
         self.assertAlmostEqual(coordConv.cosd(ang), math.cos(angRad))
         self.assertAlmostEqual(coordConv.tand(ang), math.tan(angRad))
         self.assertAlmostEqual(coordConv.atand(ang) * coordConv.RadPerDeg, math.atan(ang))
         for ang2 in (0, 35, -364):
             self.assertAlmostEqual(coordConv.atan2d(ang, ang2) * coordConv.RadPerDeg, math.atan2(ang, ang2))
     
     for val in (-1, -0.34, 0, 0.67, 1):
         self.assertAlmostEqual(coordConv.asind(val) * coordConv.RadPerDeg, math.asin(val))
         self.assertAlmostEqual(coordConv.acosd(val) * coordConv.RadPerDeg, math.acos(val))
    def testOffsetSmall(self):
        """Test offset, angularSeparation and orientationTo for small offsets not too near the pole
        
        In this regime delta-long = dist along long / cos(lat) is a reasonable approximation
        but I have no simple way to compute toOrient, except if dist very small then toOrient = fromOrient
        """
        for fromPolarAng in (-40.0, 0.43, 36.7):
            cosPolarAng = cosd(fromPolarAng)
            for fromEquatAng in (0, 41.0): # should not matter
                fromCoord = Coord(fromEquatAng, fromPolarAng)
                for fromOrient in (-90, -72, -45.0, -30, 0.01, 12.5, 31, 47, 56, 68, 89):
                    cosFromOrient = cosd(fromOrient)
                    sinFromOrient = sind(fromOrient)
                    for dist in (0, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-5, 0.001, 0.01, 0.13):
                        predEquatAng = fromEquatAng + (dist * cosFromOrient / cosPolarAng)
                        predPolarAng = fromPolarAng + (dist * sinFromOrient)

                        toCoord, toOrient = fromCoord.offset(fromOrient, dist)
                        atPole, toEquatAng, toPolarAng = toCoord.getSphPos()
                        if abs(dist) > 0.1:
                            places = 3
                        else:
                            places = 5
                        if abs(dist) < 0.0001:
                            orientPlaces = 4
                        else:
                            orientPlaces = 7
                        self.assertAlmostEqual(toEquatAng, predEquatAng, places=places)
                        self.assertAlmostEqual(toPolarAng, predPolarAng, places=places)
                        fromCoord = Coord(fromEquatAng, fromPolarAng)
                        toCoord = Coord(toEquatAng, toPolarAng)
                        self.assertAlmostEqual(dist, fromCoord.angularSeparation(toCoord))
                        predFromOrient = fromCoord.orientationTo(toCoord)
                        if numpy.isfinite(predFromOrient):
                            self.assertAlmostEqual(fromOrient, predFromOrient, places=orientPlaces)
                            self.assertAlmostEqual(toOrient, wrapNear(180 + toCoord.orientationTo(fromCoord), toOrient), places=orientPlaces)
                        else:
                            self.assertLess(dist, 1e-7)
                            self.assertAlmostEqual(fromEquatAng, toEquatAng)
                            self.assertAlmostEqual(fromPolarAng, toPolarAng)
                            self.assertAlmostEqual(fromOrient, toOrient)
    def testBasics(self):
        """Check sph -> vec and back again for points not at the pole
        
        The round trip test relies on the fact that the internal representation of a coord is vector,
        so simply retrieving the sph info again suffices to test a round trip.
        
        Warning: the test of vector velocity is poor because the code is copied from the C++.
        However, two other tests will help:
        - Convert a coordinate system to itself with two different dates of observation
          and check that the expected amount of spatial motion occurs
        - Compare coordinate conversion results to the old TCC
        """
        for equatAng in (0, 71, -123.4):
            for polarAng in (0, -75, -89.999999, 89.999999):
                for parallax in (0, MinParallax / 0.9000001, MinParallax / 0.8999999, 5):
                    for equatPM in (4,): # (0, 4):
                        for polarPM in (-7,): # (0, -7):
                            for radVel in (0, -34):
                                coord = Coord(equatAng, polarAng, parallax, equatPM, polarPM, radVel)
                                self.assertFalse(coord.atPole())
                                self.assertEqual(coord.atInfinity(), parallax < MinParallax / 0.9)

                                # check vector position
                                vecPos = coord.getVecPos()
                                dist = coord.getDistance()
                                self.assertAlmostEqual(numpy.linalg.norm(vecPos), dist, 2)
                                predVecPos = (
                                    dist * cosd(polarAng) * cosd(equatAng),
                                    dist * cosd(polarAng) * sind(equatAng),
                                    dist * sind(polarAng),
                                )
                                self.assertTrue(numpy.allclose(predVecPos, vecPos))
                                
                                # check vector proper motion
                                vecPM = coord.getVecPM()
                                RadPerYear_per_ArcsecPerCentury = RadPerDeg / (ArcsecPerDeg * 100.0)
                                SecPerYear = SecPerDay * DaysPerYear
                                AUPerYear_per_KmPerSec = SecPerYear / KmPerAU

                                sinEquat = sind(equatAng)
                                cosEquat = cosd(equatAng)
                                sinPolar = sind(polarAng)
                                cosPolar = cosd(polarAng)

                                # change units of proper motion from arcsec/century to au/year
                                pmAUPerYear1 = equatPM * dist * RadPerYear_per_ArcsecPerCentury
                                pmAUPerYear2 = polarPM * dist * RadPerYear_per_ArcsecPerCentury

                                # change units of radial velocity from km/sec to au/year
                                radVelAUPerYear = radVel * AUPerYear_per_KmPerSec
                                
                                predVecPM = (
                                    - (pmAUPerYear2 * sinPolar * cosEquat) - (pmAUPerYear1 * cosPolar * sinEquat) + (radVelAUPerYear * cosPolar * cosEquat),
                                    - (pmAUPerYear2 * sinPolar * sinEquat) + (pmAUPerYear1 * cosPolar * cosEquat) + (radVelAUPerYear * cosPolar * sinEquat),
                                    + (pmAUPerYear2 * cosPolar)                                                   + (radVelAUPerYear * sinPolar),
                                )
                                self.assertTrue(numpy.allclose(predVecPM, vecPM))

                                # check round trip
                                atPole, destEquatAng, destPolarAng = coord.getSphPos()
                                self.assertAlmostEqual(wrapPos(equatAng), destEquatAng)
                                self.assertAlmostEqual(polarAng, destPolarAng)

                                destParallax = coord.getParallax()
                                predParallax = 0 if coord.atInfinity() else parallax
                                self.assertAlmostEqual(predParallax, destParallax)

                                atPole, destEquatPM, destPolarPM = coord.getPM()
                                self.assertAlmostEqual(equatPM, destEquatPM, 6)
                                self.assertAlmostEqual(polarPM, destPolarPM, 6)

                                destRadVel = coord.getRadVel()
                                self.assertAlmostEqual(radVel, destRadVel)
                                
                                coordCopy = Coord(coord)
                                self.assertEqual(repr(coord), repr(coordCopy))
Example #11
0
    def testBasics(self):
        """Check sph -> vec and back again for points not at the pole
        
        The round trip test relies on the fact that the internal representation of a coord is vector,
        so simply retrieving the sph info again suffices to test a round trip.
        
        Warning: the test of vector velocity is poor because the code is copied from the C++.
        However, two other tests will help:
        - Convert a coordinate system to itself with two different dates of observation
          and check that the expected amount of spatial motion occurs
        - Compare coordinate conversion results to the old TCC
        """
        for equatAng in (0, 71, -123.4):
            for polarAng in (0, -75, -89.999999, 89.999999):
                for parallax in (0, MinParallax / 0.9000001,
                                 MinParallax / 0.8999999, 5):
                    for equatPM in (4, ):  # (0, 4):
                        for polarPM in (-7, ):  # (0, -7):
                            for radVel in (0, -34):
                                coord = Coord(equatAng, polarAng, parallax,
                                              equatPM, polarPM, radVel)
                                self.assertFalse(coord.atPole())
                                self.assertEqual(coord.atInfinity(),
                                                 parallax < MinParallax / 0.9)

                                # check vector position
                                vecPos = coord.getVecPos()
                                dist = coord.getDistance()
                                self.assertAlmostEqual(
                                    numpy.linalg.norm(vecPos), dist, 2)
                                predVecPos = (
                                    dist * cosd(polarAng) * cosd(equatAng),
                                    dist * cosd(polarAng) * sind(equatAng),
                                    dist * sind(polarAng),
                                )
                                self.assertTrue(
                                    numpy.allclose(predVecPos, vecPos))

                                # check vector proper motion
                                vecPM = coord.getVecPM()
                                RadPerYear_per_ArcsecPerCentury = RadPerDeg / (
                                    ArcsecPerDeg * 100.0)
                                SecPerYear = SecPerDay * DaysPerYear
                                AUPerYear_per_KmPerSec = SecPerYear / KmPerAU

                                sinEquat = sind(equatAng)
                                cosEquat = cosd(equatAng)
                                sinPolar = sind(polarAng)
                                cosPolar = cosd(polarAng)

                                # change units of proper motion from arcsec/century to au/year
                                pmAUPerYear1 = equatPM * dist * RadPerYear_per_ArcsecPerCentury
                                pmAUPerYear2 = polarPM * dist * RadPerYear_per_ArcsecPerCentury

                                # change units of radial velocity from km/sec to au/year
                                radVelAUPerYear = radVel * AUPerYear_per_KmPerSec

                                predVecPM = (
                                    -(pmAUPerYear2 * sinPolar * cosEquat) -
                                    (pmAUPerYear1 * cosPolar * sinEquat) +
                                    (radVelAUPerYear * cosPolar * cosEquat),
                                    -(pmAUPerYear2 * sinPolar * sinEquat) +
                                    (pmAUPerYear1 * cosPolar * cosEquat) +
                                    (radVelAUPerYear * cosPolar * sinEquat),
                                    +(pmAUPerYear2 * cosPolar) +
                                    (radVelAUPerYear * sinPolar),
                                )
                                self.assertTrue(
                                    numpy.allclose(predVecPM, vecPM))

                                # check round trip
                                atPole, destEquatAng, destPolarAng = coord.getSphPos(
                                )
                                self.assertAlmostEqual(wrapPos(equatAng),
                                                       destEquatAng)
                                self.assertAlmostEqual(polarAng, destPolarAng)

                                destParallax = coord.getParallax()
                                predParallax = 0 if coord.atInfinity(
                                ) else parallax
                                self.assertAlmostEqual(predParallax,
                                                       destParallax)

                                atPole, destEquatPM, destPolarPM = coord.getPM(
                                )
                                self.assertAlmostEqual(equatPM, destEquatPM, 6)
                                self.assertAlmostEqual(polarPM, destPolarPM, 6)

                                destRadVel = coord.getRadVel()
                                self.assertAlmostEqual(radVel, destRadVel)

                                coordCopy = Coord(coord)
                                self.assertEqual(repr(coord), repr(coordCopy))
    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)