Bases: object
Abstract base class for function units.
Function units are functions containing a physical unit, such as dB(mW). Most of the arithmetic operations on function units are defined in this base class.
While instantiation is defined, this class should not be used directly. Rather, subclasses should be used that override the abstract properties _default_function_unit and _quantity_class, and the abstract methods from_physical, and to_physical.
Parameters: | physical_unit : Unit or string
function_unit : Unit or string
|
---|
Attributes Summary
cgs | Copy the current function unit with the physical unit in CGS. |
equivalencies | List of equivalencies between physical and function units. |
function_unit | |
physical_type | Return the physical type of the physical unit (e.g., ‘length’). |
physical_unit | |
si | Copy the current function unit with the physical unit in SI. |
Methods Summary
decompose([bases]) | Copy the current unit with the physical unit decomposed. |
from_physical(x) | Transformation from value in physical to value in function units. |
is_equivalent(other[, equivalencies]) | Returns True if this unit is equivalent to other. |
is_unity() | |
to(other[, value, equivalencies]) | Return the converted values in the specified unit. |
to_physical(x) | Transformation from value in function to value in physical units. |
to_string([format]) | Output the unit in the given format as a string. |
Attributes Documentation
Copy the current function unit with the physical unit in CGS.
List of equivalencies between physical and function units.
Uses the from_physical and to_physical methods.
Return the physical type of the physical unit (e.g., ‘length’).
Copy the current function unit with the physical unit in SI.
Methods Documentation
Copy the current unit with the physical unit decomposed.
For details, see decompose.
Transformation from value in physical to value in function units.
This method should be overridden by subclasses. It is used to provide automatic transformations using an equivalency.
Returns True if this unit is equivalent to other.
Parameters: | other : unit object or string or tuple
equivalencies : list of equivalence pairs, optional
|
---|---|
Returns: | bool |
Return the converted values in the specified unit.
Parameters: | other : Unit object, FunctionUnitBase object or string
value : scalar int or float, or sequence convertible to array, optional
equivalencies : list of equivalence pairs, optional
|
---|---|
Returns: | values : scalar or array
|
Raises: | UnitsError
|
Transformation from value in function to value in physical units.
This method should be overridden by subclasses. It is used to provide automatic transformations using an equivalency.
Output the unit in the given format as a string.
The physical unit is appended, within parentheses, to the function unit, as in “dB(mW)”, with both units set using the given format
Parameters: | format : astropy.units.format.Base instance or str
|
---|