本文整理匯總了Python中cf_units.Unit.num2date方法的典型用法代碼示例。如果您正苦於以下問題:Python Unit.num2date方法的具體用法?Python Unit.num2date怎麽用?Python Unit.num2date使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf_units.Unit
的用法示例。
在下文中一共展示了Unit.num2date方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _convert_coord_unit_to_datetime
# 需要導入模塊: from cf_units import Unit [as 別名]
# 或者: from cf_units.Unit import num2date [as 別名]
def _convert_coord_unit_to_datetime(coord, dt):
"""Converts a datetime to be in the unit of a specified Coord.
"""
if isinstance(coord, iris.coords.Coord):
# The unit class is then cf_units.Unit.
iris_unit = coord.units
else:
iris_unit = Unit(coord.units)
return iris_unit.num2date(dt)
示例2: test_360_day_calendar
# 需要導入模塊: from cf_units import Unit [as 別名]
# 或者: from cf_units.Unit import num2date [as 別名]
def test_360_day_calendar(self):
n = 360
calendar = '360_day'
time_unit = Unit('days since 1970-01-01 00:00', calendar=calendar)
time_coord = AuxCoord(np.arange(n), 'time', units=time_unit)
expected_ydata = np.array([CalendarDateTime(time_unit.num2date(point),
calendar)
for point in time_coord.points])
line1, = iplt.plot(time_coord)
result_ydata = line1.get_ydata()
self.assertArrayEqual(expected_ydata, result_ydata)
示例3: test_360_day_calendar
# 需要導入模塊: from cf_units import Unit [as 別名]
# 或者: from cf_units.Unit import num2date [as 別名]
def test_360_day_calendar(self):
n = 360
calendar = '360_day'
time_unit = Unit('days since 1970-01-01 00:00', calendar=calendar)
time_coord = AuxCoord(np.arange(n), 'time', units=time_unit)
times = [time_unit.num2date(point) for point in time_coord.points]
times = [netcdftime.datetime(atime.year, atime.month, atime.day,
atime.hour, atime.minute, atime.second)
for atime in times]
expected_ydata = np.array([CalendarDateTime(time, calendar)
for time in times])
line1, = iplt.plot(time_coord)
result_ydata = line1.get_ydata()
self.assertArrayEqual(expected_ydata, result_ydata)