Example #1
0
 def test_gregorian_calendar(self):
     unit = Unit('hours since 2000-04-13 00:00:00', calendar='gregorian')
     coord = AuxCoord([1, 3, 6], 'time', units=unit)
     result = _fixup_dates(coord, coord.points)
     expected = [datetime.datetime(2000, 4, 13, 1),
                 datetime.datetime(2000, 4, 13, 3),
                 datetime.datetime(2000, 4, 13, 6)]
     self.assertArrayEqual(result, expected)
Example #2
0
 def test_gregorian_calendar_sub_second(self):
     unit = Unit('seconds since 2000-04-13 00:00:00', calendar='gregorian')
     coord = AuxCoord([1, 1.25, 1.5], 'time', units=unit)
     result = _fixup_dates(coord, coord.points)
     expected = [datetime.datetime(2000, 4, 13, 0, 0, 1),
                 datetime.datetime(2000, 4, 13, 0, 0, 1),
                 datetime.datetime(2000, 4, 13, 0, 0, 2)]
     self.assertArrayEqual(result, expected)
Example #3
0
 def test_365_day_calendar(self):
     unit = Unit('minutes since 2000-02-25 00:00:00', calendar='365_day')
     coord = AuxCoord([30, 60, 150], 'time', units=unit)
     result = _fixup_dates(coord, coord.points)
     expected_datetimes = [cftime.datetime(2000, 2, 25, 0, 30),
                           cftime.datetime(2000, 2, 25, 1, 0),
                           cftime.datetime(2000, 2, 25, 2, 30)]
     self.assertArrayEqual([cdt.datetime for cdt in result],
                           expected_datetimes)
Example #4
0
 def test_360_day_calendar(self):
     unit = Unit('days since 2000-02-25 00:00:00', calendar='360_day')
     coord = AuxCoord([3, 4, 5], 'time', units=unit)
     result = _fixup_dates(coord, coord.points)
     expected_datetimes = [netcdftime.datetime(2000, 2, 28),
                           netcdftime.datetime(2000, 2, 29),
                           netcdftime.datetime(2000, 2, 30)]
     self.assertArrayEqual([cdt.datetime for cdt in result],
                           expected_datetimes)
Example #5
0
 def test_gregorian_calendar(self):
     unit = Unit("hours since 2000-04-13 00:00:00", calendar="gregorian")
     coord = AuxCoord([1, 3, 6], "time", units=unit)
     result = _fixup_dates(coord, coord.points)
     expected = [
         datetime.datetime(2000, 4, 13, 1),
         datetime.datetime(2000, 4, 13, 3),
         datetime.datetime(2000, 4, 13, 6),
     ]
     self.assertArrayEqual(result, expected)
Example #6
0
 def test_gregorian_calendar_sub_second(self):
     unit = Unit("seconds since 2000-04-13 00:00:00", calendar="gregorian")
     coord = AuxCoord([1, 1.25, 1.5], "time", units=unit)
     result = _fixup_dates(coord, coord.points)
     expected = [
         datetime.datetime(2000, 4, 13, 0, 0, 1),
         datetime.datetime(2000, 4, 13, 0, 0, 1),
         datetime.datetime(2000, 4, 13, 0, 0, 2),
     ]
     self.assertArrayEqual(result, expected)
Example #7
0
 def test_365_day_calendar(self):
     unit = Unit("minutes since 2000-02-25 00:00:00", calendar="365_day")
     coord = AuxCoord([30, 60, 150], "time", units=unit)
     result = _fixup_dates(coord, coord.points)
     expected_datetimes = [
         cftime.datetime(2000, 2, 25, 0, 30),
         cftime.datetime(2000, 2, 25, 1, 0),
         cftime.datetime(2000, 2, 25, 2, 30),
     ]
     self.assertArrayEqual([cdt.datetime for cdt in result],
                           expected_datetimes)
Example #8
0
 def test_360_day_calendar(self):
     unit = Unit('days since 2000-02-25 00:00:00', calendar='360_day')
     coord = AuxCoord([3, 4, 5], 'time', units=unit)
     result = _fixup_dates(coord, coord.points)
     expected_datetimes = [
         cftime.datetime(2000, 2, 28),
         cftime.datetime(2000, 2, 29),
         cftime.datetime(2000, 2, 30)
     ]
     self.assertArrayEqual([cdt.datetime for cdt in result],
                           expected_datetimes)
Example #9
0
 def test_360_day_calendar(self):
     calendar = "360_day"
     unit = Unit("days since 2000-02-25 00:00:00", calendar=calendar)
     coord = AuxCoord([3, 4, 5], "time", units=unit)
     result = _fixup_dates(coord, coord.points)
     expected_datetimes = [
         cftime.datetime(2000, 2, 28, calendar=calendar),
         cftime.datetime(2000, 2, 29, calendar=calendar),
         cftime.datetime(2000, 2, 30, calendar=calendar),
     ]
     self.assertArrayEqual(result, expected_datetimes)
Example #10
0
 def test_365_day_calendar(self):
     unit = Unit('minutes since 2000-02-25 00:00:00', calendar='365_day')
     coord = AuxCoord([30, 60, 150], 'time', units=unit)
     result = _fixup_dates(coord, coord.points)
     expected_datetimes = [
         netcdftime.datetime(2000, 2, 25, 0, 30),
         netcdftime.datetime(2000, 2, 25, 1, 0),
         netcdftime.datetime(2000, 2, 25, 2, 30)
     ]
     self.assertArrayEqual([cdt.datetime for cdt in result],
                           expected_datetimes)
Example #11
0
 def test_360_day_calendar_attribute(self):
     calendar = "360_day"
     unit = Unit("days since 2000-02-01 00:00:00", calendar=calendar)
     coord = AuxCoord([0, 3, 6], "time", units=unit)
     result = _fixup_dates(coord, coord.points)
     self.assertEqual(result[0].calendar, calendar)
Example #12
0
 def test_360_day_calendar_attribute(self):
     unit = Unit('days since 2000-02-01 00:00:00', calendar='360_day')
     coord = AuxCoord([0, 3, 6], 'time', units=unit)
     result = _fixup_dates(coord, coord.points)
     self.assertEqual(result[0].calendar, '360_day')
Example #13
0
 def test_360_day_calendar_attribute(self):
     unit = Unit('days since 2000-02-01 00:00:00', calendar='360_day')
     coord = AuxCoord([0, 3, 6], 'time', units=unit)
     result = _fixup_dates(coord, coord.points)
     self.assertEqual(result[0].calendar, '360_day')