astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v1.1.1 »
- Units and Quantities (`astropy.units`) »
- FunctionQuantity

# FunctionQuantity

class `astropy.units.function.``FunctionQuantity`

  Bases: `astropy.units.quantity.Quantity`

  A representation of a (scaled) function of a number with a unit.

  Function quantities are quantities whose units are functions containing a physical unit, such as dB(mW). Most of the arithmetic operations on function quantities are defined in this base class.

  While instantiation is also defined here, this class should not be instantiated directly. Rather, subclasses should be made which have `_unit_class` pointing back to the corresponding function unit class.

  Parameters:

  value : number, sequence of convertible items, `Quantity`, or `FunctionQuantity`

  > The numerical value of the function quantity. If a number or a `Quantity` with a function unit, it will be converted to `unit` and the physical unit will be inferred from `unit`. If a `Quantity` with just a physical unit, it will converted to the function unit, after, if necessary, converting it to the physical unit inferred from `unit`.

  unit : string, `UnitBase` or `FunctionUnitBase` instance, optional

  > For an `FunctionUnitBase` instance, the physical unit will be taken from it; for other input, it will be inferred from `value`. By default, `unit` is set by the subclass.

  dtype : `dtype`, optional

  > The dtype of the resulting Numpy array or scalar that will hold the value. If not provided, it is determined from the input, except that any input that cannot represent float (integer and bool) is converted to float.

  copy : bool, optional

  > If `True` (default), then the value is copied. Otherwise, a copy will only be made if `__array__` returns a copy, if value is a nested sequence, or if a copy is needed to satisfy an explicitly given `dtype`. (The `False` option is intended mostly for internal use, to speed up initialization where a copy is known to have been made. Use with care.)

  order : {‘C’, ‘F’, ‘A’}, optional

  > Specify the order of the array. As in `array`. Ignored if the input does not need to be converted and `copy=False`.

  subok : bool, optional

  > If `False` (default), the returned array will be forced to be of the class used. Otherwise, subclasses will be passed through.

  ndmin : int, optional

  > Specifies the minimum number of dimensions that the resulting array should have. Ones will be pre-pended to the shape as needed to meet this requirement. This parameter is ignored if the input is a `Quantity` and `copy=False`.

  Raises:

  TypeError

  > If the value provided is not a Python numeric type.

  TypeError

  > If the unit provided is not a `FunctionUnitBase` or `Unit` object, or a parseable string unit.

  Attributes Summary

  `cgs` | Return a copy with the physical unit in CGS units.
  `equivalencies` | Equivalencies applied by default during unit conversions.
  `physical` | The physical quantity corresponding the function one.
  `si` | Return a copy with the physical unit in SI units.
  `unit` | Function unit of the quantity, containing the physical unit.

  Methods Summary

  `decompose`([bases]) | Generate a new `FunctionQuantity` with the physical unit decomposed.
  `to`(unit[, equivalencies]) | Returns a new quantity with the specified units.

  Attributes Documentation

  `cgs`

    Return a copy with the physical unit in CGS units.

  `equivalencies`

    Equivalencies applied by default during unit conversions.

    Contains the list to convert between function and physical unit, as set by the `FunctionUnitBase` unit.

  `physical`

    The physical quantity corresponding the function one.

  `si`

    Return a copy with the physical unit in SI units.

  `unit`

    Function unit of the quantity, containing the physical unit.

    Represented by a `FunctionUnitBase` object.

  Methods Documentation

  `decompose`(bases=[])

    Generate a new `FunctionQuantity` with the physical unit decomposed.

    For details, see `decompose`.

  `to`(unit, equivalencies=[])

    Returns a new quantity with the specified units.

    Parameters:

    unit : `UnitBase` instance, str

    > An object that represents the unit to convert to. Must be an `UnitBase` object or a string parseable by the `units` package.

    equivalencies : list of equivalence pairs, optional

    > A list of equivalence pairs to try if the units are not directly convertible. See Equivalencies. This list is in meant to treat only equivalencies between different physical units; the build-in equivalency between the function unit and the physical one is automatically taken into account.