本文整理匯總了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))