Beispiel #1
0
 def testY2J(self):
     """tpm.y2j() => year number into a scalar Julian date."""
     # This is just the inverse of testJ2Y.
     self.assertAlmostEqual(2400000.5, tpm.y2j(1858.879452054794), 12)
     self.assertAlmostEqual(2433282.42345905, tpm.y2j(1950.002530024794), 12)
     self.assertAlmostEqual(2451545.0, tpm.y2j(2000.004098360656), 12)
     self.assertAlmostEqual(2445700.5, tpm.y2j(1984.002732240437), 12)
Beispiel #2
0
 def testY2J(self):
     """tpm.y2j() => year number into a scalar Julian date."""
     # This is just the inverse of testJ2Y.
     self.assertAlmostEqual(2400000.5, tpm.y2j(1858.879452054794), 12)
     self.assertAlmostEqual(2433282.42345905, tpm.y2j(1950.002530024794),
                            12)
     self.assertAlmostEqual(2451545.0, tpm.y2j(2000.004098360656), 12)
     self.assertAlmostEqual(2445700.5, tpm.y2j(1984.002732240437), 12)
Beispiel #3
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()
Beispiel #4
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()
Beispiel #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()