本文整理汇总了Python中matplotlib.testing.jpl_units.Duration方法的典型用法代码示例。如果您正苦于以下问题:Python jpl_units.Duration方法的具体用法?Python jpl_units.Duration怎么用?Python jpl_units.Duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.testing.jpl_units
的用法示例。
在下文中一共展示了jpl_units.Duration方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_axvspan_epoch
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def test_axvspan_epoch():
from datetime import datetime
import matplotlib.testing.jpl_units as units
units.register()
# generate some data
t0 = units.Epoch("ET", dt=datetime(2009, 1, 20))
tf = units.Epoch("ET", dt=datetime(2009, 1, 21))
dt = units.Duration("ET", units.day.convert("sec"))
fig = plt.figure()
plt.axvspan(t0, tf, facecolor="blue", alpha=0.25)
ax = plt.gca()
ax.set_xlim(t0 - 5.0*dt, tf + 5.0*dt)
示例2: test_axhspan_epoch
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def test_axhspan_epoch():
from datetime import datetime
import matplotlib.testing.jpl_units as units
units.register()
# generate some data
t0 = units.Epoch("ET", dt=datetime(2009, 1, 20))
tf = units.Epoch("ET", dt=datetime(2009, 1, 21))
dt = units.Duration("ET", units.day.convert("sec"))
fig = plt.figure()
plt.axhspan(t0, tf, facecolor="blue", alpha=0.25)
ax = plt.gca()
ax.set_ylim(t0 - 5.0*dt, tf + 5.0*dt)
示例3: __sub__
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def __sub__( self, rhs ):
"""Subtract two Epoch's or a Duration from an Epoch.
Valid:
Duration = Epoch - Epoch
Epoch = Epoch - Duration
= INPUT VARIABLES
- rhs The Epoch to subtract.
= RETURN VALUE
- Returns either the duration between to Epoch's or the a new
Epoch that is the result of subtracting a duration from an epoch.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
# Handle Epoch - Duration
if isinstance( rhs, U.Duration ):
return self + -rhs
t = self
if self._frame != rhs._frame:
t = self.convert( rhs._frame )
days = t._jd - rhs._jd
sec = t._seconds - rhs._seconds
return U.Duration( rhs._frame, days*86400 + sec )
#-----------------------------------------------------------------------
示例4: duration2float
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def duration2float( value ):
""": Convert a Duration value to a float suitible for plotting as a
python datetime object.
= INPUT VARIABLES
- value A Duration or list of Durations that need to be converted.
= RETURN VALUE
- Returns the value parameter converted to floats.
"""
return value.days()
#------------------------------------------------------------------------
示例5: convert
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def convert( value, unit, axis ):
""": Convert value using unit to a float. If value is a sequence, return
the converted sequence.
= INPUT VARIABLES
- value The value or list of values that need to be converted.
- unit The units to use for an axis with Epoch data.
= RETURN VALUE
- Returns the value parameter converted to floats.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
isNotEpoch = True
isDuration = False
if ( iterable(value) and not isinstance(value, str) ):
if ( len(value) == 0 ):
return []
else:
return [ EpochConverter.convert( x, unit, axis ) for x in value ]
if ( isinstance(value, U.Epoch) ):
isNotEpoch = False
elif ( isinstance(value, U.Duration) ):
isDuration = True
if ( isNotEpoch and not isDuration and
units.ConversionInterface.is_numlike( value ) ):
return value
if ( unit == None ):
unit = EpochConverter.default_units( value, axis )
if ( isDuration ):
return EpochConverter.duration2float( value )
else:
return EpochConverter.epoch2float( value, unit )
#------------------------------------------------------------------------
示例6: test_fill_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def test_fill_units():
from datetime import datetime
import matplotlib.testing.jpl_units as units
units.register()
# generate some data
t = units.Epoch("ET", dt=datetime(2009, 4, 27))
value = 10.0 * units.deg
day = units.Duration("ET", 24.0 * 60.0 * 60.0)
fig = plt.figure()
# Top-Left
ax1 = fig.add_subplot(221)
ax1.plot([t], [value], yunits='deg', color='red')
ax1.fill([733525.0, 733525.0, 733526.0, 733526.0],
[0.0, 0.0, 90.0, 0.0], 'b')
# Top-Right
ax2 = fig.add_subplot(222)
ax2.plot([t], [value], yunits='deg', color='red')
ax2.fill([t, t, t+day, t+day],
[0.0, 0.0, 90.0, 0.0], 'b')
# Bottom-Left
ax3 = fig.add_subplot(223)
ax3.plot([t], [value], yunits='deg', color='red')
ax3.fill([733525.0, 733525.0, 733526.0, 733526.0],
[0*units.deg, 0*units.deg, 90*units.deg, 0*units.deg], 'b')
# Bottom-Right
ax4 = fig.add_subplot(224)
ax4.plot([t], [value], yunits='deg', color='red')
ax4.fill([t, t, t+day, t+day],
[0*units.deg, 0*units.deg, 90*units.deg, 0*units.deg],
facecolor="blue")
fig.autofmt_xdate()
示例7: __sub__
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def __sub__(self, rhs):
"""Subtract two Epoch's or a Duration from an Epoch.
Valid:
Duration = Epoch - Epoch
Epoch = Epoch - Duration
= INPUT VARIABLES
- rhs The Epoch to subtract.
= RETURN VALUE
- Returns either the duration between to Epoch's or the a new
Epoch that is the result of subtracting a duration from an epoch.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
# Handle Epoch - Duration
if isinstance(rhs, U.Duration):
return self + -rhs
t = self
if self._frame != rhs._frame:
t = self.convert(rhs._frame)
days = t._jd - rhs._jd
sec = t._seconds - rhs._seconds
return U.Duration(rhs._frame, days*86400 + sec)
# -----------------------------------------------------------------------
示例8: duration2float
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def duration2float(value):
""": Convert a Duration value to a float suitible for plotting as a
python datetime object.
= INPUT VARIABLES
- value A Duration or list of Durations that need to be converted.
= RETURN VALUE
- Returns the value parameter converted to floats.
"""
return value.seconds() / 86400.0
# -----------------------------------------------------------------------
示例9: convert
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def convert(value, unit, axis):
""": Convert value using unit to a float. If value is a sequence, return
the converted sequence.
= INPUT VARIABLES
- value The value or list of values that need to be converted.
- unit The units to use for an axis with Epoch data.
= RETURN VALUE
- Returns the value parameter converted to floats.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
isNotEpoch = True
isDuration = False
if iterable(value) and not isinstance(value, str):
if len(value) == 0:
return []
else:
return [EpochConverter.convert(x, unit, axis) for x in value]
if isinstance(value, U.Epoch):
isNotEpoch = False
elif isinstance(value, U.Duration):
isDuration = True
if (isNotEpoch and not isDuration and
units.ConversionInterface.is_numlike(value)):
return value
if unit is None:
unit = EpochConverter.default_units(value, axis)
if isDuration:
return EpochConverter.duration2float(value)
else:
return EpochConverter.epoch2float(value, unit)
# -----------------------------------------------------------------------
示例10: test_fill_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def test_fill_units():
from datetime import datetime
import matplotlib.testing.jpl_units as units
units.register()
# generate some data
t = units.Epoch("ET", dt=datetime(2009, 4, 27))
value = 10.0 * units.deg
day = units.Duration("ET", 24.0 * 60.0 * 60.0)
fig = plt.figure()
# Top-Left
ax1 = fig.add_subplot(221)
ax1.plot([t], [value], yunits='deg', color='red')
ax1.fill([733525.0, 733525.0, 733526.0, 733526.0],
[0.0, 0.0, 90.0, 0.0], 'b')
# Top-Right
ax2 = fig.add_subplot(222)
ax2.plot([t], [value], yunits='deg', color='red')
ax2.fill([t, t, t + day, t + day],
[0.0, 0.0, 90.0, 0.0], 'b')
# Bottom-Left
ax3 = fig.add_subplot(223)
ax3.plot([t], [value], yunits='deg', color='red')
ax3.fill([733525.0, 733525.0, 733526.0, 733526.0],
[0 * units.deg, 0 * units.deg, 90 * units.deg, 0 * units.deg],
'b')
# Bottom-Right
ax4 = fig.add_subplot(224)
ax4.plot([t], [value], yunits='deg', color='red')
ax4.fill([t, t, t + day, t + day],
[0 * units.deg, 0 * units.deg, 90 * units.deg, 0 * units.deg],
facecolor="blue")
fig.autofmt_xdate()
示例11: test_jpl_bar_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def test_jpl_bar_units():
from datetime import datetime
import matplotlib.testing.jpl_units as units
units.register()
day = units.Duration("ET", 24.0 * 60.0 * 60.0)
x = [0*units.km, 1*units.km, 2*units.km]
w = [1*day, 2*day, 3*day]
b = units.Epoch("ET", dt=datetime(2009, 4, 25))
fig, ax = plt.subplots()
ax.bar(x, w, bottom=b)
ax.set_ylim([b-1*day, b+w[-1]+1*day])
示例12: test_jpl_barh_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import Duration [as 别名]
def test_jpl_barh_units():
from datetime import datetime
import matplotlib.testing.jpl_units as units
units.register()
day = units.Duration("ET", 24.0 * 60.0 * 60.0)
x = [0*units.km, 1*units.km, 2*units.km]
w = [1*day, 2*day, 3*day]
b = units.Epoch("ET", dt=datetime(2009, 4, 25))
fig, ax = plt.subplots()
ax.barh(x, w, left=b)
ax.set_xlim([b-1*day, b+w[-1]+1*day])