本文整理汇总了Python中matplotlib.dates.UTC属性的典型用法代码示例。如果您正苦于以下问题:Python dates.UTC属性的具体用法?Python dates.UTC怎么用?Python dates.UTC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类matplotlib.dates
的用法示例。
在下文中一共展示了dates.UTC属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test_date2num_dst
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def _test_date2num_dst(date_range, tz_convert):
# Timezones
BRUSSELS = dateutil.tz.gettz('Europe/Brussels')
UTC = mdates.UTC
# Create a list of timezone-aware datetime objects in UTC
# Interval is 0b0.0000011 days, to prevent float rounding issues
dtstart = datetime.datetime(2014, 3, 30, 0, 0, tzinfo=UTC)
interval = datetime.timedelta(minutes=33, seconds=45)
interval_days = 0.0234375 # 2025 / 86400 seconds
N = 8
dt_utc = date_range(start=dtstart, freq=interval, periods=N)
dt_bxl = tz_convert(dt_utc, BRUSSELS)
expected_ordinalf = [735322.0 + (i * interval_days) for i in range(N)]
actual_ordinalf = list(mdates.date2num(dt_bxl))
assert actual_ordinalf == expected_ordinalf
示例2: _test_date2num_dst
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def _test_date2num_dst(date_range, tz_convert):
# Timezones
BRUSSELS = pytz.timezone('Europe/Brussels')
UTC = pytz.UTC
# Create a list of timezone-aware datetime objects in UTC
# Interval is 0b0.0000011 days, to prevent float rounding issues
dtstart = datetime.datetime(2014, 3, 30, 0, 0, tzinfo=UTC)
interval = datetime.timedelta(minutes=33, seconds=45)
interval_days = 0.0234375 # 2025 / 86400 seconds
N = 8
dt_utc = date_range(start=dtstart, freq=interval, periods=N)
dt_bxl = tz_convert(dt_utc, BRUSSELS)
expected_ordinalf = [735322.0 + (i * interval_days) for i in range(N)]
actual_ordinalf = list(mdates.date2num(dt_bxl))
assert actual_ordinalf == expected_ordinalf
示例3: _dt_to_float_ordinal
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def _dt_to_float_ordinal(dt):
"""
Convert :mod:`datetime` to the Gregorian date as UTC float days,
preserving hours, minutes, seconds and microseconds. Return value
is a :func:`float`.
"""
if (isinstance(dt, (np.ndarray, Index, ABCSeries)
) and is_datetime64_ns_dtype(dt)):
base = dates.epoch2num(dt.asi8 / 1.0E9)
else:
base = dates.date2num(dt)
return base
# Datetime Conversion
示例4: __init__
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
dates.AutoDateFormatter.__init__(self, locator, tz, defaultfmt)
# matplotlib.dates._UTC has no _utcoffset called by pandas
if self._tz is dates.UTC:
self._tz._utcoffset = self._tz.utcoffset(None)
示例5: __init__
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
dates.AutoDateFormatter.__init__(self, locator, tz, defaultfmt)
# matplotlib.dates._UTC has no _utcoffset called by pandas
if self._tz is dates.UTC:
self._tz._utcoffset = self._tz.utcoffset(None)
# For mpl > 2.0 the format strings are controlled via rcparams
# so do not mess with them. For mpl < 2.0 change the second
# break point and add a musec break point
if _mpl_le_2_0_0():
self.scaled[1. / SEC_PER_DAY] = '%H:%M:%S'
self.scaled[1. / MUSEC_PER_DAY] = '%H:%M:%S.%f'
示例6: _dt_to_float_ordinal
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def _dt_to_float_ordinal(dt):
"""
Convert :mod:`datetime` to the Gregorian date as UTC float days,
preserving hours, minutes, seconds and microseconds. Return value
is a :func:`float`.
"""
base = dates.date2num(dt)
return base
### Datetime Conversion
示例7: __init__
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
dates.AutoDateFormatter.__init__(self, locator, tz, defaultfmt)
# matplotlib.dates._UTC has no _utcoffset called by pandas
if self._tz is dates.UTC:
self._tz._utcoffset = self._tz.utcoffset(None)
self.scaled = {
365.0: '%Y',
30.: '%b %Y',
1.0: '%b %d %Y',
1. / 24.: '%H:%M:%S',
1. / 24. / 3600. / 1000.: '%H:%M:%S.%f'
}
示例8: test_drange
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def test_drange():
"""
This test should check if drange works as expected, and if all the
rounding errors are fixed
"""
start = datetime.datetime(2011, 1, 1, tzinfo=mdates.UTC)
end = datetime.datetime(2011, 1, 2, tzinfo=mdates.UTC)
delta = datetime.timedelta(hours=1)
# We expect 24 values in drange(start, end, delta), because drange returns
# dates from an half open interval [start, end)
assert_equal(24, len(mdates.drange(start, end, delta)))
# if end is a little bit later, we expect the range to contain one element
# more
end = end + datetime.timedelta(microseconds=1)
assert_equal(25, len(mdates.drange(start, end, delta)))
# reset end
end = datetime.datetime(2011, 1, 2, tzinfo=mdates.UTC)
# and tst drange with "complicated" floats:
# 4 hours = 1/6 day, this is an "dangerous" float
delta = datetime.timedelta(hours=4)
daterange = mdates.drange(start, end, delta)
assert_equal(6, len(daterange))
assert_equal(mdates.num2date(daterange[-1]), end - delta)
示例9: test_RRuleLocator_dayrange
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def test_RRuleLocator_dayrange():
loc = mdates.DayLocator()
x1 = datetime.datetime(year=1, month=1, day=1, tzinfo=mdates.UTC)
y1 = datetime.datetime(year=1, month=1, day=16, tzinfo=mdates.UTC)
loc.tick_values(x1, y1)
# On success, no overflow error shall be thrown
示例10: test_drange
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def test_drange():
"""
This test should check if drange works as expected, and if all the
rounding errors are fixed
"""
start = datetime.datetime(2011, 1, 1, tzinfo=mdates.UTC)
end = datetime.datetime(2011, 1, 2, tzinfo=mdates.UTC)
delta = datetime.timedelta(hours=1)
# We expect 24 values in drange(start, end, delta), because drange returns
# dates from an half open interval [start, end)
assert len(mdates.drange(start, end, delta)) == 24
# if end is a little bit later, we expect the range to contain one element
# more
end = end + datetime.timedelta(microseconds=1)
assert len(mdates.drange(start, end, delta)) == 25
# reset end
end = datetime.datetime(2011, 1, 2, tzinfo=mdates.UTC)
# and tst drange with "complicated" floats:
# 4 hours = 1/6 day, this is an "dangerous" float
delta = datetime.timedelta(hours=4)
daterange = mdates.drange(start, end, delta)
assert len(daterange) == 6
assert mdates.num2date(daterange[-1]) == (end - delta)
示例11: test_tz_utc
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def test_tz_utc():
dt = datetime.datetime(1970, 1, 1, tzinfo=mdates.UTC)
dt.tzname()
示例12: test_RRuleLocator_dayrange
# 需要导入模块: from matplotlib import dates [as 别名]
# 或者: from matplotlib.dates import UTC [as 别名]
def test_RRuleLocator_dayrange():
loc = mdates.DayLocator()
x1 = datetime.datetime(year=1, month=1, day=1, tzinfo=pytz.UTC)
y1 = datetime.datetime(year=1, month=1, day=16, tzinfo=pytz.UTC)
loc.tick_values(x1, y1)
# On success, no overflow error shall be thrown