Пример #1
0
 def testDeltaT(self):
     """delta_T(ut1): TT - UT1 for the given UT1."""
     dt = [7.8, 29.166059415081, 60.705445202903, 53.792092550539,
           65.217663154508]
     ut1 = [x+tpm.delta_UT(x) for x in self.utc]
     for i,j in zip(ut1, dt):
         self.assertAlmostEqual(tpm.delta_T(i), j, 12)
Пример #2
0
def get_tstate():
    tstate = tpm.TSTATE()
    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_at = tpm.delta_AT(tstate.utc)
    tstate.delta_ut = tpm.delta_UT(tstate.utc)
    tpm.tpm_data(tstate, tpm.TPM_ALL)

    return tstate
Пример #3
0
    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)
Пример #4
0
 def testDeltaT(self):
     """delta_T(ut1): TT - UT1 for the given UT1."""
     dt = [7.8, 29.166059415081, 60.705445202903, 53.792092550539, 65.217663154508]
     ut1 = [x + tpm.delta_UT(x) for x in self.utc]
     for i, j in zip(ut1, dt):
         self.assertAlmostEqual(tpm.delta_T(i), j, 12)
Пример #5
0
 def testDeltaUT(self):
     """delta_UT(utc): UT1 - UTC for the given UTC."""
     dut = [34.384, 13.032937389587, 3.482360655738, 0.392497267760, 0.967397006595]
     for i, j in zip(self.utc, dut):
         self.assertAlmostEqual(tpm.delta_UT(i), j, 12)
Пример #6
0
v620 = convert.convertv6(v619, s1=19, s2=20, utc=utc)
cat20 = convert.v62cat(v620, tpm.CJ)
cat20 = cat2array(cat20)

ha = np.degrees(cat20['alpha'])
dec = np.degrees(cat20['delta'])

# Difference in HA and Dec, using TPM and SLALIB.
ha_diff = np.abs(ha[indx] - ha_sla[indx]) * 3600.0
dec_diff = np.abs(dec[indx] - dec_sla[indx]) * 3600.0

# Find RA = LAST - HA.
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)
ra = last - ha
# Have to normalize to 0 - 360.0.
ra = np.array([i if i > 0 else i + 360.0 for i in ra])
ra_diff = np.abs(ra[indx] - ra_sla[indx]) * 3600.0

print("Comparison with SLALIB aop using HIPPARCOS data.")
fs = "{0} {1}\n" + \
    "Min:  {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n"
x = stats.describe(az_diff)
print(fs.format("az_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5))
Пример #7
0
v620 = convert.convertv6(v619, s1=19, s2=20, utc=utc)
cat20 = convert.v62cat(v620, tpm.CJ)
cat20 = cat2array(cat20)

ha = np.degrees(cat20['alpha'])
dec = np.degrees(cat20['delta'])

# Difference in HA and Dec, using TPM and SLALIB.
ha_diff = np.abs(ha[indx] - ha_sla[indx]) * 3600.0
dec_diff = np.abs(dec[indx] - dec_sla[indx]) * 3600.0

# Find RA = LAST - HA.
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)
ra = last - ha
# Have to normalize to 0 - 360.0.
ra = np.array([i if i > 0 else i + 360.0 for i in ra])
ra_diff = np.abs(ra[indx] - ra_sla[indx]) * 3600.0

print("Comparison with SLALIB aop using HIPPARCOS data.")
fs = "{0} {1}\n" + \
    "Min:  {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n"
x = stats.describe(az_diff)
print(fs.format("az_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5))
Пример #8
0
    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)
Пример #9
0
 def testDeltaUT(self):
     """delta_UT(utc): UT1 - UTC for the given UTC."""
     dut = [34.384, 13.032937389587, 3.482360655738, 0.392497267760,
            0.967397006595]
     for i,j in zip(self.utc, dut):
         self.assertAlmostEqual(tpm.delta_UT(i), j, 12)
Пример #10
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)
Пример #11
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)