本文整理汇总了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)