本文整理汇总了Python中astropy.units.Unit.to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Unit.to_string方法的具体用法?Python Unit.to_string怎么用?Python Unit.to_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.units.Unit
的用法示例。
在下文中一共展示了Unit.to_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: units_to_fits
# 需要导入模块: from astropy.units import Unit [as 别名]
# 或者: from astropy.units.Unit import to_string [as 别名]
def units_to_fits(unit):
""" Convert an astropy unit to a FITS format string.
uses the to_string() method built-in to astropy Unit()
Notes
-----
The output will be the format defined in the FITS standard:
http://fits.gsfc.nasa.gov/fits_standard.html
A roundtrip from fits_to_units -> units_to_fits may not return
the original string, as people often don't follow the standard.
"""
if unit is None:
unit = Unit('')
return unit.to_string("fits").upper()
示例2: to_tree
# 需要导入模块: from astropy.units import Unit [as 别名]
# 或者: from astropy.units.Unit import to_string [as 别名]
def to_tree(cls, node, ctx):
if isinstance(node, six.string_types):
node = Unit(node, format='vounit', parse_strict='warn')
if isinstance(node, UnitBase):
return node.to_string(format='vounit')
raise TypeError("'{0}' is not a valid unit".format(node))