本文整理汇总了Python中matplotlib.testing.jpl_units.UnitDbl方法的典型用法代码示例。如果您正苦于以下问题:Python jpl_units.UnitDbl方法的具体用法?Python jpl_units.UnitDbl怎么用?Python jpl_units.UnitDbl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.testing.jpl_units
的用法示例。
在下文中一共展示了jpl_units.UnitDbl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: default_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def default_units( value, axis ):
""": Return the default unit for value, or None.
= INPUT VARIABLES
- value The value or list of values that need units.
= RETURN VALUE
- Returns the default units to use for value.
Return the default unit for value, or None.
"""
# Determine the default units based on the user preferences set for
# default units when printing a UnitDbl.
if ( iterable(value) and not isinstance(value, str) ):
return UnitDblConverter.default_units( value[0], axis )
else:
return UnitDblConverter.defaults[ value.type() ]
示例2: float2epoch
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def float2epoch( value, unit ):
""": Convert a matplotlib floating-point date into an Epoch of the
specified units.
= INPUT VARIABLES
- value The matplotlib floating-point date.
- unit The unit system to use for the Epoch.
= RETURN VALUE
- Returns the value converted to an Epoch in the sepcified time system.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
secPastRef = value * 86400.0 * U.UnitDbl( 1.0, 'sec' )
return U.Epoch( unit, secPastRef, EpochConverter.jdRef )
#------------------------------------------------------------------------
示例3: default_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def default_units( value, axis ):
""": Return the default unit for value, or None.
= INPUT VARIABLES
- value The value or list of values that need units.
= RETURN VALUE
- Returns the default units to use for value.
Return the default unit for value, or None.
"""
# Determine the default units based on the user preferences set for
# default units when printing a UnitDbl.
if ( iterable(value) and not isinstance(value, six.string_types) ):
return UnitDblConverter.default_units( value[0], axis )
else:
return UnitDblConverter.defaults[ value.type() ]
示例4: default_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def default_units(value, axis):
""": Return the default unit for value, or None.
= INPUT VARIABLES
- value The value or list of values that need units.
= RETURN VALUE
- Returns the default units to use for value.
Return the default unit for value, or None.
"""
# Determine the default units based on the user preferences set for
# default units when printing a UnitDbl.
if iterable(value) and not isinstance(value, str):
return UnitDblConverter.default_units(value[0], axis)
else:
return UnitDblConverter.defaults[value.type()]
示例5: float2epoch
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def float2epoch(value, unit):
""": Convert a matplotlib floating-point date into an Epoch of the
specified units.
= INPUT VARIABLES
- value The matplotlib floating-point date.
- unit The unit system to use for the Epoch.
= RETURN VALUE
- Returns the value converted to an Epoch in the specified time system.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
secPastRef = value * 86400.0 * U.UnitDbl(1.0, 'sec')
return U.Epoch(unit, secPastRef, EpochConverter.jdRef)
# -----------------------------------------------------------------------
示例6: default_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def default_units(value, axis):
""": Return the default unit for value, or None.
= INPUT VARIABLES
- value The value or list of values that need units.
= RETURN VALUE
- Returns the default units to use for value.
Return the default unit for value, or None.
"""
# Determine the default units based on the user preferences set for
# default units when printing a UnitDbl.
if np.iterable(value) and not isinstance(value, str):
return UnitDblConverter.default_units(value[0], axis)
else:
return UnitDblConverter.defaults[value.type()]
示例7: float2epoch
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def float2epoch(value, unit):
""": Convert a matplotlib floating-point date into an Epoch of the
specified units.
= INPUT VARIABLES
- value The matplotlib floating-point date.
- unit The unit system to use for the Epoch.
= RETURN VALUE
- Returns the value converted to an Epoch in the specified time system.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
secPastRef = value * 86400.0 * U.UnitDbl(1.0, 'sec')
return U.Epoch(unit, secPastRef, EpochConverter.jdRef)
示例8: float2epoch
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def float2epoch( value, unit ):
""": Convert a matplotlib floating-point date into an Epoch of the
specified units.
= INPUT VARIABLES
- value The matplotlib floating-point date.
- unit The unit system to use for the Epoch.
= RETURN VALUE
- Returns the value converted to an Epoch in the specified time system.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
secPastRef = value * 86400.0 * U.UnitDbl( 1.0, 'sec' )
return U.Epoch( unit, secPastRef, EpochConverter.jdRef )
#------------------------------------------------------------------------
示例9: axisinfo
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def axisinfo( unit, axis ):
""": Returns information on how to handle an axis that has Epoch data.
= INPUT VARIABLES
- unit The units to use for a axis with Epoch data.
= RETURN VALUE
- Returns a matplotlib AxisInfo data structure that contains
minor/major formatters, major/minor locators, and default
label information.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
# Check to see if the value used for units is a string unit value
# or an actual instance of a UnitDbl so that we can use the unit
# value for the default axis label value.
if ( unit ):
if ( isinstance( unit, str ) ):
label = unit
else:
label = unit.label()
else:
label = None
if ( label == "deg" ) and isinstance( axis.axes, polar.PolarAxes ):
# If we want degrees for a polar plot, use the PolarPlotFormatter
majfmt = polar.PolarAxes.ThetaFormatter()
else:
majfmt = U.UnitDblFormatter( useOffset = False )
return units.AxisInfo( majfmt = majfmt, label = label )
#------------------------------------------------------------------------
示例10: test_polar_units
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def test_polar_units():
import matplotlib.testing.jpl_units as units
from nose.tools import assert_true
units.register()
pi = np.pi
deg = units.UnitDbl(1.0, "deg")
km = units.UnitDbl(1.0, "km")
x1 = [pi/6.0, pi/4.0, pi/3.0, pi/2.0]
x2 = [30.0*deg, 45.0*deg, 60.0*deg, 90.0*deg]
y1 = [1.0, 2.0, 3.0, 4.0]
y2 = [4.0, 3.0, 2.0, 1.0]
fig = plt.figure()
plt.polar(x2, y1, color="blue")
# polar(x2, y1, color = "red", xunits="rad")
# polar(x2, y2, color = "green")
fig = plt.figure()
# make sure runits and theta units work
y1 = [y*km for y in y1]
plt.polar(x2, y1, color="blue", thetaunits="rad", runits="km")
assert_true(isinstance(plt.gca().get_xaxis().get_major_formatter(), units.UnitDblFormatter))
示例11: axisinfo
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def axisinfo( unit, axis ):
""": Returns information on how to handle an axis that has Epoch data.
= INPUT VARIABLES
- unit The units to use for a axis with Epoch data.
= RETURN VALUE
- Returns a matplotlib AxisInfo data structure that contains
minor/major formatters, major/minor locators, and default
label information.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
# Check to see if the value used for units is a string unit value
# or an actual instance of a UnitDbl so that we can use the unit
# value for the default axis label value.
if ( unit ):
if ( isinstance( unit, six.string_types ) ):
label = unit
else:
label = unit.label()
else:
label = None
if ( label == "deg" ) and isinstance( axis.axes, polar.PolarAxes ):
# If we want degrees for a polar plot, use the PolarPlotFormatter
majfmt = polar.PolarAxes.ThetaFormatter()
else:
majfmt = U.UnitDblFormatter( useOffset = False )
return units.AxisInfo( majfmt = majfmt, label = label )
#------------------------------------------------------------------------
示例12: axisinfo
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def axisinfo(unit, axis):
""": Returns information on how to handle an axis that has Epoch data.
= INPUT VARIABLES
- unit The units to use for a axis with Epoch data.
= RETURN VALUE
- Returns a matplotlib AxisInfo data structure that contains
minor/major formatters, major/minor locators, and default
label information.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
# Check to see if the value used for units is a string unit value
# or an actual instance of a UnitDbl so that we can use the unit
# value for the default axis label value.
if unit:
label = unit if isinstance(unit, str) else unit.label()
else:
label = None
if (label == "deg") and isinstance(axis.axes, polar.PolarAxes):
# If we want degrees for a polar plot, use the PolarPlotFormatter
majfmt = polar.PolarAxes.ThetaFormatter()
else:
majfmt = U.UnitDblFormatter(useOffset=False)
return units.AxisInfo(majfmt=majfmt, label=label)
# -----------------------------------------------------------------------
示例13: axisinfo
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [as 别名]
def axisinfo(unit, axis):
""": Returns information on how to handle an axis that has Epoch data.
= INPUT VARIABLES
- unit The units to use for a axis with Epoch data.
= RETURN VALUE
- Returns a matplotlib AxisInfo data structure that contains
minor/major formatters, major/minor locators, and default
label information.
"""
# Delay-load due to circular dependencies.
import matplotlib.testing.jpl_units as U
# Check to see if the value used for units is a string unit value
# or an actual instance of a UnitDbl so that we can use the unit
# value for the default axis label value.
if unit:
label = unit if isinstance(unit, str) else unit.label()
else:
label = None
if label == "deg" and isinstance(axis.axes, polar.PolarAxes):
# If we want degrees for a polar plot, use the PolarPlotFormatter
majfmt = polar.PolarAxes.ThetaFormatter()
else:
majfmt = U.UnitDblFormatter(useOffset=False)
return units.AxisInfo(majfmt=majfmt, label=label)
示例14: convert
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [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 a 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
isNotUnitDbl = True
if ( iterable(value) and not isinstance(value, str) ):
if ( len(value) == 0 ):
return []
else:
return [ UnitDblConverter.convert( x, unit, axis ) for x in value ]
# We need to check to see if the incoming value is actually a UnitDbl and
# set a flag. If we get an empty list, then just return an empty list.
if ( isinstance(value, U.UnitDbl) ):
isNotUnitDbl = False
# If the incoming value behaves like a number, but is not a UnitDbl,
# then just return it because we don't know how to convert it
# (or it is already converted)
if ( isNotUnitDbl and units.ConversionInterface.is_numlike( value ) ):
return value
# If no units were specified, then get the default units to use.
if ( unit == None ):
unit = UnitDblConverter.default_units( value, axis )
# Convert the incoming UnitDbl value/values to float/floats
if isinstance( axis.axes, polar.PolarAxes ) and (value.type() == "angle"):
# Guarantee that units are radians for polar plots.
return value.convert( "rad" )
return value.convert( unit )
#------------------------------------------------------------------------
示例15: convert
# 需要导入模块: from matplotlib.testing import jpl_units [as 别名]
# 或者: from matplotlib.testing.jpl_units import UnitDbl [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 a 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
isNotUnitDbl = True
if ( iterable(value) and not isinstance(value, six.string_types) ):
if ( len(value) == 0 ):
return []
else:
return [ UnitDblConverter.convert( x, unit, axis ) for x in value ]
# We need to check to see if the incoming value is actually a UnitDbl and
# set a flag. If we get an empty list, then just return an empty list.
if ( isinstance(value, U.UnitDbl) ):
isNotUnitDbl = False
# If the incoming value behaves like a number, but is not a UnitDbl,
# then just return it because we don't know how to convert it
# (or it is already converted)
if ( isNotUnitDbl and units.ConversionInterface.is_numlike( value ) ):
return value
# If no units were specified, then get the default units to use.
if ( unit == None ):
unit = UnitDblConverter.default_units( value, axis )
# Convert the incoming UnitDbl value/values to float/floats
if isinstance( axis.axes, polar.PolarAxes ) and (value.type() == "angle"):
# Guarantee that units are radians for polar plots.
return value.convert( "rad" )
return value.convert( unit )
#------------------------------------------------------------------------