示例#1
0
    def test_timet(self):
        t = Time(datetime.datetime(1970, 1, 1, 0, 0, 0))
        self.assertAlmostEqual(t.timet, 0)

        t = Time(datetime.datetime(1970, 1, 1, 12, 34, 56))
        self.assertAlmostEqual(t.timet, 45296)

        t = Time(datetime.datetime(1970, 1, 1 + 10, 12, 34, 56))
        self.assertAlmostEqual(t.timet, 45296 + (10 * 86400))
示例#2
0
 def test_deepsky1(self):
     # http://www.convertalot.com/celestial_horizon_co-ordinates_calculator.html
     observer = Observer.from_str("N 42° 21'", "W 71° 4'")
     obstime = Time.from_str("2004-04-06 19:00:00Z")
     dsobject = EquatorialCoordObject.from_str("03:47", "+24° 7'")
     apparent = dsobject.calculate_apparent_position(observer, obstime)
     self.assertAlmostEqual(apparent.altitude, 70.76031714756199, places=2)
     self.assertAlmostEqual(apparent.azimuth, 159.05385342558554, places=2)
示例#3
0
 def test_gmst(self):
     # http://www2.arnes.si/~gljsentvid10/sidereal.htm -- there's an error
     # in this document; it first says 280.46061837 in the equation for
     # GMST, but later in the example uses 281.46061837. Don't have the
     # original (Meeus formula 11.4) available, but other sources also use
     # 280.xxx.
     t = Time.from_str("1994-06-16 18:00:00Z")
     gmst = t.greenwich_mean_sidereal_time_deg
     self.assertAlmostEqual(gmst, 174.771113474402, places=5)
示例#4
0
    def test_deepsky_stellarium(self):
        observer = Observer.from_str("N 48° 51' 12.27\"", "E 2° 20' 55.68\"")
        obstime = Time.from_localtime_str("2017-08-16 23:25:22",
                                          "Europe/Paris")
        dsobject = EquatorialCoordObject.from_str(
            "20:22:00.54", "-14° 43' 20.4\"")  # beta Cap

        apparent = dsobject.calculate_apparent_position(observer, obstime)
        self.assertAlmostEqual(apparent.azimuth,
                               162 + (32 / 60) + (50.2 / 3600),
                               places=2)
        self.assertAlmostEqual(apparent.altitude,
                               24 + (49 / 60) + (28.4 / 3600),
                               places=1)
示例#5
0
    def test_deepsky2(self):
        # http://www.stargazing.net/kepler/altaz.html
        observer = Observer.from_str("N 52° 30'", "W 1° 55'")
        obstime = Time.from_str("1998-08-10 23:10:00Z")
        dsobject = EquatorialCoordObject.from_str("16:41.7", "36° 28'")

        self.assertAlmostEqual(dsobject.ra, 16.695)
        self.assertAlmostEqual(dsobject.dec, 36.466667, places=6)
        self.assertAlmostEqual(obstime.time, 23.166667, places=6)
        self.assertAlmostEqual(observer.latitude, 52.5)
        self.assertAlmostEqual(observer.longitude, -1.9166667)

        lst_deg = obstime.local_mean_sidereal_time_deg(observer)
        self.assertAlmostEqual(lst_deg, 304.80761, places=3)

        apparent = dsobject.calculate_apparent_position(observer, obstime)
        self.assertAlmostEqual(apparent.altitude, 49.169122, places=3)
        self.assertAlmostEqual(apparent.azimuth, 269.14634, places=3)
示例#6
0
    def test_local_sidereal_time(self):
        obs = Observer.from_str("N 0", "E 13")
        t = Time(datetime.datetime(2017, 1, 1, 10, 0, 21))
        self.assertAlmostEqual(t.jd, 2457754.91691, places=6)
        self.assertAlmostEqual(t.local_mean_sidereal_time_hrs(obs),
                               17 + (37 / 60) + (21 / 3600),
                               places=3)

        obs = Observer.from_str("N 0", "W 122.49")
        t = Time(datetime.datetime(2010, 1, 2, 20, 34, 5))
        self.assertAlmostEqual(t.jd, 2455199.357, places=5)
        self.assertAlmostEqual(t.local_mean_sidereal_time_hrs(obs),
                               19 + (13 / 60) + (36 / 3600),
                               places=3)
示例#7
0
    def test_jupiter(self):
        observer = Observer.from_str("N 48° 51' 12.27\"", "E 2° 20' 55.68\"")
        obstime = Time.from_localtime_str("2017-08-16 20:00:53",
                                          "Europe/Paris")

        jupiter = self._jupiter()
        equatorial = jupiter.calculate_equatorial_position(observer, obstime)
        self.assertAlmostEqual(equatorial.ra,
                               13 + (13 / 60) + (12.22 / 3600),
                               places=2)
        self.assertAlmostEqual(equatorial.dec,
                               -(6 + (31 / 60) + (28.0 / 3600)),
                               places=1)
        apparent = jupiter.calculate_apparent_position(observer, obstime)
        self.assertAlmostEqual(apparent.azimuth,
                               224 + (11 / 60) + (15.7 / 3600),
                               places=0)
        self.assertAlmostEqual(apparent.altitude,
                               24 + (45 / 60) + (32.5 / 3600),
                               places=1)
示例#8
0
    def test_y2000days(self):
        t = Time(datetime.datetime(2000, 1, 2, 12, 0, 0))
        self.assertAlmostEqual(t.days_since_y2000, 1)

        t = Time(datetime.datetime(2000, 1, 3, 13, 0, 0))
        self.assertAlmostEqual(t.days_since_y2000, 2 + (1 / 24))
示例#9
0
 def test_jd(self):
     t = Time(datetime.datetime(2013, 1, 1, 0, 30, 0))
     self.assertAlmostEqual(t.jd, 2456293.520833, places=6)