FunctionQuantity#
- class astropy.units.function.core.FunctionQuantity(value, unit=None, dtype=<class 'numpy.inexact'>, copy=True, order=None, subok=False, ndmin=0)[source]#
Bases:
QuantityA 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_classpointing back to the corresponding function unit class.- Parameters:
- valuenumber, astropy:quantity-like, or sequence thereof
The numerical value of the function quantity. If a number or a
Quantitywith a function unit, it will be converted tounitand the physical unit will be inferred fromunit. If aQuantitywith just a physical unit, it will converted to the function unit, after, if necessary, converting it to the physical unit inferred fromunit.- unit
str,UnitBase, orFunctionUnitBase, optional For an
FunctionUnitBaseinstance, the physical unit will be taken from it; for other input, it will be inferred fromvalue. By default,unitis 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.
- copybool, 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 givendtype. (TheFalseoption 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 andcopy=False.- subokbool, 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 prepended to the shape as needed to meet this requirement. This parameter is ignored if the input is a
Quantityandcopy=False.
- Raises:
TypeErrorIf the value provided is not a Python numeric type.
TypeErrorIf the unit provided is not a
FunctionUnitBaseorUnitobject, or a parseable string unit.
Attributes Summary
Return a copy with the physical unit in CGS units.
The physical quantity corresponding the function one.
Return a copy with the physical unit in SI units.
Methods Summary
clip([min, max, out])Return an array whose values are limited to
[min, max].cumsum([axis, dtype, out])Return the cumulative sum of the elements along the given axis.
decompose([bases])Generate a new instance with the physical unit decomposed.
max([axis, out, keepdims, initial, where])Return the maximum along a given axis.
min([axis, out, keepdims, initial, where])Return the minimum along a given axis.
sum([axis, dtype, out, keepdims, initial, where])Return the sum of the array elements over the given axis.
Attributes Documentation
- cgs#
Return a copy with the physical unit in CGS units.
- physical#
The physical quantity corresponding the function one.
- si#
Return a copy with the physical unit in SI units.
Methods Documentation
- clip(min=None, max=None, out=None, **kwargs)[source]#
Return an array whose values are limited to
[min, max]. One of max or min must be given.Refer to
numpy.clipfor full documentation.See also
numpy.clipequivalent function
- cumsum(axis=None, dtype=None, out=None)[source]#
Return the cumulative sum of the elements along the given axis.
Refer to
numpy.cumsumfor full documentation.See also
numpy.cumsumequivalent function
- decompose(bases=[])[source]#
Generate a new instance with the physical unit decomposed.
For details, see
decompose.
- max(axis=None, out=None, keepdims=False, initial=<no value>, where=True)[source]#
Return the maximum along a given axis.
Refer to
numpy.amaxfor full documentation.See also
numpy.amaxequivalent function
- min(axis=None, out=None, keepdims=False, initial=<no value>, where=True)[source]#
Return the minimum along a given axis.
Refer to
numpy.aminfor full documentation.See also
numpy.aminequivalent function