VOUnit#

class astropy.units.format.VOUnit(*args, **kwargs)[源代码]#

基类:Base, _GenericParserMixin

VO使用的单位的IVOA标准。

这是实现 Units in the VO 1.0 .

属性摘要

name 

方法总结

format_exponential_notation(val[, format_spec])

将值格式化为指数表示法。

parse(s[, debug])

将字符串转换为单位对象。

to_string(unit[, fraction])

将单位转换为其字符串表示形式。

属性文档

name: ClassVar[str] = 'vounit'#

方法文件

classmethod format_exponential_notation(val: UnitScale | np.number, format_spec: str = '.8g') str[源代码]#

将值格式化为指数表示法。

参数:
val : number

要格式化的值

format_spec : str ,可选Python:字符串,可选

用于拆分尾数和指数的格式

返回:
str

此类格式的指数表示法中的值。

classmethod parse(s: str, debug: bool = False) UnitBase[源代码]#

将字符串转换为单位对象。

classmethod to_string(unit: UnitBase, fraction: bool | Literal['inline', 'multiline'] = False) str[源代码]#

将单位转换为其字符串表示形式。

实施 to_string

参数:
unitUnitBase单位

要转换的单位。

fraction{False|True|'inline'|'multiline'}, optional

选项如下:

  • False :原样具有负功率的显示单元底座(例如, km s-1 );

  • ‘inline’或 True :使用单行分数(例如, km / s );

  • “多行”:如果可能的话使用多行分数(适用于 latex , consoleunicode 格式;例如, $\mathrm{\frac{km}{s}}$ ).如果不可能,请使用“inline”。

加薪:
ValueError

如果 fraction 不被识别。