VOUnit#
- class astropy.units.format.VOUnit(*args, **kwargs)[source]#
Bases:
FITS
The IVOA standard for units used by the VO.
This is an implementation of Units in the VO 1.0.
Attributes Summary
Methods Summary
format_exponential_notation
(val[, format_spec])Formats a value in exponential notation.
parse
(s[, debug])Convert a string to a unit object.
to_string
(unit[, fraction])Convert a unit to its string representation.
Attributes Documentation
- name: ClassVar[str] = 'vounit'#
Methods Documentation
- classmethod format_exponential_notation(val: float | np.number, format_spec: str = '.8g') str [source]#
Formats a value in exponential notation.
- Parameters:
- valnumber
The value to be formatted
- format_spec
python:str
, optional Format used to split up mantissa and exponent
- Returns:
python:str
The value in exponential notation in a this class’s format.
- classmethod parse(s: str, debug: bool = False) UnitBase [source]#
Convert a string to a unit object.
- classmethod to_string(unit: UnitBase, fraction: bool | Literal['inline'] = False) str [source]#
Convert a unit to its string representation.
Implementation for
to_string
.- Parameters:
- unit|Unit|
The unit to convert.
- fraction{False|True|’inline’|’multiline’}, optional
Options are as follows:
False
: display unit bases with negative powers as they are (e.g.,km s-1
);‘inline’ or
True
: use a single-line fraction (e.g.,km / s
);‘multiline’ : use a multiline fraction (available for the
latex
,console
andunicode
formats only; e.g.,$\mathrm{\frac{km}{s}}$
).
- Raises:
ValueError
If
fraction
is not recognized.