def testInit(self): """PVEC() => pvec with default values for all V6C.""" pvec = tpm.PVEC() # The following also tests getting an item. for i in range(tpm.N_TPM_STATES): self.checkpvec(pvec, i, dict(x=0.0, y=0.0, z=0.0, xdot=0.0, ydot=0.0, zdot=0.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()
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)
def testTPM(self): """tpm.tpm() => coordinate conversion.""" # M100 FK5 J2000 from SIMBAD. # See pytpm/tests/c_tests/test_conversion.c. results = [ dict(ra_dd=-175.00, ra_mm=43.0, ra_ss=43.4850, de_dd=15.00, de_mm=49.00, de_ss=20.5700), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=42.3616, de_dd=15.00, de_mm=49.00, de_ss=20.4480), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=43.4850, de_dd=15.00, de_mm=49.00, de_ss=20.5700), dict(ra_dd=178.00, ra_mm=46.00, ra_ss=57.2326, de_dd=16.00, de_mm=45.00, de_ss=34.9209), dict(ra_dd=-89.00, ra_mm=8.00, ra_ss=10.1024, de_dd=76.00, de_mm=53.00, de_ss=55.9283), dict(ra_dd=-175.00, ra_mm=5.00, ra_ss=44.0262, de_dd=16.00, de_mm=5.00, de_ss=58.0246 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=43.4850, de_dd=15.00, de_mm=49.00, de_ss=20.5700 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=43.4852, de_dd=15.00, de_mm=49.00, de_ss=20.5699 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=43.4819, de_dd=15.00, de_mm=49.00, de_ss=20.5712 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=44.9349, de_dd=15.00, de_mm=49.00, de_ss=13.4744 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=44.9350, de_dd=15.00, de_mm=49.00, de_ss=13.4743 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=30.6891, de_dd=15.00, de_mm=49.00, de_ss=19.5611 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=43.4852, de_dd=15.00, de_mm=49.00, de_ss=20.5699 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=43.4819, de_dd=15.00, de_mm=49.00, de_ss=20.5712 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=45.2053, de_dd=15.00, de_mm=49.00, de_ss=13.4529 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=45.2054, de_dd=15.00, de_mm=49.00, de_ss=13.4528 ), dict(ra_dd=-175.00, ra_mm=43.00, ra_ss=30.9595, de_dd=15.00, de_mm=49.00, de_ss=19.5396 ), dict(ra_dd=-17.00, ra_mm=8.00, ra_ss=52.8721, de_dd=15.00, de_mm=49.00, de_ss=19.5396 ), dict(ra_dd=132.00, ra_mm=32.00, ra_ss=57.5676, de_dd=67.00, de_mm=45.00, de_ss=9.6836 ), dict(ra_dd=132.00, ra_mm=32.00, ra_ss=57.5676, de_dd=67.00, de_mm=45.00, de_ss=34.3714 ), dict(ra_dd=-17.00, ra_mm=9.00, ra_ss=9.5430, de_dd=15.00, de_mm=49.00, de_ss=38.3077 ), dict(ra_dd=-17.00, ra_mm=14.00, ra_ss=6.8699, de_dd=-15.00, de_mm=10.00, de_ss=13.0062 ) ] ra = tpm.h2r(12+22/60.0+54.899/3600.0) de = tpm.d2r(15+49/60.0+20.57/3600.0) ep = tpm.J2000 eq = tpm.J2000 s1 = tpm.TPM_S06 s2 = tpm.TPM_S00 tstate = tpm.TSTATE() pvec = tpm.PVEC() for i in range(tpm.N_TPM_STATES): 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_ut = tpm.delta_UT(tstate.utc) tpm.tpm_data(tstate, tpm.TPM_ALL) v6 = tpm.V6S() v6.r = 1e9 v6.alpha = ra v6.delta = de pvec[s1] = v6.s2c() s2 = i tpm.tpm(pvec, s1, s2, ep, eq, tstate) v6 = pvec[s2].c2s() ra1 = v6.alpha de1 = v6.delta ra_dms = tpm.DMS(r=ra1) de_dms = tpm.DMS(r=de1) ra_dms.normalize() de_dms.normalize() self.assertAlmostEqual(ra_dms.dd, results[i]['ra_dd'], 4) self.assertAlmostEqual(ra_dms.mm, results[i]['ra_mm'], 4) self.assertAlmostEqual(ra_dms.ss, results[i]['ra_ss'], 4) self.assertAlmostEqual(de_dms.dd, results[i]['de_dd'], 4) self.assertAlmostEqual(de_dms.mm, results[i]['de_mm'], 4) self.assertAlmostEqual(de_dms.ss, results[i]['de_ss'], 4)
def testCreate(self): """PVEC() => a PVEC object.""" pvec = tpm.PVEC() self.assertEqual(type(pvec), tpm.PVEC)