Exemplo n.º 1
0
 def test_dateLongToDate(self):
     """dateLongToDate should give known output"""
     self.assertEqual(Lgm_CTrans.dateLongToDate(20001223), datetime.datetime(2000, 12, 23, 0, 0))
     self.assertEqual(Lgm_CTrans.dateLongToDate([20001223]), datetime.datetime(2000, 12, 23, 0, 0))
     self.assertEqual(Lgm_CTrans.dateLongToDate([20001223]*2),
                      [datetime.datetime(2000, 12, 23, 0, 0), datetime.datetime(2000, 12, 23, 0, 0)])
     numpy.testing.assert_array_equal(Lgm_CTrans.dateLongToDate(numpy.array([20001223]*2)),
                      numpy.array([datetime.datetime(2000, 12, 23, 0, 0), datetime.datetime(2000, 12, 23, 0, 0)]))
Exemplo n.º 2
0
    def test_Lgm_LoadLeapSeconds(self):
        """Lgm_LoadLeapSeconds should work and not change"""
        self.assertTrue(Lgm_LoadLeapSeconds(ctypes.pointer(self.c)))
        # The LeapSecondDates values are the dates that the given corrections came into effect. But the actual leap second
        # date is the day before -- thats when the extra second was tacked on. So subtract a day from each of the dates.
        LeapSecondDates = [19720101, 19720701, 19730101, 19740101, 19750101,
                           19760101, 19770101, 19780101, 19790101, 19800101,
                           19810701, 19820701, 19830701, 19850701, 19880101,
                           19900101, 19910101, 19920701, 19930701, 19940701,
                           19960101, 19970701, 19990101, 20060101, 20090101,]
        LeapSecondJDs = [2441317.5, 2441499.5, 2441683.5, 2442048.5, 2442413.5,
                         2442778.5, 2443144.5, 2443509.5, 2443874.5, 2444239.5,
                         2444786.5, 2445151.5, 2445516.5, 2446247.5, 2447161.5,
                         2447892.5, 2448257.5, 2448804.5, 2449169.5, 2449534.5,
                         2450083.5, 2450630.5, 2451179.5, 2453736.5, 2454832.5,]
        LeapSeconds = [10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0,
                       19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0,
                       28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, ]
        LeapSecondDates = Lgm_CTrans.dateLongToDate(LeapSecondDates)
        LeapSecondDates = [val - datetime.timedelta(days=1) for val in LeapSecondDates]
        LeapSecondDates = Lgm_CTrans.dateToDateLong(LeapSecondDates)

        for i, (v1, v2, v3) in enumerate(zip(LeapSecondDates, LeapSecondJDs, LeapSeconds)):
            self.assertEqual(v1, self.c.l.LeapSecondDates[i])
            self.assertEqual(v2, self.c.l.LeapSecondJDs[i])
            self.assertEqual(v3, self.c.l.LeapSeconds[i])
    def test_Lgm_LoadLeapSeconds(self):
        """Lgm_LoadLeapSeconds should work and not change"""
        self.assertTrue(Lgm_LoadLeapSeconds(ctypes.pointer(self.c)))
        # The LeapSecondDates values are the dates that the given corrections came into effect. But the actual leap second
        # date is the day before -- thats when the extra second was tacked on. So subtract a day from each of the dates.
        LeapSecondDates = [
            19720101,
            19720701,
            19730101,
            19740101,
            19750101,
            19760101,
            19770101,
            19780101,
            19790101,
            19800101,
            19810701,
            19820701,
            19830701,
            19850701,
            19880101,
            19900101,
            19910101,
            19920701,
            19930701,
            19940701,
            19960101,
            19970701,
            19990101,
            20060101,
            20090101,
        ]
        LeapSecondJDs = [
            2441317.5,
            2441499.5,
            2441683.5,
            2442048.5,
            2442413.5,
            2442778.5,
            2443144.5,
            2443509.5,
            2443874.5,
            2444239.5,
            2444786.5,
            2445151.5,
            2445516.5,
            2446247.5,
            2447161.5,
            2447892.5,
            2448257.5,
            2448804.5,
            2449169.5,
            2449534.5,
            2450083.5,
            2450630.5,
            2451179.5,
            2453736.5,
            2454832.5,
        ]
        LeapSeconds = [
            10.0,
            11.0,
            12.0,
            13.0,
            14.0,
            15.0,
            16.0,
            17.0,
            18.0,
            19.0,
            20.0,
            21.0,
            22.0,
            23.0,
            24.0,
            25.0,
            26.0,
            27.0,
            28.0,
            29.0,
            30.0,
            31.0,
            32.0,
            33.0,
            34.0,
        ]
        LeapSecondDates = Lgm_CTrans.dateLongToDate(LeapSecondDates)
        LeapSecondDates = [
            val - datetime.timedelta(days=1) for val in LeapSecondDates
        ]
        LeapSecondDates = Lgm_CTrans.dateToDateLong(LeapSecondDates)

        for i, (v1, v2, v3) in enumerate(
                zip(LeapSecondDates, LeapSecondJDs, LeapSeconds)):
            self.assertEqual(v1, self.c.l.LeapSecondDates[i])
            self.assertEqual(v2, self.c.l.LeapSecondJDs[i])
            self.assertEqual(v3, self.c.l.LeapSeconds[i])