Exemplo n.º 1
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.º 2
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.º 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 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.º 5
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()