Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
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.º 16
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.º 17
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.º 18
0
    def test_slalib_hip_fk52obs(self):
        """convert(x, s1=6, s2=19) (+ s2=20) + PM => SLALIB sla_aop HIP."""
        tab = get_sla("slalib_hip_aop.txt")
        az_sla = []
        zd_sla = []
        ha_sla = []
        dec_sla = []
        ra_sla = []
        for i in tab:
            # Convert longitude values to 0 - 360
            az_sla.append(i[0] if i[0] >= 0 else i[0] + 360.0)
            zd_sla.append(i[1])
            ha_sla.append(i[2] if i[2] >= 0 else i[2] + 360.0)
            dec_sla.append(i[3])
            ra_sla.append(i[4] if i[4] >= 0 else i[4] + 360.0)

        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)

        # Convert to Az-EL.
        v6o = convert.proper_motion(v6l, tt, tpm.J2000)
        v6o = convert.convertv6(v6o, s1=6, s2=19, utc=utc)

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

        az = []
        zd = []
        for i in cat:
            az.append(tpm.r2d(i['alpha']))
            zd.append(90.0 - tpm.r2d(i['delta']))

        # Convert Az-El to HA-Dec.
        v6o = convert.convertv6(v6o, s1=19, s2=20, utc=utc)

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

        # Find LAST.
        tstate = tpm.TSTATE()
        tpm.tpm_data(tstate, tpm.TPM_INIT)
        tstate.utc = utc
        tstate.delta_ut = tpm.delta_UT(utc)
        tstate.delta_at = tpm.delta_AT(utc)
        tstate.lon = tpm.d2r(-111.598333)
        tstate.lat = tpm.d2r(31.956389)
        tpm.tpm_data(tstate, tpm.TPM_ALL)
        last = tpm.r2d(tstate.last)

        ha = []
        dec = []
        ra = []
        for i in cat:
            ha.append(tpm.r2d(i['alpha']))
            dec.append(tpm.r2d(i['delta']))
            # RA = LAST - HA and convert to 0 - 360.
            x = last - tpm.r2d(i['alpha'])
            ra.append(x if x >= 0 else x + 360.0)

        for i in range(len(az)):
            # Test only the coordinates with ZD < 75.0.
            if zd[i] < 75.0:
                self.assertTrue(abs(az[i] - az_sla[i]) * 3600.0 <= 0.25)
                self.assertTrue(abs(zd[i] - zd_sla[i]) * 3600.0 <= 0.04)
                self.assertTrue(abs(ha[i] - ha_sla[i]) * 3600.0 <= 0.28)
                self.assertTrue(abs(dec[i] - dec_sla[i]) * 3600.0 <= 0.04)
                self.assertTrue(abs(ra[i] - ra_sla[i]) * 3600.0 <= 0.33)
Exemplo n.º 19
0
    def test_slalib_hip_fk52obs(self):
        """convert(x, s1=6, s2=19) (+ s2=20) + PM => SLALIB sla_aop HIP."""
        tab = get_sla("slalib_hip_aop.txt")
        az_sla = []
        zd_sla = []
        ha_sla = []
        dec_sla = []
        ra_sla = []
        for i in tab:
            # Convert longitude values to 0 - 360
            az_sla.append(i[0] if i[0] >= 0 else i[0] + 360.0)
            zd_sla.append(i[1])
            ha_sla.append(i[2] if i[2] >= 0 else i[2] + 360.0)
            dec_sla.append(i[3])
            ra_sla.append(i[4] if i[4] >= 0 else i[4] + 360.0)

        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)

        # Convert to Az-EL.
        v6o = convert.proper_motion(v6l, tt, tpm.J2000)
        v6o = convert.convertv6(v6o, s1=6, s2=19, utc=utc)

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

        az = []
        zd = []
        for i in cat:
            az.append(tpm.r2d(i['alpha']))
            zd.append(90.0 - tpm.r2d(i['delta']))

        # Convert Az-El to HA-Dec.
        v6o = convert.convertv6(v6o, s1=19, s2=20, utc=utc)

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

        # Find LAST.
        tstate = tpm.TSTATE()
        tpm.tpm_data(tstate, tpm.TPM_INIT)
        tstate.utc = utc
        tstate.delta_ut = tpm.delta_UT(utc)
        tstate.delta_at = tpm.delta_AT(utc)
        tstate.lon = tpm.d2r(-111.598333)
        tstate.lat = tpm.d2r(31.956389)
        tpm.tpm_data(tstate, tpm.TPM_ALL)
        last = tpm.r2d(tstate.last)

        ha = []
        dec = []
        ra = []
        for i in cat:
            ha.append(tpm.r2d(i['alpha']))
            dec.append(tpm.r2d(i['delta']))
            # RA = LAST - HA and convert to 0 - 360.
            x = last - tpm.r2d(i['alpha'])
            ra.append(x if x >= 0  else x + 360.0)

        for i in range(len(az)):
            # Test only the coordinates with ZD < 75.0.
            if zd[i] < 75.0:
                self.assertTrue(abs(az[i] - az_sla[i]) * 3600.0 <= 0.25)
                self.assertTrue(abs(zd[i] - zd_sla[i]) * 3600.0 <= 0.04)
                self.assertTrue(abs(ha[i] - ha_sla[i]) * 3600.0 <= 0.28)
                self.assertTrue(abs(dec[i] - dec_sla[i]) * 3600.0 <= 0.04)
                self.assertTrue(abs(ra[i] - ra_sla[i]) * 3600.0 <= 0.33)