Exemplo n.º 1
0
    def testpm(self):
        """Proper motion => apply PM to position."""
        import math
        ra = tpm.d2r(269.45402305)
        de = tpm.d2r(4.66828815)
        px = 549.01 / 1000.0 # To Arc seconds
        rv = 0.0
        # pmra * cos(de) into pmra
        pmra = (-797.84 / 1000.0 ) / math.cos(de) 
        pmra *= 100.0 # To Arcseconds per century.
        pmde = (10326.93 / 1000.0) 
        pmde *= 100.0 # To Arcseconds per century.
        C = tpm.CJ

        v6 = tpm.cat2v6(ra, de, pmra, pmde, px, rv, C)
        
        v6 = tpm.proper_motion(v6, tpm.J2000, tpm.jyear2jd(1991.25))
        v6 = v6.c2s()
        hms = tpm.HMS(r=v6.alpha)
        dms = tpm.DMS(r=v6.delta)
        hms.normalize()
        dms.normalize() 

        self.assertAlmostEqual(hms.hh, -7.0)
        self.assertAlmostEqual(hms.mm, 57.0)
        self.assertAlmostEqual(hms.ss, 48.4986, 3)
        self.assertAlmostEqual(dms.dd, 4.0)
        self.assertAlmostEqual(dms.mm, 41.0)
        self.assertAlmostEqual(dms.ss, 36.1980, 3)
Exemplo n.º 2
0
    def testv62cat(self):
        """v62cat => Cartesian to catalog; testing cat2v6 <-> v62cat."""
        # See pytpm/tests/c_tests/cat2v6_v62cat_test.c.
        # Barnard's star from Hipparcos catalog.
        # ICRS Epoch J1991.25
        import math

        alpha = tpm.d2r(269.45402305)
        delta = tpm.d2r(4.66828815)
        px = 549.01 / 1000.0  # To Arc seconds
        rv = 0.0
        # pmra * cos(de) into pmra
        pma = (-797.84 / 1000.0) / math.cos(delta)
        pma *= 100.0  # To Arcseconds per century.
        pmd = 10326.93 / 1000.0
        pmd *= 100.0  # To Arcseconds per century.
        C = tpm.CJ

        v6 = tpm.cat2v6(alpha, delta, pma, pmd, px, rv, C)

        p = tpm.v62cat(v6, C)

        self.assertAlmostEqual(tpm.r2r(p["alpha"]), alpha)
        self.assertAlmostEqual(p["delta"], delta)
        self.assertAlmostEqual(p["pma"], pma)
        self.assertAlmostEqual(p["pmd"], pmd)
        self.assertAlmostEqual(p["px"], px)
        self.assertAlmostEqual(p["rv"], rv)
Exemplo n.º 3
0
    def test_slalib_hip_galeq(self):
        """convertv6(x,s1=4,s=6) + PM <=> SLALIB galeq HIP"""
        v6l = []
        for r, d in zip(self.hip_tab['glon'], self.hip_tab['glat']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        # The epoch of galactic data is J2000. But in SLALIB
        # the input is taken to be B1950.0. I can't apply proper_motion
        # from J2000 to B1950 before input to SLALIB since, I don't
        # have galactic velocities. In essence, the SLALIB input has a
        # proper_motion for the period B1950 to J2000, which is also
        # present in the output. By setting
        # epoch=tpm.B1950 PyTPM will return FK5 values at eq. J2000
        # but at epoch B1950, which should match the results from
        # SLALIB. The velocities for this conversion show up during
        # FK4-FK5 frame conversion.
        v6o = convert.convertv6(v6l, s1=4, s2=6, epoch=tpm.B1950)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        tab = get_sla("slalib_hip_galeq.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.001 )
            self.assertTrue(dec_diff <= 0.001 )
Exemplo n.º 4
0
    def test_slalib_hip_eqgal(self):
        """convertv6(x,s1=6,s=4) + PM <=> SLALIB eqgal HIP"""
        v6l = []
        for r, d in zip(self.hip_tab['raj2'], self.hip_tab['decj2']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        v6o = convert.convertv6(v6l, s1=6, s2=4)
        # The galactic coordinates are at epoch J2000. But SLALIB
        # results are for B1950. So apply proper motion here.
        v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        tab = get_sla("slalib_hip_eqgal.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.001 )
            self.assertTrue(dec_diff <= 0.001 )
Exemplo n.º 5
0
    def test_slalib_hip_galeq(self):
        """convertv6(x,s1=4,s=6) + PM <=> SLALIB galeq HIP"""
        v6l = []
        for r, d in zip(self.hip_tab['glon'], self.hip_tab['glat']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        # The epoch of galactic data is J2000. But in SLALIB
        # the input is taken to be B1950.0. I can't apply proper_motion
        # from J2000 to B1950 before input to SLALIB since, I don't
        # have galactic velocities. In essence, the SLALIB input has a
        # proper_motion for the period B1950 to J2000, which is also
        # present in the output. By setting
        # epoch=tpm.B1950 PyTPM will return FK5 values at eq. J2000
        # but at epoch B1950, which should match the results from
        # SLALIB. The velocities for this conversion show up during
        # FK4-FK5 frame conversion.
        v6o = convert.convertv6(v6l, s1=4, s2=6, epoch=tpm.B1950)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        tab = get_sla("slalib_hip_galeq.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)
Exemplo n.º 6
0
 def testEqu2gal(self):
     """tpm.equ2gal => convert Galactic to FK4 equatorial."""
     v6 = tpm.V6S(r=1e9,alpha=tpm.d2r(120.0), delta=tpm.d2r(90.0))
     v6 = v6.s2c()
     v6 = tpm.gal2equ(v6)
     self.verify(v6.c2s(), tpm.V6S(r=1e9, alpha=tpm.d2r(192.25),
                                   delta=tpm.d2r(27.4))) 
Exemplo n.º 7
0
    def testProperMotion(self):
        """Convert.proper_motion: multiple V6C values."""
        ra = tpm.d2r(269.45402305)
        de = tpm.d2r(4.66828815)
        px = 549.01 / 1000.0  # To Arc seconds
        rv = 0.0
        # pmra * cos(de) into pmra
        pmra = (-797.84 / 1000.0) / math.cos(de)
        pmra *= 100.0  # To Arcseconds per century.
        pmde = (10326.93 / 1000.0)
        pmde *= 100.0  # To Arcseconds per century.
        C = tpm.CJ

        v6 = tpm.cat2v6(ra, de, pmra, pmde, px, rv, C)

        v6_out = convert.proper_motion([v6, v6], tpm.J2000,
                                       tpm.jyear2jd(1991.25))

        for i in v6_out:
            v6 = i.c2s()
            hms = tpm.HMS(r=v6.alpha)
            dms = tpm.DMS(r=v6.delta)
            hms.normalize()
            dms.normalize()

            self.assertAlmostEqual(hms.hh, -7.0)
            self.assertAlmostEqual(hms.mm, 57.0)
            self.assertAlmostEqual(hms.ss, 48.4986, 3)
            self.assertAlmostEqual(dms.dd, 4.0)
            self.assertAlmostEqual(dms.mm, 41.0)
            self.assertAlmostEqual(dms.ss, 36.1980, 3)
Exemplo n.º 8
0
    def testcat2v6(self):
        """cat2v6 => catalog to Cartesian."""
        # See pytpm/tests/c_tests/cat2v6_v62cat_test.c.
        # Barnard's star from Hipparcos catalog.
        # ICRS Epoch J1991.25
        import math

        alpha = tpm.d2r(269.45402305)
        delta = tpm.d2r(4.66828815)
        px = 549.01 / 1000.0  # To Arc seconds
        rv = 0.0
        # pmra * cos(de) into pmra
        pma = (-797.84 / 1000.0) / math.cos(delta)
        pma *= 100.0  # To Arcseconds per century.
        pmd = 10326.93 / 1000.0
        pmd *= 100.0  # To Arcseconds per century.
        C = tpm.CJ

        v6 = tpm.cat2v6(alpha, delta, pma, pmd, px, rv, C)

        self.assertAlmostEqual(v6.x, -3568.1807935995)
        self.assertAlmostEqual(v6.y, -374439.8219691383)
        self.assertAlmostEqual(v6.z, 30577.3105202634)
        self.assertAlmostEqual(v6.xdot, -0.0039386179)
        self.assertAlmostEqual(v6.ydot, 0.0042290848)
        self.assertAlmostEqual(v6.zdot, 0.0513283878)
Exemplo n.º 9
0
    def test_slalib_nwdfs_fk54z(self):
        """convertv6(x,s1=6,s=5) + PM <=> SLALIB FK5-FK4 (fk54z) NDWFS"""
        v6l = []
        for r, d in zip(self.ndwfs_tab['raj2'], self.ndwfs_tab['decj2']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        v6o = convert.convertv6(v6l, s1=6, s2=5)
        v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000)
        cat = (tpm.v62cat(v, tpm.CB) for v in v6o)

        tab = get_sla("slalib_ndwfs_fk54z.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])
            # arcsec/cent to milli-arcsec/year.
            pma = v['pma'] * 1000.0 / 100.0
            pmd = v['pmd'] * 1000.0 / 100.0

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            pma_diff = abs(pma - s[2])
            pmd_diff = abs(pmd - s[3])
            self.assertTrue(ra_diff <= 0.0001)
            self.assertTrue(dec_diff <= 0.0001)
            self.assertTrue(pma_diff <= 1)
            self.assertTrue(pmd_diff <= 1)
Exemplo n.º 10
0
    def testcat2v6(self):
        """cat2v6 => catalog to Cartesian."""
        # See pytpm/tests/c_tests/cat2v6_v62cat_test.c.
        # Barnard's star from Hipparcos catalog. 
        # ICRS Epoch J1991.25
        import math
        alpha = tpm.d2r(269.45402305)
        delta = tpm.d2r(4.66828815)
        px = 549.01 / 1000.0 # To Arc seconds
        rv = 0.0
        # pmra * cos(de) into pmra
        pma = (-797.84 / 1000.0 ) / math.cos(delta) 
        pma *= 100.0 # To Arcseconds per century.
        pmd = (10326.93 / 1000.0) 
        pmd *= 100.0 # To Arcseconds per century.
        C = tpm.CJ

        v6 = tpm.cat2v6(alpha, delta, pma, pmd, px, rv, C)

        self.assertAlmostEqual(v6.x, -3568.1807935995)
        self.assertAlmostEqual(v6.y, -374439.8219691383)
        self.assertAlmostEqual(v6.z, 30577.3105202634)
        self.assertAlmostEqual(v6.xdot, -0.0039386179)
        self.assertAlmostEqual(v6.ydot, 0.0042290848)
        self.assertAlmostEqual(v6.zdot, 0.0513283878)
Exemplo n.º 11
0
    def testProperMotion(self):
        """Convert.proper_motion: multiple V6C values."""
        ra = tpm.d2r(269.45402305)
        de = tpm.d2r(4.66828815)
        px = 549.01 / 1000.0  # To Arc seconds
        rv = 0.0
        # pmra * cos(de) into pmra
        pmra = (-797.84 / 1000.0) / math.cos(de)
        pmra *= 100.0  # To Arcseconds per century.
        pmde = 10326.93 / 1000.0
        pmde *= 100.0  # To Arcseconds per century.
        C = tpm.CJ

        v6 = tpm.cat2v6(ra, de, pmra, pmde, px, rv, C)

        v6_out = convert.proper_motion([v6, v6], tpm.J2000, tpm.jyear2jd(1991.25))

        for i in v6_out:
            v6 = i.c2s()
            hms = tpm.HMS(r=v6.alpha)
            dms = tpm.DMS(r=v6.delta)
            hms.normalize()
            dms.normalize()

            self.assertAlmostEqual(hms.hh, -7.0)
            self.assertAlmostEqual(hms.mm, 57.0)
            self.assertAlmostEqual(hms.ss, 48.4986, 3)
            self.assertAlmostEqual(dms.dd, 4.0)
            self.assertAlmostEqual(dms.mm, 41.0)
            self.assertAlmostEqual(dms.ss, 36.1980, 3)
Exemplo n.º 12
0
 def testEqu2gal(self):
     """tpm.equ2gal => convert FK4 equatorial to Galactic."""
     v6 = tpm.V6S(r=1e9, alpha=tpm.d2r(192.25), delta=tpm.d2r(27.4))
     v6 = v6.s2c()
     v6 = tpm.equ2gal(v6)
     v6 = v6.c2s()
     self.verify(v6, tpm.V6S(r=1e9, alpha=tpm.d2r(120.866), delta=tpm.d2r(90.0)))
Exemplo n.º 13
0
    def testpm(self):
        """Proper motion => apply PM to position."""
        import math

        ra = tpm.d2r(269.45402305)
        de = tpm.d2r(4.66828815)
        px = 549.01 / 1000.0  # To Arc seconds
        rv = 0.0
        # pmra * cos(de) into pmra
        pmra = (-797.84 / 1000.0) / math.cos(de)
        pmra *= 100.0  # To Arcseconds per century.
        pmde = 10326.93 / 1000.0
        pmde *= 100.0  # To Arcseconds per century.
        C = tpm.CJ

        v6 = tpm.cat2v6(ra, de, pmra, pmde, px, rv, C)

        v6 = tpm.proper_motion(v6, tpm.J2000, tpm.jyear2jd(1991.25))
        v6 = v6.c2s()
        hms = tpm.HMS(r=v6.alpha)
        dms = tpm.DMS(r=v6.delta)
        hms.normalize()
        dms.normalize()

        self.assertAlmostEqual(hms.hh, -7.0)
        self.assertAlmostEqual(hms.mm, 57.0)
        self.assertAlmostEqual(hms.ss, 48.4986, 3)
        self.assertAlmostEqual(dms.dd, 4.0)
        self.assertAlmostEqual(dms.mm, 41.0)
        self.assertAlmostEqual(dms.ss, 36.1980, 3)
Exemplo n.º 14
0
    def test_slalib_nwdfs_fk54z(self):
        """convertv6(x,s1=6,s=5) + PM <=> SLALIB FK5-FK4 (fk54z) NDWFS"""
        v6l = []
        for r, d in zip(self.ndwfs_tab['raj2'], self.ndwfs_tab['decj2']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        v6o = convert.convertv6(v6l, s1=6, s2=5)
        v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000)
        cat = (tpm.v62cat(v, tpm.CB) for v in v6o)

        tab = get_sla("slalib_ndwfs_fk54z.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])
            # arcsec/cent to milli-arcsec/year.
            pma = v['pma'] * 1000.0 / 100.0
            pmd = v['pmd'] * 1000.0 / 100.0

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            pma_diff = abs(pma - s[2])
            pmd_diff = abs(pmd - s[3])
            self.assertTrue(ra_diff <= 0.0001 )
            self.assertTrue(dec_diff <= 0.0001)
            self.assertTrue(pma_diff <= 1)
            self.assertTrue(pmd_diff <= 1)
Exemplo n.º 15
0
    def testv62cat(self):
        """v62cat => Cartesian to catalog; testing cat2v6 <-> v62cat."""
                # See pytpm/tests/c_tests/cat2v6_v62cat_test.c.
        # Barnard's star from Hipparcos catalog. 
        # ICRS Epoch J1991.25
        import math
        alpha = tpm.d2r(269.45402305)
        delta = tpm.d2r(4.66828815)
        px = 549.01 / 1000.0 # To Arc seconds
        rv = 0.0
        # pmra * cos(de) into pmra
        pma = (-797.84 / 1000.0 ) / math.cos(delta) 
        pma *= 100.0 # To Arcseconds per century.
        pmd = (10326.93 / 1000.0) 
        pmd *= 100.0 # To Arcseconds per century.
        C = tpm.CJ

        v6 = tpm.cat2v6(alpha, delta, pma, pmd, px, rv, C)
        
        p = tpm.v62cat(v6, C)

        self.assertAlmostEqual(tpm.r2r(p['alpha']), alpha)
        self.assertAlmostEqual(p['delta'], delta)
        self.assertAlmostEqual(p['pma'], pma)
        self.assertAlmostEqual(p['pmd'], pmd)
        self.assertAlmostEqual(p['px'], px)
        self.assertAlmostEqual(p['rv'], rv)
Exemplo n.º 16
0
    def test_slalib_hip_eqgal(self):
        """convertv6(x,s1=6,s=4) + PM <=> SLALIB eqgal HIP"""
        v6l = []
        for r, d in zip(self.hip_tab['raj2'], self.hip_tab['decj2']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        v6o = convert.convertv6(v6l, s1=6, s2=4)
        # The galactic coordinates are at epoch J2000. But SLALIB
        # results are for B1950. So apply proper motion here.
        v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        tab = get_sla("slalib_hip_eqgal.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)
Exemplo n.º 17
0
 def testD2R(self):
     """tpm.d2r() => convert degrees into radians."""
     import math
     self.assertAlmostEqual(tpm.d2r(180.0), math.pi)
     self.assertAlmostEqual(tpm.d2r(360.0), 2*math.pi)
     self.assertAlmostEqual(tpm.d2r(-360.0), -2*math.pi)
     self.assertAlmostEqual(tpm.d2r(720.0), 4*math.pi)
     self.assertAlmostEqual(tpm.d2r(-720.0), -4*math.pi)
Exemplo n.º 18
0
 def testEqu2gal(self):
     """tpm.equ2gal => convert FK4 equatorial to Galactic."""
     v6 = tpm.V6S(r=1e9,alpha=tpm.d2r(192.25), delta=tpm.d2r(27.4))
     v6 = v6.s2c()
     v6 = tpm.equ2gal(v6)
     v6 = v6.c2s()
     self.verify(v6, tpm.V6S(r=1e9, alpha=tpm.d2r(120.866),
                             delta=tpm.d2r(90.0)))
Exemplo n.º 19
0
 def testNdelta(self):
     delta = [-100, 100, 181, 270]
     delta_out = [-80.0, 80.0, -1.0, -90.0]
     for i,d in enumerate(delta):
         j = tpm.ndelta(d, degrees=True)
         self.assertAlmostEqual(j, delta_out[i], 1)
         k = tpm.ndelta(tpm.d2r(d), degrees=False)
         self.assertAlmostEqual(k, tpm.d2r(delta_out[i]), 1)
Exemplo n.º 20
0
 def testFk425(self):
     """tpm.fk425 => B1950 FK4 to J2000 FK5."""
     v6 = tpm.V6S(r=1e9, alpha=tpm.d2r(23.15678), delta=tpm.d2r(54.3892))
     v6 = v6.s2c()
     v6 = tpm.fk425(v6)
     v6 = v6.c2s()
     # Why does R change?
     self.verify(v6, tpm.V6S(r=1000000000.0008671284, alpha=tpm.d2r(23.9534903408), delta=tpm.d2r(54.6442824316)))
Exemplo n.º 21
0
 def testNdelta(self):
     delta = [-100, 100, 181, 270]
     delta_out = [-80.0, 80.0, -1.0, -90.0]
     for i, d in enumerate(delta):
         j = tpm.ndelta(d, degrees=True)
         self.assertAlmostEqual(j, delta_out[i], 1)
         k = tpm.ndelta(tpm.d2r(d), degrees=False)
         self.assertAlmostEqual(k, tpm.d2r(delta_out[i]), 1)
Exemplo n.º 22
0
 def testFk524(self):
     """tpm.fk524 => J2000 FK5 to B1950 FK4."""
     v6 = tpm.V6S(r=1e9, alpha=tpm.d2r(23.9534903408), delta=tpm.d2r(54.6442824316))
     v6 = v6.s2c()
     v6 = tpm.fk524(v6)
     v6 = v6.c2s()
     # Why does R change?
     self.verify(v6, tpm.V6S(r=1e9, alpha=tpm.d2r(23.15678), delta=tpm.d2r(54.3892)))
Exemplo n.º 23
0
 def testD2R(self):
     """tpm.d2r() => convert degrees into radians."""
     import math
     self.assertAlmostEqual(tpm.d2r(180.0), math.pi)
     self.assertAlmostEqual(tpm.d2r(360.0), 2 * math.pi)
     self.assertAlmostEqual(tpm.d2r(-360.0), -2 * math.pi)
     self.assertAlmostEqual(tpm.d2r(720.0), 4 * math.pi)
     self.assertAlmostEqual(tpm.d2r(-720.0), -4 * math.pi)
Exemplo n.º 24
0
 def testNalpha(self):
     """tpm.nalpha => angle in [0, 360) or [0, 2π)."""
     alpha = [361, -361, -180]
     alpha_out = [1, 359, 180]
     for i, d in enumerate(alpha):
         j = tpm.nalpha(d, degrees=True)
         self.assertAlmostEqual(j, alpha_out[i], 1)
         k = tpm.nalpha(tpm.d2r(d), degrees=False)
         self.assertAlmostEqual(k, tpm.d2r(alpha_out[i]), 1)
Exemplo n.º 25
0
 def testNalpha(self):
     """tpm.nalpha => angle in [0, 360) or [0, 2π)."""
     alpha = [361, -361, -180]
     alpha_out = [1, 359, 180]
     for i,d in enumerate(alpha):
         j = tpm.nalpha(d, degrees=True)
         self.assertAlmostEqual(j, alpha_out[i], 1)
         k = tpm.nalpha(tpm.d2r(d), degrees=False)
         self.assertAlmostEqual(k, tpm.d2r(alpha_out[i]), 1)
Exemplo n.º 26
0
    def testLdelfect(self):
        """tpm.ldeflect => apply GR light deflection."""
        v6h = tpm.evp(tpm.J2000)[1]
        v6 = tpm.V6S(r=1, alpha=tpm.d2r(34.56), delta=tpm.d2r(46.19))
        v6 = v6.s2c()

        v6 = tpm.ldeflect(v6, v6h, 1)

        self.verify(v6.c2s(), tpm.V6S(r=1.0, alpha=0.6031857970, delta=0.8061675815))
Exemplo n.º 27
0
 def testazel2hadec(self):
     """tpm.azel2hadec => (AZ,EL) to (HA,DEC)"""
     v6 = tpm.V6S(r=1e9)
     for i,j,k,l in zip(self.az,self.el,self.ha_c,self.dec_c):
         v6.alpha = tpm.d2r(i)
         v6.delta = tpm.d2r(j)
         v61 = tpm.azel2hadec(v6.s2c(), tpm.d2r(self.lat))
         v6 = v61.c2s()
         self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.alpha)), k, 8)
         self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.delta)), l, 8)
Exemplo n.º 28
0
 def testazel2hadec(self):
     """tpm.azel2hadec => (AZ,EL) to (HA,DEC)"""
     v6 = tpm.V6S(r=1e9)
     for i, j, k, l in zip(self.az, self.el, self.ha_c, self.dec_c):
         v6.alpha = tpm.d2r(i)
         v6.delta = tpm.d2r(j)
         v61 = tpm.azel2hadec(v6.s2c(), tpm.d2r(self.lat))
         v6 = v61.c2s()
         self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.alpha)), k, 8)
         self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.delta)), l, 8)
Exemplo n.º 29
0
    def testPrecess(self):
        """convert.precess => precess in inertial frame."""
        alpha = [34.1592] * 2
        delta = [12.9638] * 2

        a, d = convert.precess(alpha, delta, tpm.J2000, tpm.J1984, tpm.PRECESS_FK5)

        for i, j in zip(a, d):
            self.assertAlmostEqual(tpm.d2r(i), 0.5924126644, 5)
            self.assertAlmostEqual(tpm.d2r(j), 0.2249726697, 5)
Exemplo n.º 30
0
    def testLdelfect(self):
        """tpm.ldeflect => apply GR light deflection."""
        v6h = tpm.evp(tpm.J2000)[1]
        v6 = tpm.V6S(r=1, alpha=tpm.d2r(34.56), delta=tpm.d2r(46.19))
        v6 = v6.s2c()

        v6 = tpm.ldeflect(v6, v6h, 1)

        self.verify(v6.c2s(), tpm.V6S(r=1.0, alpha=0.6031857970,
                                delta=0.8061675815))
Exemplo n.º 31
0
    def testPrecess(self):
        """convert.precess => precess in inertial frame."""
        alpha = [34.1592] * 2
        delta = [12.9638] * 2

        a, d = convert.precess(alpha, delta, tpm.J2000, tpm.J1984,
                               tpm.PRECESS_FK5)

        for i, j in zip(a, d):
            self.assertAlmostEqual(tpm.d2r(i), 0.5924126644, 5)
            self.assertAlmostEqual(tpm.d2r(j), 0.2249726697, 5)
Exemplo n.º 32
0
 def testHadec2azel(self):
     """tpm.hadec2azel => (HA,DEC) to (AZ,EL)"""
     v6 = tpm.V6S(r=1e9)
     for i, j, k, l in zip(self.az, self.el, self.ha_c, self.dec_c):
         j = tpm.r2d(tpm.r2r(tpm.d2r(j)))
         v6.alpha = tpm.d2r(k)
         v6.delta = tpm.d2r(l)
         v61 = tpm.hadec2azel(v6.s2c(), tpm.d2r(self.lat))
         v6 = v61.c2s()
         self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.alpha)), i, 8)
         self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.delta)), j, 8)
Exemplo n.º 33
0
 def testFk425(self):
     """tpm.fk425 => B1950 FK4 to J2000 FK5."""
     v6 = tpm.V6S(r=1e9, alpha=tpm.d2r(23.15678), delta=
                  tpm.d2r(54.3892))
     v6 = v6.s2c()
     v6 = tpm.fk425(v6)
     v6 = v6.c2s()
     # Why does R change?
     self.verify(v6, tpm.V6S(r=1000000000.0008671284,
                             alpha=tpm.d2r(23.9534903408),
                             delta=tpm.d2r(54.6442824316)))
Exemplo n.º 34
0
 def testFk524(self):
     """tpm.fk524 => J2000 FK5 to B1950 FK4."""
     v6 = tpm.V6S(r=1e9,
                             alpha=tpm.d2r(23.9534903408),
                             delta=tpm.d2r(54.6442824316))
     v6 = v6.s2c()
     v6 = tpm.fk524(v6)
     v6 = v6.c2s()
     # Why does R change?
     self.verify(v6, tpm.V6S(r=1e9, alpha=tpm.d2r(23.15678), delta=
                  tpm.d2r(54.3892)))
Exemplo n.º 35
0
def get_tstate():
    tstate = tpm.TSTATE()
    tpm.tpm_data(tstate, tpm.TPM_INIT)
    tstate.utc = tpm.J2000
    tstate.lon = tpm.d2r(-111.598333)
    tstate.lat = tpm.d2r(31.956389)
    tstate.alt = 2093.093
    tstate.delta_at = tpm.delta_AT(tstate.utc)
    tstate.delta_ut = tpm.delta_UT(tstate.utc)
    tpm.tpm_data(tstate, tpm.TPM_ALL)

    return tstate
Exemplo n.º 36
0
 def testHadec2azel(self):
     """tpm.hadec2azel => (HA,DEC) to (AZ,EL)"""
     v6 = tpm.V6S(r=1e9)
     for i,j,k,l in zip(self.az,self.el,self.ha_c,self.dec_c):
         j = tpm.r2d(tpm.r2r(tpm.d2r(j)))
         v6.alpha = tpm.d2r(k)
         v6.delta = tpm.d2r(l)
         v61 = tpm.hadec2azel(v6.s2c(), tpm.d2r(self.lat))
         v6 = v61.c2s()
         self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.alpha)),
                                i, 8)
         self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.delta)), j, 8)
Exemplo n.º 37
0
    def testPrecess(self):
        """tpm.precess => precess V6 in inertial frame."""
        v6 = tpm.V6S(r=1e9, alpha=tpm.d2r(34.1592),
                     delta=tpm.d2r(12.9638), rdot=-0.123,
                     alphadot=0.382, deltadot=1.0)

        v6 = v6.s2c()
        v6 = tpm.precess(tpm.J2000, tpm.J1984, v6, tpm.PRECESS_FK5)
        v6 = v6.c2s()

        self.verify(v6,tpm.V6S(r=1e9, alpha=0.5924126644,
                               delta=0.2249726697,rdot=-0.1229999560,
                               alphadot=0.3809705204,
                               deltadot=1.0003321415))
Exemplo n.º 38
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,
         ),
     )
Exemplo n.º 39
0
    def testToObsAzElDateJ2000ep2000(self):
        """P and V: J2000 (~ICRS) 1991.25 => ObsAzEl Date J2000 ep J2000."""
        # Set s2=TPM_S13 and ep2=J2000 in
        # c_tests/test_conversion_with_pm.c.
        ra = []
        dec = []
        pmra = []
        pmdec = []
        px = []
        f = open(hip_data, "r")
        for i in f:
            x = [float(j) for j in i.split()]
            ra.append(tpm.d2r(x[0]))
            dec.append(tpm.d2r(x[1]))
            # Milli-arcsec/year to arcsec/century.
            pmra.append( ((x[2]/1000.0) / math.cos(tpm.d2r(x[1]))) * 100.0 )
            pmdec.append( (x[3]/1000.0) * 100.0)
            px.append(x[4])
        f.close()
        
        s1 = tpm.TPM_S06
        ep = tpm.y2j(1991.25)
        eq = tpm.J2000
        s2 = tpm.TPM_S13
        ep2 = tpm.J2000

        f = open(os.path.join(c_tests_dir,
                              "hipicrsep1991_ObsAzElDateJ2000ep2000.txt"),
                 "r")

        pvec = tpm.PVEC()
        tstate = get_tstate()
        
        for i in xrange(len(ra)):
            v6 = tpm.cat2v6(ra[i], dec[i], pmra[i], pmdec[i], px[i], 0.0,
                            tpm.CJ)
            pvec[s1] = v6
            tpm.tpm(pvec, s1, s2, ep, eq, tstate)
            v6 = pvec[s2]
            tpm.proper_motion(v6, ep2, ep)
            d = tpm.v62cat(v6, tpm.CJ)
            x = [float(j) for j in f.readline().strip().split()]
            self.assertAlmostEqual(tpm.r2d(tpm.r2r(d['alpha'])), x[0], 8)
            self.assertAlmostEqual(tpm.r2d(d['delta']), x[1], 8)
            self.assertAlmostEqual(d['pma'], x[2], 4)
            self.assertAlmostEqual(d['pmd'], x[3], 4)            
            self.assertAlmostEqual(d['px'], x[4], 8)
            self.assertAlmostEqual(d['rv'], x[5], 2)
            
        f.close()
Exemplo n.º 40
0
    def testConvertv6(self):
        """ConvertV6: J2000 (~ICRS) 1991.25 => FK4 B1950 ep 1950.0."""
        # Set s2=TPM_S05 and ep2=B1950 in
        # c_tests/test_conversion_with_pm.c.
        ra = []
        dec = []
        pmra = []
        pmdec = []
        px = []
        f = open(hip_data_icrs, "r")
        for i in f:
            x = [float(j) for j in i.split()]
            ra.append(tpm.d2r(x[0]))
            dec.append(tpm.d2r(x[1]))
            # Milli-arcsec/year to arcsec/century.
            pmra.append(((x[2] / 1000.0) / math.cos(tpm.d2r(x[1]))) * 100.0)
            pmdec.append((x[3] / 1000.0) * 100.0)
            px.append(x[4])
        f.close()

        s1 = tpm.TPM_S06
        ep = tpm.y2j(1991.25)
        eq = tpm.J2000
        s2 = tpm.TPM_S05
        ep2 = tpm.B1950

        f = open(os.path.join(c_tests_dir, "hipicrsep1991_fk4B1950ep1950.txt"),
                 "r")

        v6_l = []
        for i in range(len(ra)):
            v6 = tpm.cat2v6(ra[i], dec[i], pmra[i], pmdec[i], px[i], 0.0,
                            tpm.CJ)
            v6_l.append(v6)

        v6_out = convert.convertv6(v6_l, epoch=ep, equinox=eq, s1=s1, s2=s2)

        for v in v6_out:
            tpm.proper_motion(v, ep2, ep)
            d = tpm.v62cat(v, tpm.CJ)
            x = [float(j) for j in f.readline().strip().split()]
            self.assertAlmostEqual(tpm.r2d(tpm.r2r(d['alpha'])), x[0], 8)
            self.assertAlmostEqual(tpm.r2d(d['delta']), x[1], 8)
            self.assertAlmostEqual(d['pma'], x[2], 4)
            self.assertAlmostEqual(d['pmd'], x[3], 4)
            self.assertAlmostEqual(d['px'], x[4], 8)
            self.assertAlmostEqual(d['rv'], x[5], 2)

        f.close()
Exemplo n.º 41
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))
Exemplo n.º 42
0
    def testConvertv6(self):
        """ConvertV6: J2000 (~ICRS) 1991.25 => FK4 B1950 ep 1950.0."""
        # Set s2=TPM_S05 and ep2=B1950 in
        # c_tests/test_conversion_with_pm.c.
        ra = []
        dec = []
        pmra = []
        pmdec = []
        px = []
        f = open(hip_data_icrs, "r")
        for i in f:
            x = [float(j) for j in i.split()]
            ra.append(tpm.d2r(x[0]))
            dec.append(tpm.d2r(x[1]))
            # Milli-arcsec/year to arcsec/century.
            pmra.append(((x[2] / 1000.0) / math.cos(tpm.d2r(x[1]))) * 100.0)
            pmdec.append((x[3] / 1000.0) * 100.0)
            px.append(x[4])
        f.close()

        s1 = tpm.TPM_S06
        ep = tpm.y2j(1991.25)
        eq = tpm.J2000
        s2 = tpm.TPM_S05
        ep2 = tpm.B1950

        f = open(os.path.join(c_tests_dir, "hipicrsep1991_fk4B1950ep1950.txt"), "r")

        v6_l = []
        for i in range(len(ra)):
            v6 = tpm.cat2v6(ra[i], dec[i], pmra[i], pmdec[i], px[i], 0.0, tpm.CJ)
            v6_l.append(v6)

        v6_out = convert.convertv6(v6_l, epoch=ep, equinox=eq, s1=s1, s2=s2)

        for v in v6_out:
            tpm.proper_motion(v, ep2, ep)
            d = tpm.v62cat(v, tpm.CJ)
            x = [float(j) for j in f.readline().strip().split()]
            self.assertAlmostEqual(tpm.r2d(tpm.r2r(d["alpha"])), x[0], 8)
            self.assertAlmostEqual(tpm.r2d(d["delta"]), x[1], 8)
            self.assertAlmostEqual(d["pma"], x[2], 4)
            self.assertAlmostEqual(d["pmd"], x[3], 4)
            self.assertAlmostEqual(d["px"], x[4], 8)
            self.assertAlmostEqual(d["rv"], x[5], 2)

        f.close()
Exemplo n.º 43
0
    def test_slalib_hip_fk524(self):
        """convertv6(x,s1=6,s2=5) + PM <=> SLALIB FK5-FK4 (fk524) HIP"""
        v6l = []
        for r, d, pa, pd, px in zip(self.hip_tab['raj2'],
                                    self.hip_tab['decj2'],
                                    self.hip_tab['pma'],
                                    self.hip_tab['pmd'],
                                    self.hip_tab['px']):
            r = tpm.d2r(r)
            d = tpm.d2r(d)
            # Milli-arcsec / Jul. yr to milli-arcsec per Jul. century.
            pma = pa / math.cos(d) / 1000.0 * 100.0
            pmd = pd / 1000.0 * 100.0
            px /= 1000.0  # mili-arcsec to arc-sec.
            v6 = tpm.cat2v6(r, d, pma, pmd, px, 0.0, tpm.CJ)
            v6l.append(v6)

        v6o = convert.convertv6(v6l, s1=6, s2=5)
        v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000)
        cat = (tpm.v62cat(v, tpm.CB) for v in v6o)

        tab = get_sla("slalib_hip_fk524.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])
            # arc-sec/cent. to milli-arcsec/trop. year.
            pma = v['pma'] * 1000.0 / 100.0
            pmd = v['pmd'] * 1000.0 / 100.0
            px = v['px'] * 1e3  # arc-sec to milli-arcsec

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            px_diff = abs(px - s[2])
            pma_diff = abs(pma - s[3])
            pmd_diff = abs(pmd - s[4])
            rv_diff = abs(v['rv'] - s[5])

            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)
            self.assertTrue(pma_diff <= 0.001)
            self.assertTrue(pmd_diff <= 0.001)
            self.assertTrue(px_diff <= 9)
            self.assertTrue(rv_diff <= 0.04)
Exemplo n.º 44
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))
Exemplo n.º 45
0
 def testEllab(self):
     """tpm.ellab => apply elliptic aberration."""
     # pytpm/tests/c_tests/ellab_test.c
     v6 = tpm.V6S(r=1e9, alpha=tpm.h2r(20), delta=tpm.d2r(40.0))
     v6 = v6.s2c()
     v6 = tpm.ellab(tpm.J2000, v6, -1)
     v6 = v6.c2s()
     self.assertAlmostEqual(v6.r, 1e9, 5)
     self.assertAlmostEqual(tpm.r2h(tpm.r2r(v6.alpha)), 20.000007838, 8)
     self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.delta)), 39.999987574, 8)
Exemplo n.º 46
0
    def testPrecess(self):
        """tpm.precess => precess V6 in inertial frame."""
        v6 = tpm.V6S(r=1e9, alpha=tpm.d2r(34.1592), delta=tpm.d2r(12.9638), rdot=-0.123, alphadot=0.382, deltadot=1.0)

        v6 = v6.s2c()
        v6 = tpm.precess(tpm.J2000, tpm.J1984, v6, tpm.PRECESS_FK5)
        v6 = v6.c2s()

        self.verify(
            v6,
            tpm.V6S(
                r=1e9,
                alpha=0.5924126644,
                delta=0.2249726697,
                rdot=-0.1229999560,
                alphadot=0.3809705204,
                deltadot=1.0003321415,
            ),
        )
Exemplo n.º 47
0
 def testEllab(self):
     """tpm.ellab => apply elliptic aberration."""
     # pytpm/tests/c_tests/ellab_test.c
     v6 = tpm.V6S(r=1e9, alpha=tpm.h2r(20), delta=tpm.d2r(40.0))
     v6 = v6.s2c()
     v6 = tpm.ellab(tpm.J2000, v6, -1)
     v6 = v6.c2s()
     self.assertAlmostEqual(v6.r, 1e9,5)
     self.assertAlmostEqual(tpm.r2h(tpm.r2r(v6.alpha)), 20.000007838,8)
     self.assertAlmostEqual(tpm.r2d(tpm.r2r(v6.delta)), 39.999987574,8)
Exemplo n.º 48
0
    def test_slalib_hip_fk524(self):
        """convertv6(x,s1=6,s2=5) + PM <=> SLALIB FK5-FK4 (fk524) HIP"""
        v6l = []
        for r, d, pa, pd, px in zip(self.hip_tab['raj2'],
                                    self.hip_tab['decj2'], self.hip_tab['pma'],
                                    self.hip_tab['pmd'], self.hip_tab['px']):
            r = tpm.d2r(r)
            d = tpm.d2r(d)
            # Milli-arcsec / Jul. yr to milli-arcsec per Jul. century.
            pma = pa / math.cos(d) / 1000.0 * 100.0
            pmd = pd / 1000.0 * 100.0
            px /= 1000.0  # mili-arcsec to arc-sec.
            v6 = tpm.cat2v6(r, d, pma, pmd, px, 0.0, tpm.CJ)
            v6l.append(v6)

        v6o = convert.convertv6(v6l, s1=6, s2=5)
        v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000)
        cat = (tpm.v62cat(v, tpm.CB) for v in v6o)

        tab = get_sla("slalib_hip_fk524.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])
            # arc-sec/cent. to milli-arcsec/trop. year.
            pma = v['pma'] * 1000.0 / 100.0
            pmd = v['pmd'] * 1000.0 / 100.0
            px = v['px'] * 1e3  # arc-sec to milli-arcsec

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            px_diff = abs(px - s[2])
            pma_diff = abs(pma - s[3])
            pmd_diff = abs(pmd - s[4])
            rv_diff = abs(v['rv'] - s[5])

            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)
            self.assertTrue(pma_diff <= 0.001)
            self.assertTrue(pmd_diff <= 0.001)
            self.assertTrue(px_diff <= 9)
            self.assertTrue(rv_diff <= 0.04)
Exemplo n.º 49
0
    def test_slalib_hip_fk425(self):
        """convertv6(v6,s1=5,s2=6) + PM <=> SLALIB FK4-FK5 (fk425) HIP."""
        sla_tabb = get_sla("slalib_hip_fk524.txt")
        tab = get_sla("slalib_hip_fk524_fk425.txt")

        v6l = []
        for r, d, px, pa, pd, rv in sla_tabb:
            r = tpm.d2r(r)
            d = tpm.d2r(d)
            # Milli-arcsec / Trop. yr to arcsec per Trop. century.
            pma = pa / 1000.0 * 100.0
            pmd = pd / 1000.0 * 100.0
            px /= 1000.0  # mili-arcsec to arc-sec.
            v6 = tpm.cat2v6(r, d, pma, pmd, px, rv, tpm.CB)
            v6l.append(v6)

        v6o = convert.convertv6(v6l, s1=5, s2=6, epoch=tpm.B1950)
        v6o = convert.proper_motion(v6o, tpm.J2000, tpm.B1950)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])
            # arc-sec/cent. to milli-arcsec/Jul. year.
            pma = v['pma'] * 1000.0 / 100.0
            pmd = v['pmd'] * 1000.0 / 100.0
            px = v['px'] * 1e3  # arc-sec to milli-arcsec

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            px_diff = abs(px - s[2])
            pma_diff = abs(pma - s[3])
            pmd_diff = abs(pmd - s[4])
            rv_diff = abs(v['rv'] - s[5])

            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)
            self.assertTrue(pma_diff <= 0.001)
            self.assertTrue(pmd_diff <= 0.001)
            self.assertTrue(px_diff <= 9)
            self.assertTrue(rv_diff <= 0.04)
Exemplo n.º 50
0
    def test_slalib_hip_fk52appradec(self):
        """convert(x, s1=6, s2=11) + PM => SLALIB sla_map HIP."""
        tab = get_sla("slalib_hip_map.txt")

        v6l = []
        for r, d, pa, pd, px in zip(self.hip_tab['raj2'],
                                    self.hip_tab['decj2'], self.hip_tab['pma'],
                                    self.hip_tab['pmd'], self.hip_tab['px']):
            r = tpm.d2r(r)
            d = tpm.d2r(d)
            # Milli-arcsec / Jul. yr to arcsec per Jul. century.
            pma = pa / math.cos(d) / 1000.0 * 100.0
            pmd = pd / 1000.0 * 100.0
            px /= 1000.0  # mili-arcsec to arc-sec.
            v6 = tpm.cat2v6(r, d, pma, pmd, px, 0.0, tpm.CJ)
            v6l.append(v6)

        utc = tpm.gcal2j(2010, 1, 1) - 0.5  # midnight
        tt = tpm.utc2tdb(utc)

        v6o = convert.proper_motion(v6l, tt, tpm.J2000)
        v6o = convert.convertv6(v6o,
                                s1=6,
                                s2=11,
                                epoch=tt,
                                equinox=tpm.J2000,
                                utc=utc,
                                delta_at=tpm.delta_AT(utc))

        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        l = len(v6o)

        for v, s, i in zip(cat, tab, range(l)):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.33)
            self.assertTrue(dec_diff <= 0.03)
Exemplo n.º 51
0
    def test_slalib_hip_fk425(self):
        """convertv6(v6,s1=5,s2=6) + PM <=> SLALIB FK4-FK5 (fk425) HIP."""
        sla_tabb = get_sla("slalib_hip_fk524.txt")
        tab = get_sla("slalib_hip_fk524_fk425.txt")

        v6l = []
        for r, d, px, pa, pd, rv in sla_tabb:
            r = tpm.d2r(r)
            d = tpm.d2r(d)
            # Milli-arcsec / Trop. yr to arcsec per Trop. century.
            pma = pa / 1000.0 * 100.0
            pmd = pd / 1000.0 * 100.0
            px /= 1000.0  # mili-arcsec to arc-sec.
            v6 = tpm.cat2v6(r, d, pma, pmd, px, rv, tpm.CB)
            v6l.append(v6)

        v6o = convert.convertv6(v6l, s1=5, s2=6, epoch=tpm.B1950)
        v6o = convert.proper_motion(v6o, tpm.J2000, tpm.B1950)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])
            # arc-sec/cent. to milli-arcsec/Jul. year.
            pma = v['pma'] * 1000.0 / 100.0
            pmd = v['pmd'] * 1000.0 / 100.0
            px = v['px'] * 1e3  # arc-sec to milli-arcsec

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            px_diff = abs(px - s[2])
            pma_diff = abs(pma - s[3])
            pmd_diff = abs(pmd - s[4])
            rv_diff = abs(v['rv'] - s[5])

            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)
            self.assertTrue(pma_diff <= 0.001)
            self.assertTrue(pmd_diff <= 0.001)
            self.assertTrue(px_diff <= 9)
            self.assertTrue(rv_diff <= 0.04)
Exemplo n.º 52
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)
        )
Exemplo n.º 53
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))
Exemplo n.º 54
0
    def test_slalib_hip_fk52appradec(self):
        """convert(x, s1=6, s2=11) + PM => SLALIB sla_map HIP."""
        tab = get_sla("slalib_hip_map.txt")

        v6l = []
        for r, d, pa, pd, px in zip(self.hip_tab['raj2'],
                                    self.hip_tab['decj2'],
                                    self.hip_tab['pma'],
                                    self.hip_tab['pmd'],
                                    self.hip_tab['px']):
            r = tpm.d2r(r)
            d = tpm.d2r(d)
            # Milli-arcsec / Jul. yr to arcsec per Jul. century.
            pma = pa / math.cos(d) / 1000.0 * 100.0
            pmd = pd / 1000.0 * 100.0
            px /= 1000.0  # mili-arcsec to arc-sec.
            v6 = tpm.cat2v6(r, d, pma, pmd, px, 0.0, tpm.CJ)
            v6l.append(v6)

        utc = tpm.gcal2j(2010, 1, 1) - 0.5  # midnight
        tt = tpm.utc2tdb(utc)

        v6o = convert.proper_motion(v6l, tt, tpm.J2000)
        v6o = convert.convertv6(v6o, s1=6, s2=11, epoch=tt,
                                equinox=tpm.J2000,
                                utc=utc, delta_at=tpm.delta_AT(utc))

        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        l = len(v6o)

        for v, s, i in zip(cat, tab, range(l)):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.33)
            self.assertTrue(dec_diff <= 0.03)
Exemplo n.º 55
0
    def test_slalib_nwdfs_eqecl(self):
        """convertv6(x,s1=6,s=3) <=> SLALIB eqecl NDWFS"""
        v6l = []
        for r, d in zip(self.ndwfs_tab['raj2'], self.ndwfs_tab['decj2']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        v6o = convert.convertv6(v6l, s1=6, s2=3)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        tab = get_sla("slalib_ndwfs_eqecl.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.001 )
            self.assertTrue(dec_diff <= 0.001)
Exemplo n.º 56
0
    def test_slalib_hip_ecleq(self):
        """convertv6(x,s1=3,s=6) <=> SLALIB ecleq HIP"""
        v6l = []
        for r, d in zip(self.hip_tab['elon2'], self.hip_tab['elat2']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        v6o = convert.convertv6(v6l, s1=3, s2=6)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        tab = get_sla("slalib_hip_ecleq.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)
Exemplo n.º 57
0
    def test_slalib_nwdfs_eqecl(self):
        """convertv6(x,s1=6,s=3) <=> SLALIB eqecl NDWFS"""
        v6l = []
        for r, d in zip(self.ndwfs_tab['raj2'], self.ndwfs_tab['decj2']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        v6o = convert.convertv6(v6l, s1=6, s2=3)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        tab = get_sla("slalib_ndwfs_eqecl.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)
Exemplo n.º 58
0
    def test_slalib_hip_ecleq(self):
        """convertv6(x,s1=3,s=6) <=> SLALIB ecleq HIP"""
        v6l = []
        for r, d in zip(self.hip_tab['elon2'], self.hip_tab['elat2']):
            v6 = tpm.V6S()
            v6.r = 1e9
            v6.alpha = tpm.d2r(r)
            v6.delta = tpm.d2r(d)
            v6l.append(v6.s2c())

        v6o = convert.convertv6(v6l, s1=3, s2=6)
        cat = (tpm.v62cat(v, tpm.CJ) for v in v6o)

        tab = get_sla("slalib_hip_ecleq.txt")

        for v, s in zip(cat, tab):
            ra = math.degrees(tpm.r2r(v['alpha']))
            dec = math.degrees(v['delta'])

            ra_diff = abs(ra - s[0]) * 3600.0
            dec_diff = abs(dec - s[1]) * 3600.0
            self.assertTrue(ra_diff <= 0.001)
            self.assertTrue(dec_diff <= 0.001)