Esempio n. 1
0
 def testEterms(self):
     """tpm.eterms => return e-terms of aberration."""
     ep = [tpm.J2000, tpm.J1984]
     v6c = [tpm.V6C(x=-0.0000016181, y=-0.0000003411,
                    z=-0.0000001479),
            tpm.V6C(x=-0.0000016206, y=-0.0000003341,
                    z=-0.0000001449)]
     for i,e in enumerate(ep):
         v6 = tpm.eterms(e)
         self.verify(v6, v6c[i])
Esempio n. 2
0
    def testEcl2equ(self):
        """tpm.equ2ecl => FK5 Equatorial to Ecliptic."""
        v6 = tpm.V6C(x=0.5, y=0.173611298, z=0.848445117,
                xdot=-0.034000000, ydot=0.251873488,
                zdot=-0.872330067)
        
        v6 = tpm.equ2ecl(v6, tpm.d2r(23.7))

        self.verify(v6, tpm.V6C(x=0.5, y=0.499999997, z=0.707106774,
                                 xdot=-0.0340, ydot=-0.120, zdot=-0.9))
Esempio n. 3
0
 def testV6Dot(self):
     """V6C.dot(V6C) => dot product of two V6C vector withs."""
     t = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
     v6c = tpm.V6C(**t)
     t1 = dict(x=100.34,
               y=-0.230,
               z=0.0,
               xdot=-1234.5,
               ydot=-43.5,
               zdot=123.9)
     v6c1 = tpm.V6C(**t1)
     x = t['x'] * t1['x'] + t['y'] * t1['y'] + t['z'] * t1['z']
     self.assertEqual(v6c.dot(v6c1), x)
     self.assertEqual(v6c1.dot(v6c), x)
Esempio n. 4
0
 def testEvp(self):
     """tpm.evp => Barycentric and Heliocentric V6C."""
     # See pytpm/tests/c_tests/evp_test.c
     tdt = [tpm.J2000, tpm.J1984]
     v6b_c = [tpm.V6C(x=-0.184273673, y=0.884790492, z=0.383823230,
                    xdot=-0.017202342, ydot=-0.002904995, zdot=-0.001259484),
              tpm.V6C(x=-0.167332100, y=0.896946944, z=0.388718633,
                     xdot=-0.017240508, ydot=-0.002790623, zdot=-0.001209123)]
     v6h_c = [tpm.V6C(x=-0.177134378, y=0.887424942, z=0.384742891,
                      xdot=-0.017207714, ydot=-0.002898199, zdot=-0.001256438),
              tpm.V6C(x=-0.170373080, y=0.888493845, z=0.385246878,
                      xdot=-0.017232243, ydot=-0.002792198, zdot=-0.001210002)]
     for i,t in enumerate(tdt):
         v6b, v6h = tpm.evp(tpm.tdt2tdb(t))
         self.verify(v6b, v6b_c[i])
         self.verify(v6h, v6h_c[i])
Esempio n. 5
0
 def testV6Scale(self):
     """V6C.scale() => scale with a scalar."""
     t = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
     v6c = tpm.V6C(**t)
     v6c = v6c.scale(1.234)
     t1 = t.copy()
     for key in t1:
         t1[key] *= 1.234
     self.checkv6(v6c, t1)
Esempio n. 6
0
 def testV6Unit(self):
     """V6C.unit() =>  unit POS vector and scaled VEL vector."""
     t = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
     v6c = tpm.V6C(**t)
     v6c = v6c.unit()
     tm = (t['x']**2 + t['y']**2 + t['z']**2)**(0.5)
     t1 = t.copy()
     for key in t1:
         t1[key] *= 1 / tm
     self.checkv6(v6c, t1)
Esempio n. 7
0
 def testV6Add(self):
     """V6C.__add__ => V3C + V3C."""
     t1 = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
     t2 = dict(x=23.5,
               y=12.3,
               z=1234.5,
               xdot=-1.23,
               ydot=-123.4,
               zdot=100.0)
     tsum = dict(x=t1['x'] + t2['x'],
                 y=t1['y'] + t2['y'],
                 z=t1['z'] + t2['z'],
                 xdot=t1['xdot'] + t2['xdot'],
                 ydot=t1['ydot'] + t2['ydot'],
                 zdot=t1['zdot'] + t2['zdot'])
     v6c1 = tpm.V6C(**t1)
     v6c2 = tpm.V6C(**t2)
     v6csum = v6c1 + v6c2
     self.checkv6(v6csum, tsum)
Esempio n. 8
0
 def testV6Sub(self):
     """V6C.__sub__ => V6C - V6C."""
     t1 = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
     t2 = dict(x=23.5,
               y=12.3,
               z=1234.5,
               xdot=-1.23,
               ydot=-123.4,
               zdot=100.0)
     tdiff = dict(x=t1['x'] - t2['x'],
                  y=t1['y'] - t2['y'],
                  z=t1['z'] - t2['z'],
                  xdot=t1['xdot'] - t2['xdot'],
                  ydot=t1['ydot'] - t2['ydot'],
                  zdot=t1['zdot'] - t2['zdot'])
     v6c1 = tpm.V6C(**t1)
     v6c2 = tpm.V6C(**t2)
     v6cdiff = v6c1 - v6c2
     self.checkv6(v6cdiff, tdiff)
Esempio n. 9
0
    def testaberrate(self):
        """tpm.aberrate => aberrate function."""
        v61 = tpm.V6C(x=1.0,y=2.0,z=3.0)
        v62 = tpm.V6C(xdot=-0.5,ydot=-0.6,zdot=-0.00345)

        v6 = tpm.aberrate(v61, v62, 1)
        self.assertAlmostEqual(v6.x, 0.989194995, 8)
        self.assertAlmostEqual(v6.y, 1.987033994, 8)
        self.assertAlmostEqual(v6.z, 2.999925445, 8)
        self.assertAlmostEqual(v6.xdot, 0.0)
        self.assertAlmostEqual(v6.ydot, 0.0)
        self.assertAlmostEqual(v6.zdot, 0.0)

        v6 = tpm.aberrate(v61, v62, -1)
        self.assertAlmostEqual(v6.x, 1.010805005, 8)
        self.assertAlmostEqual(v6.y, 2.012966006, 8)
        self.assertAlmostEqual(v6.z, 3.000074555, 8)
        self.assertAlmostEqual(v6.xdot, 0.0)
        self.assertAlmostEqual(v6.ydot, 0.0)
        self.assertAlmostEqual(v6.zdot, 0.0)
Esempio n. 10
0
 def testV62V3(self):
     """V6C.v62v3() => apply space motion and return resulting V3CP."""
     t = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
     v6c = tpm.V6C(**t)
     dt = 1200.345
     v3cp = v6c.v62v3(dt)
     self.assertEqual(v3cp.ctype, tpm.CARTESIAN)
     self.assertEqual(v3cp.vtype, tpm.POS)
     self.assertAlmostEqual(v3cp.x, t['x'] + t['xdot'] * dt)
     self.assertAlmostEqual(v3cp.y, t['y'] + t['ydot'] * dt)
     self.assertAlmostEqual(v3cp.z, t['z'] + t['zdot'] * dt)
Esempio n. 11
0
 def testV6SetPOS(self):
     """V6C.pos = V3CP => set POS components of V6C, using V3CP."""
     t = dict(x=1123.4556, y=4556.1123, z=9876.1267)
     v3cp = tpm.V3CP(**t)
     v6cp = tpm.V6C()
     v6cp.pos = v3cp
     self.assertAlmostEqual(v6cp.x, t['x'])
     self.assertAlmostEqual(v6cp.x, v3cp.x)
     self.assertAlmostEqual(v6cp.y, t['y'])
     self.assertAlmostEqual(v6cp.y, v3cp.y)
     self.assertAlmostEqual(v6cp.z, t['z'])
     self.assertAlmostEqual(v6cp.z, v3cp.z)
Esempio n. 12
0
    def testEcl2equ(self):
        """tpm.ecl2equ => Ecliptic to FK5 equatorial."""
        v6 = tpm.V6S(r=1.0,alpha=tpm.M_PI/4.0,delta=tpm.M_PI/4.0)
        v6 = v6.s2c()
        v6.xdot = -0.034
        v6.ydot = -0.12
        v6.zdot = -0.9

        v6 = tpm.ecl2equ(v6, tpm.d2r(23.7))

        self.verify(v6, tpm.V6C(x=0.5, y=0.173611298, z=0.848445117,
                                xdot=-0.034000000, ydot=0.251873488,
                                zdot=-0.872330067))
Esempio n. 13
0
    def testGetSet(self):
        """PVEC[X] = V6C => assign a V6C to a position in PVEC."""
        pvec = tpm.PVEC()
        t = dict(x=100.0, y=234.156, z=346.5,
                 xdot=-12.3, ydot=0.2, zdot=-9.4)
        pvec[tpm.TPM_S06] = tpm.V6C(**t)
        self.checkpvec(pvec, tpm.TPM_S06, t)

        self.assertRaises(IndexError, lambda x: x[34], pvec)
        self.assertRaises(IndexError, lambda x: x[-4], pvec)

        def f(pvec):
            pvec[tpm.TPM_S03] = tpm.V6S()
        self.assertRaises(TypeError, f, pvec)
Esempio n. 14
0
    def testV6Cross(self):
        """V6C.cross(V6C) => cross product V6C vectors."""
        t1 = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
        v6c = tpm.V6C(**t1)
        t2 = dict(x=100.34,
                  y=-0.230,
                  z=0.0,
                  xdot=-1234.5,
                  ydot=-43.5,
                  zdot=123.9)
        v6c1 = tpm.V6C(**t2)
        t = dict(x=t1['y'] * t2['z'] - t1['z'] * t2['y'],
                 y=t1['z'] * t2['x'] - t1['x'] * t2['z'],
                 z=t1['x'] * t2['y'] - t1['y'] * t2['x'],
                 xdot=0.0,
                 ydot=0.0,
                 zdot=0.0)

        self.checkv6(v6c.cross(v6c1), t)
        self.checkv6(
            v6c1.cross(v6c),
            dict(x=-t['x'], y=-t['y'], z=-t['z'], xdot=0.0, ydot=0.0,
                 zdot=0.0))
Esempio n. 15
0
 def testV6GetPOS(self):
     """V6C.pos => POS components of V6C, as V3CP."""
     t = dict(x=1123.4556,
              y=4556.1123,
              z=9876.1267,
              xdot=2.3456,
              ydot=6.7891,
              zdot=7.8912)
     v6c = tpm.V6C(**t)
     v6pos = v6c.pos
     self.assertEqual(v6pos.vtype, tpm.POS)
     self.assertEqual(v6pos.ctype, tpm.CARTESIAN)
     self.assertAlmostEqual(v6pos.x, t['x'])
     self.assertAlmostEqual(v6pos.y, t['y'])
     self.assertAlmostEqual(v6pos.z, t['z'])
Esempio n. 16
0
    def testCreate(self):
        """V6C() => creat a V6C class."""
        v6c = tpm.V6C()
        self.assertEqual(type(v6c), tpm.V6C)

        # Access default init values.
        self.assertAlmostEqual(v6c.ctype, tpm.CARTESIAN)
        self.assertAlmostEqual(v6c.x, 0.0)
        self.assertAlmostEqual(v6c.y, 0.0)
        self.assertAlmostEqual(v6c.z, 0.0)
        self.assertAlmostEqual(v6c.xdot, 0.0)
        self.assertAlmostEqual(v6c.ydot, 0.0)
        self.assertAlmostEqual(v6c.zdot, 0.0)

        # ctype is read only.
        def f(x):
            x.ctype = tpm.SPHERICAL

        self.assertRaises(AttributeError, f, v6c)
Esempio n. 17
0
 def testV6C2S(self):
     """V6C.c2s() => V6C to V6S i.e., Cartesian to spherical."""
     t = dict(x=1123.4556,
              y=4556.1123,
              z=9876.1267,
              xdot=2.3456,
              ydot=6.7891,
              zdot=7.8912)
     tn = dict(r=10934.26679617,
               alpha=1.32903712,
               delta=1.12723066,
               rdot=10.19744374,
               alphadot=-0.00013894,
               deltadot=-0.00028117)
     v6c = tpm.V6C(**t)
     v6s = v6c.c2s()
     self.assertEqual(v6s.ctype, tpm.SPHERICAL)
     self.assertAlmostEqual(v6s.r, tn['r'])
     self.assertAlmostEqual(v6s.alpha, tn['alpha'])
     self.assertAlmostEqual(v6s.delta, tn['delta'])
     self.assertAlmostEqual(v6s.rdot, tn['rdot'])
     self.assertAlmostEqual(v6s.alphadot, tn['alphadot'])
     self.assertAlmostEqual(v6s.deltadot, tn['deltadot'])
Esempio n. 18
0
 def testV6Mod(self):
     """V6C.mod() => modulus/length of a V6C vector."""
     t = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
     v6c = tpm.V6C(**t)
     tm = (t['x']**2 + t['y']**2 + t['z']**2)**(0.5)
     self.assertAlmostEqual(v6c.mod(), tm)
Esempio n. 19
0
 def testGeod2geoc(self):
     """tpm.geod2geoc => Geodetic to geocentric."""
     v6 = tpm.geod2geoc(tpm.d2r(30.567), tpm.d2r(46.713), 1500.0)
     self.verify(v6,tpm.V6C(x=3773051.892626300,y=2228444.491846553,
                           z=4621039.023174386,xdot=-162.500738326,
                           ydot=275.135288555,zdot=0.0))
Esempio n. 20
0
 def testSetGetInitValues(self):
     """V6C(**vals) => set fields at init."""
     t = dict(x=-12.34, y=21345.0, z=0.01, xdot=1.23, ydot=3.21, zdot=0.0)
     v6c = tpm.V6C(**t)
     self.checkv6(v6c, t)