Пример #1
0
    def _contains_point(self, point, unit):
        point_dt = unit.num2date(point)
        point_yday = self._day_of_year(point_dt)

        start_dt = netcdftime.datetime(point_dt.year, *self.day_of_year[0])
        start_dt = _fix_netcdftime_datetime(start_dt, unit)
        start_yday = self._day_of_year(start_dt)

        end_dt = netcdftime.datetime(point_dt.year, *self.day_of_year[1])
        end_dt = _fix_netcdftime_datetime(end_dt, unit)
        end_yday = self._day_of_year(end_dt)

        if start_yday < end_yday:
            result = start_yday <= point_yday <= end_yday
        elif start_yday > end_yday:
            result = point_yday >= start_yday or point_yday <= end_yday
        else:
            raise ValueError('start_yday == end_yday')
        return result
 def test_360(self):
     dt = netcdftime.datetime(2000, 12, 30)
     unit = iris.unit.Unit('days since 2000-01-01',
                           calendar=iris.unit.CALENDAR_360_DAY)
     self.assertEqual(_fix_netcdftime_datetime(dt, unit).dayofyr, 360)
Пример #3
0
 def test_360(self):
     dt = netcdftime.datetime(2000, 12, 30)
     unit = iris.unit.Unit('days since 2000-01-01',
                           calendar=iris.unit.CALENDAR_360_DAY)
     self.assertEqual(_fix_netcdftime_datetime(dt, unit).dayofyr, 360)
 def test_greg_leap(self):
     dt = netcdftime.datetime(2000, 12, 31)
     unit = iris.unit.Unit('days since 2000-01-01',
                           calendar=iris.unit.CALENDAR_GREGORIAN)
     day_of_year = _fix_netcdftime_datetime(dt, unit).timetuple().tm_yday
     self.assertEqual(day_of_year, 366)
Пример #5
0
 def test_greg_leap(self):
     dt = netcdftime.datetime(2000, 12, 31)
     unit = iris.unit.Unit('days since 2000-01-01',
                           calendar=iris.unit.CALENDAR_GREGORIAN)
     day_of_year = _fix_netcdftime_datetime(dt, unit).timetuple().tm_yday
     self.assertEqual(day_of_year, 366)