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)
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)
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)
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)
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)
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)
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)
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)
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)
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 )
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 )
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)
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)
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)
def cat2array(cat): dtype = [('alpha', np.float64), ('delta', np.float64), ('pma', np.float64), ('pmd', np.float64), ('px', np.float64), ('rv', np.float64)] d = np.array([(tpm.r2r(i['alpha']), i['delta'], i['pma'], i['pmd'], i['px'], i['rv']) for i in cat], dtype=dtype) return d
def cat2array(cat): dtype = [('alpha', np.float64), ('delta', np.float64), ('pma', np.float64), ('pmd', np.float64), ('px', np.float64), ('rv', np.float64)] d = np.array([(tpm.r2r( i['alpha']), i['delta'], i['pma'], i['pmd'], i['px'], i['rv']) for i in cat], dtype=dtype) return d
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 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()
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()
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)
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)
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)
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)
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)
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)
def test_slalib_nwdfs_fk45z(self): """convertv6(x,s1=5,s=6) <=> SLALIB FK4-FK5 (fk45z) NDWFS""" v6l = [] for r, d in zip(self.ndwfs_tab['rab1'], self.ndwfs_tab['decb1']): 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=5, s2=6) v6o = convert.proper_motion(v6o, tpm.J2000, tpm.B1950) cat = (tpm.v62cat(v, tpm.CJ) for v in v6o) tab = get_sla("slalib_ndwfs_fk45z.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.5 ) self.assertTrue(dec_diff <= 0.5)
def test_slalib_nwdfs_fk45z(self): """convertv6(x,s1=5,s=6) <=> SLALIB FK4-FK5 (fk45z) NDWFS""" v6l = [] for r, d in zip(self.ndwfs_tab['rab1'], self.ndwfs_tab['decb1']): 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=5, s2=6) v6o = convert.proper_motion(v6o, tpm.J2000, tpm.B1950) cat = (tpm.v62cat(v, tpm.CJ) for v in v6o) tab = get_sla("slalib_ndwfs_fk45z.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.5) self.assertTrue(dec_diff <= 0.5)
def testR2R(self): """tpm.r2r() => properly normalize radians.""" import math self.assertAlmostEqual(tpm.r2r( 0.00000000), 0.00000000) self.assertAlmostEqual(tpm.r2r( -0.00000000), -0.00000000) self.assertAlmostEqual(tpm.r2r( math.pi/2.0), 1.57079633) self.assertAlmostEqual(tpm.r2r( -math.pi/2.0), 4.71238898) self.assertAlmostEqual(tpm.r2r( 2*math.pi), 0.00000000) self.assertAlmostEqual(tpm.r2r( -2*math.pi), 0.00000000) self.assertAlmostEqual(tpm.r2r( -3*math.pi), 3.14159265) self.assertAlmostEqual(tpm.r2r( 3*math.pi), 3.14159265) self.assertAlmostEqual(tpm.r2r( 4*math.pi), 0.00000000) self.assertAlmostEqual(tpm.r2r(-4*math.pi), 0.00000000) self.assertAlmostEqual(tpm.r2r( 4.2*math.pi), 0.62831853) self.assertAlmostEqual(tpm.r2r(-4.2*math.pi), 5.65486678)
def testR2R(self): """tpm.r2r() => properly normalize radians.""" import math self.assertAlmostEqual(tpm.r2r(0.00000000), 0.00000000) self.assertAlmostEqual(tpm.r2r(-0.00000000), -0.00000000) self.assertAlmostEqual(tpm.r2r(math.pi / 2.0), 1.57079633) self.assertAlmostEqual(tpm.r2r(-math.pi / 2.0), 4.71238898) self.assertAlmostEqual(tpm.r2r(2 * math.pi), 0.00000000) self.assertAlmostEqual(tpm.r2r(-2 * math.pi), 0.00000000) self.assertAlmostEqual(tpm.r2r(-3 * math.pi), 3.14159265) self.assertAlmostEqual(tpm.r2r(3 * math.pi), 3.14159265) self.assertAlmostEqual(tpm.r2r(4 * math.pi), 0.00000000) self.assertAlmostEqual(tpm.r2r(-4 * math.pi), 0.00000000) self.assertAlmostEqual(tpm.r2r(4.2 * math.pi), 0.62831853) self.assertAlmostEqual(tpm.r2r(-4.2 * math.pi), 5.65486678)
def verify(self, v61, v62): self.assertAlmostEqual(v61.r, v62.r, 2) self.assertAlmostEqual(tpm.r2r(v61.alpha), v62.alpha, 2) self.assertAlmostEqual(tpm.r2r(v61.delta), v62.delta, 2)