Units and Quantities (astropy.units
)¶
Introduction¶
astropy.units
handles defining, converting between, and performing
arithmetic with physical quantities, such as meters, seconds, Hz,
etc. It also handles logarithmic units such as magnitude and decibel.
astropy.units
does not know spherical geometry or sexagesimal
(hours, min, sec): if you want to deal with celestial coordinates,
see the astropy.coordinates
package.
Getting Started¶
Most users of the astropy.units
package will work with Quantity objects: the combination of a value and a unit. The most convenient way to
create a Quantity
is to multiply or divide a value by one of the built-in
units. It works with scalars, sequences, and numpy
arrays.
Examples¶
To create a Quantity
object:
>>> from astropy import units as u
>>> 42.0 * u.meter
<Quantity 42. m>
>>> [1., 2., 3.] * u.m
<Quantity [1., 2., 3.] m>
>>> import numpy as np
>>> np.array([1., 2., 3.]) * u.m
<Quantity [1., 2., 3.] m>
You can get the unit and value from a Quantity
using the unit and
value members:
>>> q = 42.0 * u.meter
>>> q.value
42.0
>>> q.unit
Unit("m")
From this basic building block, it is possible to start combining quantities with different units:
>>> 15.1 * u.meter / (32.0 * u.second)
<Quantity 0.471875 m / s>
>>> 3.0 * u.kilometer / (130.51 * u.meter / u.second)
<Quantity 0.022986744310780783 km s / m>
>>> (3.0 * u.kilometer / (130.51 * u.meter / u.second)).decompose()
<Quantity 22.986744310780782 s>
Unit conversion is done using the
to()
method, which returns a new
Quantity
in the given unit:
>>> x = 1.0 * u.parsec
>>> x.to(u.km)
<Quantity 30856775814671.914 km>
It is also possible to work directly with units at a lower level, for example, to create custom units:
>>> from astropy.units import imperial
>>> cms = u.cm / u.s
>>> # ...and then use some imperial units
>>> mph = imperial.mile / u.hour
>>> # And do some conversions
>>> q = 42.0 * cms
>>> q.to(mph)
<Quantity 0.939513242662849 mi / h>
Units that “cancel out” become a special unit called the “dimensionless unit”:
>>> u.m / u.m
Unit(dimensionless)
To create a basic dimensionless quantity, multiply a value by the unscaled dimensionless unit:
>>> q = 1.0 * u.dimensionless_unscaled
>>> q.unit
Unit(dimensionless)
astropy.units
is able to match compound units against the units it already
knows about:
>>> (u.s ** -1).compose()
[Unit("Bq"), Unit("Hz"), Unit("2.7027e-11 Ci")]
And it can convert between unit systems, such as SI or CGS:
>>> (1.0 * u.Pa).cgs
<Quantity 10. P / s>
The units mag
, dex
, and dB
are special, being logarithmic
units, for which a value is the logarithm of a physical
quantity in a given unit. These can be used with a physical unit in
parentheses to create a corresponding logarithmic quantity:
>>> -2.5 * u.mag(u.ct / u.s)
<Magnitude -2.5 mag(ct / s)>
>>> from astropy import constants as c
>>> u.Dex((c.G * u.M_sun / u.R_sun**2).cgs)
<Dex 4.438067627303133 dex(cm / s2)>
astropy.units
also handles equivalencies, such as
that between wavelength and frequency. To use that feature, equivalence objects
are passed to the to()
conversion
method. For instance, a conversion from wavelength to frequency does not
normally work:
>>> (1000 * u.nm).to(u.Hz)
Traceback (most recent call last):
...
UnitConversionError: 'nm' (length) and 'Hz' (frequency) are not convertible
But by passing an equivalency list, in this case
spectral()
, it does:
>>> (1000 * u.nm).to(u.Hz, equivalencies=u.spectral())
<Quantity 2.99792458e+14 Hz>
Quantities and units can be printed nicely to strings using the Format String Syntax. Format
specifiers (like 0.03f
) in strings will be used to format the quantity
value:
>>> q = 15.1 * u.meter / (32.0 * u.second)
>>> q
<Quantity 0.471875 m / s>
>>> f"{q:0.03f}"
'0.472 m / s'
The value and unit can also be formatted separately. Format specifiers for units can be used to choose the unit formatter:
>>> q = 15.1 * u.meter / (32.0 * u.second)
>>> q
<Quantity 0.471875 m / s>
>>> f"{q.value:0.03f} {q.unit:FITS}"
'0.472 m s-1'
Using astropy.units
¶
- Quantity
- Creating Quantity Instances
- Converting to Different Units
- Comparing Quantities
- Plotting Quantities
- Arithmetic
- NumPy Functions
- Dimensionless Quantities
- Converting to Plain Python Scalars
- Functions that Accept Quantities
- Representing Vectors with Units
- Creating and Converting Quantities without Copies
- The
numpy.dtype
of a Quantity - QTable
- Subclassing Quantity
- Unit-Aware Type Annotations
- Standard Units
- Combining and Defining Units
- Decomposing and Composing Units
- Magnitudes and Other Logarithmic Units
- Structured Units
- String Representations of Units and Quantities
- Equivalencies
- Physical Types
- Using Prior Versions of Constants
- Low-Level Unit Conversion
Acknowledgments¶
This code was originally based on the pynbody units module written by Andrew Pontzen, who has granted the Astropy Project permission to use the code under a BSD license.
See Also¶
FITS Standard for units in FITS.
The Units in the VO 1.0 Standard for representing units in the VO.
OGIP Units: A standard for storing units in OGIP FITS files.
Performance Tips¶
If you are attaching units to arrays to make Quantity
objects, multiplying
arrays by units will result in the array being copied in memory, which will slow
things down. Furthermore, if you are multiplying an array by a composite unit,
the array will be copied for each individual multiplication. Thus, in the
following case, the array is copied four successive times:
In [1]: import numpy as np
In [2]: from astropy import units as u
In [3]: rng = np.random.default_rng()
In [4]: array = rng.random(10000000)
In [5]: %timeit array * u.m / u.s / u.kg / u.sr
92.5 ms ± 2.52 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
There are several ways to speed this up. First, when you are using composite units, ensure that the entire unit gets evaluated first, then attached to the array. You can do this by using parentheses as for any other operation:
In [6]: %timeit array * (u.m / u.s / u.kg / u.sr)
21.5 ms ± 886 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In this case, this has sped things up by a factor of 4. If you use a composite unit several times in your code then you can define a variable for it:
In [7]: UNIT_MSKGSR = u.m / u.s / u.kg / u.sr
In [8]: %timeit array * UNIT_MSKGSR
22.2 ms ± 551 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In this case and the case with brackets, the array is still copied once when
creating the Quantity
. If you want to avoid any copies altogether, you can
make use of the <<
operator to attach the unit to the array:
In [9]: %timeit array << u.m / u.s / u.kg / u.sr
47.1 µs ± 5.77 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
Note that these are now microseconds, so this is 2000x faster than the
original case with no brackets. Note that brackets are not needed when using
<<
since *
and /
have a higher precedence, so the unit will be
evaluated first. When using <<
, be aware that because the data is not being
copied, changing the original array will also change the Quantity
object.
Note that for composite units, you will definitely see an impact if you can pre-compute the composite unit:
In [10]: %timeit array << UNIT_MSKGSR
6.51 µs ± 112 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
Which is over 10000x faster than the original example. See
Creating and Converting Quantities without Copies for more details about the <<
operator.
Reference/API¶
astropy.units.quantity Module¶
This module defines the Quantity
object, which represents a number with some
associated units. Quantity
objects support operations like ordinary numbers,
but will deal with unit conversions internally.
Functions¶
|
Whether two arrays are element-wise equal within a tolerance. |
|
Return a boolean array where two arrays are element-wise equal within a tolerance. |
Classes¶
|
A |
|
Superclass for Quantities of specific physical type. |
|
|
|
Container for meta information like name, description, format. |
Class Inheritance Diagram¶
astropy.units Package¶
This subpackage contains classes and functions for defining and converting between different physical units.
This code is adapted from the pynbody units module written by Andrew Pontzen, who has granted the Astropy project permission to use the code under a BSD license.
Functions¶
|
Add aliases for units. |
|
Adds to the equivalencies enabled in the unit registry. |
|
Adds to the set of units enabled in the unit registry. |
|
Whether two arrays are element-wise equal within a tolerance. |
|
Convert between the |
|
Defines the conversion between Jy/sr and "brightness temperature", \(T_B\), in Kelvins. |
|
Add a mapping between a unit and the corresponding physical type(s). |
|
Factory function for defining new units. |
Allow angles to be equivalent to dimensionless (with 1 rad = 1 m/m = 1). |
|
|
Return the equivalency pairs for the optical convention for velocity. |
|
Return the equivalency pairs for the radio convention for velocity. |
Returns the equivalence between Doppler redshift (unitless) and radial velocity. |
|
|
Return the equivalency pairs for the relativistic convention for velocity. |
|
Return the physical type that corresponds to a unit (or another physical type representation). |
|
Return a boolean array where two arrays are element-wise equal within a tolerance. |
Allow logarithmic units to be converted to dimensionless fractions |
|
Returns a list of equivalence pairs that handle the conversion between mass and energy. |
|
Returns the equivalence between amu and molar mass. |
|
|
Returns a list of equivalence pairs that handle the conversion between parallax angle and distance. |
|
Convert between pixel distances (in units of |
|
Convert between lengths (to be interpreted as lengths in the focal plane) and angular units with a specified |
|
A decorator for validating the units of arguments to functions. |
|
Set aliases for units. |
|
Sets the equivalencies enabled in the unit registry. |
|
Sets the units enabled in the unit registry. |
|
Returns a list of equivalence pairs that handle spectral wavelength, wave number, frequency, and energy equivalencies. |
|
Returns a list of equivalence pairs that handle spectral density with regard to wavelength and frequency. |
Convert between Kelvin, Celsius, Rankine and Fahrenheit here because Unit and CompositeUnit cannot do addition or subtraction properly. |
|
Convert between Kelvin and keV(eV) to an equivalent amount. |
|
|
Defines the conversion between Jy/sr and "thermodynamic temperature", \(T_{CMB}\), in Kelvins. |
|
An equivalency for converting linear flux units ("maggys") defined relative to a standard source into a standardized system. |
Classes¶
|
Create a composite unit using expressions of previously defined units. |
|
|
|
Logarithmic physical units expressed in dB |
|
|
|
Logarithmic physical units expressed in magnitudes |
|
A container for a units equivalency. |
|
A representation of a (scaled) function of a number with a unit. |
|
Abstract base class for function units. |
|
Irreducible units are the units that all other units are defined in terms of. |
|
A representation of a (scaled) logarithm of a number with a unit |
|
Logarithmic unit containing a physical one |
|
Logarithmic physical units expressed in magnitudes |
|
|
|
The base class of units that have a name. |
|
Represents the physical type(s) that are dimensionally compatible with a set of units. |
|
A unit that is simply a SI-prefixed version of another unit. |
|
A |
|
Container for meta information like name, description, format. |
|
|
|
Superclass for Quantities of specific physical type. |
|
Container for units for a structured Quantity. |
|
The main unit class. |
|
Abstract base class for units. |
Used specifically for errors related to converting between units or interpreting units in terms of other units. |
|
Used specifically for errors in setting to units not allowed by a class. |
|
The base class for unit-specific exceptions. |
|
The base class for unit-specific warnings. |
|
|
A unit that did not parse correctly. |
Class Inheritance Diagram¶
astropy.units.format Package¶
A collection of different unit formats.
Functions¶
|
Get a formatter by name. |
Classes¶
|
The abstract base class of all unit formats. |
|
A "generic" format. |
|
Support the Centre de Données astronomiques de Strasbourg Standards for Astronomical Catalogues 2.0 format, and the complete set of supported units. |
|
Output-only format for to display pretty formatting at the console. |
|
The FITS standard unit format. |
|
Output LaTeX to display the unit based on IAU style guidelines. |
|
Output LaTeX to display the unit based on IAU style guidelines with negative powers. |
|
Support the units in Office of Guest Investigator Programs (OGIP) FITS files. |
|
Output-only format to display pretty formatting at the console using Unicode characters. |
|
A format that doesn't display the scale part of the unit, other than that, it is identical to the |
|
The IVOA standard for units used by the VO. |
Class Inheritance Diagram¶
astropy.units.si Module¶
This package defines the SI units. They are also available in the
astropy.units
namespace.
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
annum (a) |
\(\mathrm{365.25\,d}\) |
|
Yes |
|
ampere: base unit of electric current in SI |
|
Yes |
|
|
ångström: 10 ** -10 m |
\(\mathrm{0.1\,nm}\) |
|
Yes |
|
arc minute: angular measurement |
\(\mathrm{0.016666667\,{}^{\circ}}\) |
|
Yes |
|
arc second: angular measurement |
\(\mathrm{0.00027777778\,{}^{\circ}}\) |
|
Yes |
|
becquerel: unit of radioactivity |
\(\mathrm{\frac{1}{s}}\) |
|
No |
|
coulomb: electric charge |
\(\mathrm{A\,s}\) |
|
Yes |
|
candela: base unit of luminous intensity in SI |
|
Yes |
|
|
curie: unit of radioactivity |
\(\mathrm{3.7 \times 10^{10}\,Bq}\) |
|
No |
|
day (d) |
\(\mathrm{24\,h}\) |
|
Yes |
|
degree: angular measurement 1/360 of full rotation |
\(\mathrm{0.017453293\,rad}\) |
|
Yes |
|
Degrees Celsius |
|
No |
|
|
Electron Volt |
\(\mathrm{1.6021766 \times 10^{-19}\,J}\) |
|
Yes |
|
Farad: electrical capacitance |
\(\mathrm{\frac{C}{V}}\) |
|
Yes |
|
fortnight |
\(\mathrm{2\,wk}\) |
No |
|
|
gram (g) |
\(\mathrm{0.001\,kg}\) |
|
Yes |
|
hour (h) |
\(\mathrm{3600\,s}\) |
|
Yes |
|
Henry: inductance |
\(\mathrm{\frac{Wb}{A}}\) |
|
Yes |
|
hour angle: angular measurement with 24 in a full circle |
\(\mathrm{15\,{}^{\circ}}\) |
No |
|
|
Frequency |
\(\mathrm{\frac{1}{s}}\) |
|
Yes |
|
Joule: energy |
\(\mathrm{N\,m}\) |
|
Yes |
|
Kelvin: temperature with a null point at absolute zero. |
|
Yes |
|
|
kilogram: base unit of mass in SI. |
|
No |
|
|
liter: metric unit of volume |
\(\mathrm{1000\,cm^{3}}\) |
|
Yes |
|
lumen: luminous flux |
\(\mathrm{cd\,sr}\) |
|
Yes |
|
lux: luminous emittance |
\(\mathrm{\frac{lm}{m^{2}}}\) |
|
Yes |
|
meter: base unit of length in SI |
|
Yes |
|
|
milli arc second: angular measurement |
\(\mathrm{0.001\,{}^{\prime\prime}}\) |
No |
|
|
micron: alias for micrometer (um) |
\(\mathrm{\mu m}\) |
No |
|
|
minute (min) |
\(\mathrm{60\,s}\) |
|
Yes |
|
mole: amount of a chemical substance in SI. |
|
Yes |
|
|
Newton: force |
\(\mathrm{\frac{kg\,m}{s^{2}}}\) |
|
Yes |
|
Ohm: electrical resistance |
\(\mathrm{\frac{V}{A}}\) |
|
Yes |
|
Pascal: pressure |
\(\mathrm{\frac{J}{m^{3}}}\) |
|
Yes |
|
percent: one hundredth of unity, factor 0.01 |
\(\mathrm{0.01\,}\) |
|
No |
|
radian: angular measurement of the ratio between the length on an arc and its radius |
|
Yes |
|
|
second: base unit of time in SI. |
|
Yes |
|
|
Siemens: electrical conductance |
\(\mathrm{\frac{A}{V}}\) |
|
Yes |
|
Sidereal day (sday) is the time of one rotation of the Earth. |
\(\mathrm{86164.091\,s}\) |
No |
|
|
steradian: unit of solid angle in SI |
\(\mathrm{rad^{2}}\) |
|
Yes |
|
Metric tonne |
\(\mathrm{1000\,kg}\) |
|
No |
|
Tesla: magnetic flux density |
\(\mathrm{\frac{Wb}{m^{2}}}\) |
|
Yes |
|
micro arc second: angular measurement |
\(\mathrm{1 \times 10^{-6}\,{}^{\prime\prime}}\) |
No |
|
|
Volt: electric potential or electromotive force |
\(\mathrm{\frac{J}{C}}\) |
|
Yes |
|
Watt: power |
\(\mathrm{\frac{J}{s}}\) |
|
Yes |
|
Weber: magnetic flux |
\(\mathrm{V\,s}\) |
|
Yes |
|
week (wk) |
\(\mathrm{7\,d}\) |
|
No |
|
year (yr) |
\(\mathrm{365.25\,d}\) |
|
Yes |
astropy.units.cgs Module¶
This package defines the CGS units. They are also available in the
top-level astropy.units
namespace.
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
abcoulomb: CGS (EMU) of charge |
\(\mathrm{Bi\,s}\) |
|
No |
|
Barye: CGS unit of pressure |
\(\mathrm{\frac{g}{cm\,s^{2}}}\) |
|
Yes |
|
Biot: CGS (EMU) unit of current |
\(\mathrm{\frac{cm^{1/2}\,g^{1/2}}{s}}\) |
|
No |
|
coulomb: electric charge |
\(\mathrm{A\,s}\) |
|
No |
|
candela: base unit of luminous intensity in SI |
|
No |
|
|
centimeter (cm) |
\(\mathrm{cm}\) |
|
No |
|
Debye: CGS unit of electric dipole moment |
\(\mathrm{3.3333333 \times 10^{-30}\,C\,m}\) |
|
Yes |
|
Degrees Celsius |
|
No |
|
|
dyne: CGS unit of force |
\(\mathrm{\frac{cm\,g}{s^{2}}}\) |
|
Yes |
|
erg: CGS unit of energy |
\(\mathrm{\frac{cm^{2}\,g}{s^{2}}}\) |
Yes |
|
|
Franklin: CGS (ESU) unit of charge |
\(\mathrm{\frac{cm^{3/2}\,g^{1/2}}{s}}\) |
|
No |
|
gram (g) |
\(\mathrm{0.001\,kg}\) |
|
No |
|
Gauss: CGS unit for magnetic field |
\(\mathrm{0.0001\,T}\) |
|
Yes |
|
Gal: CGS unit of acceleration |
\(\mathrm{\frac{cm}{s^{2}}}\) |
|
Yes |
|
Kelvin: temperature with a null point at absolute zero. |
|
No |
|
|
kayser: CGS unit of wavenumber |
\(\mathrm{\frac{1}{cm}}\) |
|
Yes |
|
mole: amount of a chemical substance in SI. |
|
No |
|
|
Maxwell: CGS unit for magnetic flux |
\(\mathrm{1 \times 10^{-8}\,Wb}\) |
|
No |
|
poise: CGS unit of dynamic viscosity |
\(\mathrm{\frac{g}{cm\,s}}\) |
|
Yes |
|
radian: angular measurement of the ratio between the length on an arc and its radius |
|
No |
|
|
second: base unit of time in SI. |
|
No |
|
|
steradian: unit of solid angle in SI |
\(\mathrm{rad^{2}}\) |
|
No |
|
stokes: CGS unit of kinematic viscosity |
\(\mathrm{\frac{cm^{2}}{s}}\) |
|
Yes |
|
statampere: CGS (ESU) unit of current |
\(\mathrm{\frac{Fr}{s}}\) |
|
No |
astropy.units.astrophys Module¶
This package defines the astrophysics-specific units. They are also
available in the astropy.units
namespace.
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
adu |
Yes |
||
|
astronomical unit: approximately the mean Earth–Sun distance. |
\(\mathrm{1.4959787 \times 10^{11}\,m}\) |
|
Yes |
|
beam |
Yes |
||
|
bin |
Yes |
||
|
chan |
Yes |
||
|
count (ct) |
|
Yes |
|
|
dn (DN) |
|
No |
|
|
Earth mass |
\(\mathrm{5.9721679 \times 10^{24}\,kg}\) |
|
No |
|
Earth radius |
\(\mathrm{6378100\,m}\) |
|
No |
|
Number of electrons |
No |
||
|
Jupiter mass |
\(\mathrm{1.8981246 \times 10^{27}\,kg}\) |
|
No |
|
Jupiter radius |
\(\mathrm{71492000\,m}\) |
|
No |
|
Jansky: spectral flux density |
\(\mathrm{1 \times 10^{-26}\,\frac{W}{Hz\,m^{2}}}\) |
|
Yes |
|
Light second |
\(\mathrm{2.9979246 \times 10^{8}\,m}\) |
|
No |
|
Light year |
\(\mathrm{9.4607305 \times 10^{15}\,m}\) |
|
Yes |
|
parsec: approximately 3.26 light-years. |
\(\mathrm{3.0856776 \times 10^{16}\,m}\) |
|
Yes |
|
photon (ph) |
|
Yes |
|
|
Rayleigh: photon flux |
\(\mathrm{7.9577472 \times 10^{8}\,\frac{ph}{s\,sr\,m^{2}}}\) |
|
Yes |
|
Rydberg: Energy of a photon whose wavenumber is the Rydberg constant |
\(\mathrm{13.605693\,eV}\) |
|
Yes |
|
Solar luminance |
\(\mathrm{3.828 \times 10^{26}\,W}\) |
|
No |
|
Solar mass |
\(\mathrm{1.9884099 \times 10^{30}\,kg}\) |
|
No |
|
Solar radius |
\(\mathrm{6.957 \times 10^{8}\,m}\) |
|
No |
|
Sun |
No |
astropy.units.misc Module¶
This package defines miscellaneous units. They are also
available in the astropy.units
namespace.
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
bar: pressure |
\(\mathrm{100000\,Pa}\) |
Yes |
|
|
barn: unit of area used in HEP |
\(\mathrm{1 \times 10^{-28}\,m^{2}}\) |
|
Yes |
|
b (bit) |
|
Yes |
|
|
B (byte) |
\(\mathrm{8\,bit}\) |
|
Yes |
|
cycle: angular measurement, a full turn or rotation |
\(\mathrm{6.2831853\,rad}\) |
|
No |
|
Electron mass |
\(\mathrm{9.1093837 \times 10^{-31}\,kg}\) |
No |
|
|
Proton mass |
\(\mathrm{1.6726219 \times 10^{-27}\,kg}\) |
No |
|
|
pixel (pix) |
|
Yes |
|
|
spat: the solid angle of the sphere, 4pi sr |
\(\mathrm{12.566371\,sr}\) |
|
No |
|
Unit of pressure based on an absolute scale, now defined as exactly 1/760 of a standard atmosphere |
\(\mathrm{133.32237\,Pa}\) |
|
Yes |
|
Unified atomic mass unit |
\(\mathrm{1.6605391 \times 10^{-27}\,kg}\) |
|
Yes |
|
voxel (vox) |
|
Yes |
astropy.units.function.units Module¶
This package defines units that can also be used as functions of other units.
If called, their arguments are used to initialize the corresponding function
unit (e.g., u.mag(u.ct/u.s)
). Note that the prefixed versions cannot be
called, as it would be unclear what, e.g., u.mmag(u.ct/u.s)
would mean.
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
Decibel: ten per base 10 logarithmic unit |
\(\mathrm{0.1\,dex}\) |
|
No |
|
Dex: Base 10 logarithmic unit |
No |
||
|
Astronomical magnitude: -2.5 per base 10 logarithmic unit |
\(\mathrm{-0.4\,dex}\) |
Yes |
astropy.units.photometric Module¶
This module defines magnitude zero points and related photometric quantities.
The corresponding magnitudes are given in the description of each unit
(the actual definitions are in logarithmic
).
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
AB magnitude zero flux density (magnitude |
\(\mathrm{3.6307805 \times 10^{-20}\,\frac{erg}{Hz\,s\,cm^{2}}}\) |
|
No |
|
Luminosity corresponding to absolute bolometric magnitude zero (magnitude |
\(\mathrm{3.0128 \times 10^{28}\,W}\) |
|
No |
|
Irradiance corresponding to appparent bolometric magnitude zero (magnitude |
\(\mathrm{2.3975101 \times 10^{25}\,\frac{W}{pc^{2}}}\) |
|
No |
|
Maggies - a linear flux unit that is the flux for a mag=0 object.To tie this onto a specific calibrated unit system, the zero_point_flux equivalency should be used. |
|
Yes |
|
|
ST magnitude zero flux density (magnitude |
\(\mathrm{3.6307805 \times 10^{-9}\,\frac{erg}{\mathring{A}\,s\,cm^{2}}}\) |
|
No |
Functions¶
|
An equivalency for converting linear flux units ("maggys") defined relative to a standard source into a standardized system. |
astropy.units.imperial Module¶
This package defines colloquially used Imperial units. They are
available in the astropy.units.imperial
namespace, but not in the
top-level astropy.units
namespace, e.g.:
>>> import astropy.units as u
>>> mph = u.imperial.mile / u.hour
>>> mph
Unit("mi / h")
To include them in compose
and the results of
find_equivalent_units
, do:
>>> import astropy.units as u
>>> u.imperial.enable()
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
International acre |
\(\mathrm{43560\,ft^{2}}\) |
|
No |
|
British thermal unit |
\(\mathrm{1.0550559\,kJ}\) |
|
No |
|
Thermochemical calorie: pre-SI metric unit of energy |
\(\mathrm{4.184\,J}\) |
|
No |
|
U.S. |
\(\mathrm{0.5\,pint}\) |
No |
|
|
Degrees Fahrenheit |
|
No |
|
|
Rankine scale: absolute scale of thermodynamic temperature |
|
No |
|
|
U.S. |
\(\mathrm{0.125\,cup}\) |
|
No |
|
International foot |
\(\mathrm{12\,inch}\) |
|
No |
|
Furlong |
\(\mathrm{660\,ft}\) |
|
No |
|
U.S. |
\(\mathrm{3.7854118\,\mathcal{l}}\) |
No |
|
|
Electrical horsepower |
\(\mathrm{745.69987\,W}\) |
|
No |
|
International inch |
\(\mathrm{2.54\,cm}\) |
No |
|
|
Calorie: colloquial definition of Calorie |
\(\mathrm{1000\,cal}\) |
|
No |
|
Kilopound: force |
\(\mathrm{1000\,lbf}\) |
|
No |
|
nautical unit of speed: 1 nmi per hour |
\(\mathrm{\frac{nmi}{h}}\) |
|
No |
|
International avoirdupois pound: mass |
\(\mathrm{16\,oz}\) |
|
No |
|
Pound: force |
\(\mathrm{\frac{ft\,slug}{s^{2}}}\) |
No |
|
|
International mile |
\(\mathrm{5280\,ft}\) |
|
No |
|
Thousandth of an inch |
\(\mathrm{0.001\,inch}\) |
|
No |
|
Nautical mile |
\(\mathrm{1852\,m}\) |
|
No |
|
International avoirdupois ounce: mass |
\(\mathrm{28.349523\,g}\) |
|
No |
|
U.S. |
\(\mathrm{0.5\,quart}\) |
No |
|
|
Pound per square inch: pressure |
\(\mathrm{\frac{lbf}{inch^{2}}}\) |
No |
|
|
U.S. |
\(\mathrm{0.25\,gallon}\) |
No |
|
|
slug: mass |
\(\mathrm{32.174049\,lb}\) |
No |
|
|
International avoirdupois stone: mass |
\(\mathrm{14\,lb}\) |
|
No |
|
U.S. |
\(\mathrm{0.5\,foz}\) |
|
No |
|
International avoirdupois ton: mass |
\(\mathrm{2000\,lb}\) |
No |
|
|
U.S. |
\(\mathrm{0.33333333\,tbsp}\) |
|
No |
|
International yard |
\(\mathrm{3\,ft}\) |
|
No |
Functions¶
|
Enable Imperial units so they appear in results of |
astropy.units.cds Module¶
This package defines units used in the CDS format, both the units defined in Centre de Données astronomiques de Strasbourg Standards for Astronomical Catalogues 2.0 format and the complete set of supported units. This format is used by VOTable up to version 1.2.
These units are not available in the top-level astropy.units
namespace. To use these units, you must import the astropy.units.cds
module:
>>> from astropy.units import cds
>>> q = 10. * cds.lyr
To include them in compose
and the results of
find_equivalent_units
, do:
>>> from astropy.units import cds
>>> cds.enable()
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
percent |
\(\mathrm{\%}\) |
No |
|
|
dimensionless and unscaled |
\(\mathrm{}\) |
|
No |
|
Planck constant |
\(\mathrm{6.6260701 \times 10^{-34}\,J\,s}\) |
Yes |
|
|
Ampere |
\(\mathrm{A}\) |
Yes |
|
|
year |
\(\mathrm{a}\) |
Yes |
|
|
Bohr radius |
\(\mathrm{5.2917721 \times 10^{-11}\,m}\) |
Yes |
|
|
Angstrom |
\(\mathrm{\mathring{A}}\) |
|
Yes |
|
Light year |
\(\mathrm{lyr}\) |
Yes |
|
|
Fine structure constant |
\(\mathrm{0.0072973526\,}\) |
Yes |
|
|
minute of arc |
\(\mathrm{{}^{\prime}}\) |
|
Yes |
|
second of arc |
\(\mathrm{{}^{\prime\prime}}\) |
|
Yes |
|
atmosphere |
\(\mathrm{101325\,Pa}\) |
Yes |
|
|
astronomical unit |
\(\mathrm{AU}\) |
|
Yes |
|
bar |
\(\mathrm{bar}\) |
Yes |
|
|
barn |
\(\mathrm{barn}\) |
Yes |
|
|
bit |
\(\mathrm{bit}\) |
Yes |
|
|
byte |
\(\mathrm{byte}\) |
Yes |
|
|
Coulomb |
\(\mathrm{C}\) |
Yes |
|
|
speed of light |
\(\mathrm{2.9979246 \times 10^{8}\,\frac{m}{s}}\) |
Yes |
|
|
calorie |
\(\mathrm{4.1854\,J}\) |
Yes |
|
|
candela |
\(\mathrm{cd}\) |
Yes |
|
|
Crab (X-ray) flux |
Yes |
||
|
count |
\(\mathrm{ct}\) |
Yes |
|
|
Debye (dipole) |
\(\mathrm{D}\) |
Yes |
|
|
Julian day |
\(\mathrm{d}\) |
Yes |
|
|
degree |
\(\mathrm{{}^{\circ}}\) |
|
Yes |
|
dyne |
\(\mathrm{dyn}\) |
Yes |
|
|
electron charge |
\(\mathrm{1.6021766 \times 10^{-19}\,C}\) |
Yes |
|
|
electric constant |
\(\mathrm{8.8541878 \times 10^{-12}\,\frac{F}{m}}\) |
Yes |
|
|
erg |
\(\mathrm{erg}\) |
Yes |
|
|
electron volt |
\(\mathrm{eV}\) |
Yes |
|
|
Farad |
\(\mathrm{F}\) |
Yes |
|
|
Gravitation constant |
\(\mathrm{6.6743 \times 10^{-11}\,\frac{m^{3}}{kg\,s^{2}}}\) |
Yes |
|
|
gram |
\(\mathrm{g}\) |
Yes |
|
|
Gauss |
\(\mathrm{G}\) |
Yes |
|
|
Earth mass |
\(\mathrm{M_{\oplus}}\) |
|
Yes |
|
Henry |
\(\mathrm{H}\) |
Yes |
|
|
hour |
\(\mathrm{h}\) |
Yes |
|
|
hour |
\(\mathrm{h}\) |
Yes |
|
|
Hertz |
\(\mathrm{Hz}\) |
Yes |
|
|
inch |
\(\mathrm{0.0254\,m}\) |
Yes |
|
|
Joule |
\(\mathrm{J}\) |
Yes |
|
|
Julian day |
\(\mathrm{d}\) |
Yes |
|
|
Jupiter mass |
\(\mathrm{M_{\rm J}}\) |
|
Yes |
|
Jansky |
\(\mathrm{Jy}\) |
Yes |
|
|
Kelvin |
\(\mathrm{K}\) |
Yes |
|
|
Boltzmann |
\(\mathrm{1.380649 \times 10^{-23}\,\frac{J}{K}}\) |
Yes |
|
|
litre |
\(\mathrm{\mathcal{l}}\) |
Yes |
|
|
lumen |
\(\mathrm{lm}\) |
Yes |
|
|
solar luminosity |
\(\mathrm{L_{\odot}}\) |
|
Yes |
|
lux |
\(\mathrm{lx}\) |
Yes |
|
|
Light year |
\(\mathrm{lyr}\) |
Yes |
|
|
meter |
\(\mathrm{m}\) |
Yes |
|
|
magnitude |
\(\mathrm{mag}\) |
Yes |
|
|
millisecond of arc |
\(\mathrm{marcsec}\) |
No |
|
|
electron mass |
\(\mathrm{9.1093837 \times 10^{-31}\,kg}\) |
Yes |
|
|
minute |
\(\mathrm{min}\) |
Yes |
|
|
Julian day |
\(\mathrm{d}\) |
Yes |
|
|
millimeter of mercury |
\(\mathrm{133.32239\,Pa}\) |
Yes |
|
|
mole |
\(\mathrm{mol}\) |
Yes |
|
|
proton mass |
\(\mathrm{1.6726219 \times 10^{-27}\,kg}\) |
Yes |
|
|
solar mass |
\(\mathrm{M_{\odot}}\) |
|
Yes |
|
magnetic constant |
\(\mathrm{1.2566371 \times 10^{-6}\,\frac{N}{A^{2}}}\) |
|
Yes |
|
Bohr magneton |
\(\mathrm{9.2740101 \times 10^{-24}\,\frac{J}{T}}\) |
Yes |
|
|
Newton |
\(\mathrm{N}\) |
Yes |
|
|
Ohm |
\(\mathrm{\Omega}\) |
Yes |
|
|
Pascal |
\(\mathrm{Pa}\) |
Yes |
|
|
parsec |
\(\mathrm{pc}\) |
Yes |
|
|
photon |
\(\mathrm{ph}\) |
Yes |
|
|
π |
\(\mathrm{3.1415927\,}\) |
Yes |
|
|
pixel |
\(\mathrm{pix}\) |
Yes |
|
|
parts per million |
\(\mathrm{1 \times 10^{-6}\,}\) |
Yes |
|
|
gas constant |
\(\mathrm{8.3144626\,\frac{J}{K\,mol}}\) |
Yes |
|
|
radian |
\(\mathrm{rad}\) |
Yes |
|
|
Earth equatorial radius |
\(\mathrm{6378100\,m}\) |
Yes |
|
|
Jupiter equatorial radius |
\(\mathrm{71492000\,m}\) |
Yes |
|
|
solar radius |
\(\mathrm{R_{\odot}}\) |
|
Yes |
|
Rydberg |
\(\mathrm{R_{\infty}}\) |
Yes |
|
|
Siemens |
\(\mathrm{S}\) |
Yes |
|
|
second |
\(\mathrm{s}\) |
|
Yes |
|
steradian |
\(\mathrm{sr}\) |
Yes |
|
|
solar unit |
\(\mathrm{Sun}\) |
Yes |
|
|
Tesla |
\(\mathrm{T}\) |
Yes |
|
|
metric tonne |
\(\mathrm{1000\,kg}\) |
Yes |
|
|
atomic mass |
\(\mathrm{1.6605391 \times 10^{-27}\,kg}\) |
Yes |
|
|
Volt |
\(\mathrm{V}\) |
Yes |
|
|
Watt |
\(\mathrm{W}\) |
Yes |
|
|
Weber |
\(\mathrm{Wb}\) |
Yes |
|
|
year |
\(\mathrm{a}\) |
Yes |
|
|
microsecond of arc |
\(\mathrm{\mu arcsec}\) |
No |
Functions¶
|
Enable CDS units so they appear in results of |
astropy.units.physical Module¶
Defines the physical types that correspond to different units.
Physical type |
Unit |
Other physical type(s) with same unit |
---|---|---|
absement |
\(\mathrm{m\,s}\) |
|
absity |
\(\mathrm{s^{2}\,m}\) |
|
acceleration |
\(\mathrm{\frac{m}{s^{2}}}\) |
|
action |
\(\mathrm{\frac{m^{2}\,kg}{s}}\) |
angular momentum |
amount of substance |
\(\mathrm{mol}\) |
|
angle |
\(\mathrm{rad}\) |
|
angular acceleration |
\(\mathrm{\frac{rad}{s^{2}}}\) |
|
angular frequency |
\(\mathrm{\frac{rad}{s}}\) |
angular speed, angular velocity |
angular momentum |
\(\mathrm{\frac{m^{2}\,kg}{s}}\) |
action |
angular speed |
\(\mathrm{\frac{rad}{s}}\) |
angular frequency, angular velocity |
angular velocity |
\(\mathrm{\frac{rad}{s}}\) |
angular frequency, angular speed |
area |
\(\mathrm{m^{2}}\) |
|
bandwidth |
\(\mathrm{\frac{bit}{s}}\) |
|
catalytic activity |
\(\mathrm{\frac{mol}{s}}\) |
|
chemical potential |
\(\mathrm{\frac{J}{mol}}\) |
|
column density |
\(\mathrm{\frac{1}{m^{2}}}\) |
|
compressibility |
\(\mathrm{\frac{1}{Pa}}\) |
|
crackle |
\(\mathrm{\frac{m}{s^{5}}}\) |
|
data quantity |
\(\mathrm{bit}\) |
|
diffusivity |
\(\mathrm{\frac{m^{2}}{s}}\) |
kinematic viscosity |
dimensionless |
\(\mathrm{}\) |
|
dynamic viscosity |
\(\mathrm{\frac{g}{m\,s}}\) |
|
electrical capacitance |
\(\mathrm{F}\) |
|
electrical charge |
\(\mathrm{C}\) |
|
electrical charge (EMU) |
\(\mathrm{abC}\) |
|
electrical charge (ESU) |
\(\mathrm{Fr}\) |
|
electrical charge density |
\(\mathrm{\frac{C}{m^{3}}}\) |
|
electrical conductance |
\(\mathrm{S}\) |
|
electrical conductivity |
\(\mathrm{\frac{S}{m}}\) |
|
electrical current |
\(\mathrm{A}\) |
|
electrical current (EMU) |
\(\mathrm{Bi}\) |
|
electrical current (ESU) |
\(\mathrm{statA}\) |
|
electrical current density |
\(\mathrm{\frac{A}{m^{2}}}\) |
|
electrical dipole moment |
\(\mathrm{C\,m}\) |
|
electrical field strength |
\(\mathrm{\frac{V}{m}}\) |
|
electrical flux density |
\(\mathrm{\frac{C}{m^{2}}}\) |
polarization density, surface charge density |
electrical impedance |
\(\mathrm{\Omega}\) |
electrical reactance, electrical resistance |
electrical mobility |
\(\mathrm{\frac{m^{2}}{V\,s}}\) |
|
electrical potential |
\(\mathrm{V}\) |
|
electrical reactance |
\(\mathrm{\Omega}\) |
electrical impedance, electrical resistance |
electrical resistance |
\(\mathrm{\Omega}\) |
electrical impedance, electrical reactance |
electrical resistivity |
\(\mathrm{\Omega\,m}\) |
|
electromagnetic field strength |
\(\mathrm{\frac{H}{m}}\) |
permeability |
electron density |
\(\mathrm{\frac{e^{-}}{m^{3}}}\) |
|
electron flux |
\(\mathrm{\frac{e^{-}}{s\,m^{2}}}\) |
|
energy |
\(\mathrm{J}\) |
torque, work |
energy density |
\(\mathrm{Pa}\) |
pressure, stress |
energy flux |
\(\mathrm{\frac{J}{s\,m^{2}}}\) |
irradiance |
entropy |
\(\mathrm{\frac{J}{K}}\) |
heat capacity |
force |
\(\mathrm{N}\) |
|
frequency |
\(\mathrm{Hz}\) |
|
frequency drift |
\(\mathrm{\frac{1}{s^{2}}}\) |
|
heat capacity |
\(\mathrm{\frac{J}{K}}\) |
entropy |
illuminance |
\(\mathrm{lx}\) |
luminous emittance |
impulse |
\(\mathrm{\frac{kg\,m}{s}}\) |
momentum |
inductance |
\(\mathrm{H}\) |
|
irradiance |
\(\mathrm{\frac{J}{s\,m^{2}}}\) |
energy flux |
jerk |
\(\mathrm{\frac{m}{s^{3}}}\) |
jolt |
jolt |
\(\mathrm{\frac{m}{s^{3}}}\) |
jerk |
jounce |
\(\mathrm{\frac{m}{s^{4}}}\) |
snap |
kinematic viscosity |
\(\mathrm{\frac{m^{2}}{s}}\) |
diffusivity |
length |
\(\mathrm{m}\) |
|
linear density |
\(\mathrm{\frac{kg}{m}}\) |
|
luminance |
\(\mathrm{\frac{cd}{m^{2}}}\) |
|
luminous efficacy |
\(\mathrm{\frac{lm}{W}}\) |
|
luminous emittance |
\(\mathrm{lx}\) |
illuminance |
luminous flux |
\(\mathrm{lm}\) |
|
luminous intensity |
\(\mathrm{cd}\) |
|
magnetic field strength |
\(\mathrm{\frac{A}{m}}\) |
|
magnetic flux |
\(\mathrm{Wb}\) |
|
magnetic flux density |
\(\mathrm{T}\) |
|
magnetic moment |
\(\mathrm{m^{2}\,A}\) |
|
magnetic reluctance |
\(\mathrm{\frac{1}{H}}\) |
|
mass |
\(\mathrm{g}\) |
|
mass attenuation coefficient |
\(\mathrm{\frac{m^{2}}{kg}}\) |
opacity |
mass density |
\(\mathrm{\frac{kg}{m^{3}}}\) |
|
mass flux |
\(\mathrm{\frac{kg}{s\,m^{2}}}\) |
momentum density |
molality |
\(\mathrm{\frac{mol}{kg}}\) |
|
molar concentration |
\(\mathrm{\frac{mol}{m^{3}}}\) |
|
molar conductivity |
\(\mathrm{\frac{m^{2}\,S}{mol}}\) |
|
molar heat capacity |
\(\mathrm{\frac{J}{K\,mol}}\) |
|
molar volume |
\(\mathrm{\frac{m^{3}}{mol}}\) |
|
moment of inertia |
\(\mathrm{m^{2}\,kg}\) |
|
momentum |
\(\mathrm{\frac{kg\,m}{s}}\) |
impulse |
momentum density |
\(\mathrm{\frac{kg}{s\,m^{2}}}\) |
mass flux |
number density |
\(\mathrm{\frac{1}{m^{3}}}\) |
|
opacity |
\(\mathrm{\frac{m^{2}}{kg}}\) |
mass attenuation coefficient |
particle flux |
\(\mathrm{\frac{1}{s\,m^{2}}}\) |
|
permeability |
\(\mathrm{\frac{H}{m}}\) |
electromagnetic field strength |
permittivity |
\(\mathrm{\frac{F}{m}}\) |
|
photon flux |
\(\mathrm{R}\) |
|
photon flux density |
\(\mathrm{\frac{ph}{Hz\,s\,cm^{2}}}\) |
|
photon flux density wav |
\(\mathrm{\frac{ph}{\mathring{A}\,s\,cm^{2}}}\) |
|
plate scale |
\(\mathrm{\frac{rad}{m}}\) |
|
polarization density |
\(\mathrm{\frac{C}{m^{2}}}\) |
electrical flux density, surface charge density |
pop |
\(\mathrm{\frac{m}{s^{6}}}\) |
pounce |
pounce |
\(\mathrm{\frac{m}{s^{6}}}\) |
pop |
power |
\(\mathrm{W}\) |
radiant flux |
power density |
\(\mathrm{\frac{J}{s\,m^{3}}}\) |
spectral flux density wav |
pressure |
\(\mathrm{Pa}\) |
energy density, stress |
radiance |
\(\mathrm{\frac{W}{sr\,m^{2}}}\) |
|
radiant flux |
\(\mathrm{W}\) |
power |
radiant intensity |
\(\mathrm{\frac{W}{sr}}\) |
|
reaction rate |
\(\mathrm{\frac{mol}{s\,m^{3}}}\) |
|
snap |
\(\mathrm{\frac{m}{s^{4}}}\) |
jounce |
solid angle |
\(\mathrm{sr}\) |
|
specific energy |
\(\mathrm{\frac{J}{kg}}\) |
|
specific entropy |
\(\mathrm{\frac{J}{K\,kg}}\) |
specific heat capacity |
specific heat capacity |
\(\mathrm{\frac{J}{K\,kg}}\) |
specific entropy |
specific volume |
\(\mathrm{\frac{m^{3}}{kg}}\) |
|
spectral flux density |
\(\mathrm{Jy}\) |
|
spectral flux density wav |
\(\mathrm{\frac{J}{s\,m^{3}}}\) |
power density |
speed |
\(\mathrm{\frac{m}{s}}\) |
velocity |
stress |
\(\mathrm{Pa}\) |
energy density, pressure |
surface charge density |
\(\mathrm{\frac{C}{m^{2}}}\) |
electrical flux density, polarization density |
surface mass density |
\(\mathrm{\frac{kg}{m^{2}}}\) |
|
surface tension |
\(\mathrm{\frac{m^{2}\,W}{Hz}}\) |
|
temperature |
\(\mathrm{K}\) |
|
temperature gradient |
\(\mathrm{\frac{K}{m}}\) |
|
thermal conductance |
\(\mathrm{\frac{W}{K}}\) |
|
thermal conductivity |
\(\mathrm{\frac{W}{K\,m}}\) |
|
thermal resistance |
\(\mathrm{\frac{K}{W}}\) |
|
thermal resistivity |
\(\mathrm{\frac{K\,m}{W}}\) |
|
time |
\(\mathrm{s}\) |
|
torque |
\(\mathrm{J}\) |
energy, work |
velocity |
\(\mathrm{\frac{m}{s}}\) |
speed |
volume |
\(\mathrm{m^{3}}\) |
|
volumetric flow rate |
\(\mathrm{\frac{m^{3}}{s}}\) |
|
volumetric rate |
\(\mathrm{\frac{1}{s\,m^{3}}}\) |
|
wavenumber |
\(\mathrm{\frac{1}{m}}\) |
|
work |
\(\mathrm{J}\) |
energy, torque |
yank |
\(\mathrm{\frac{N}{s}}\) |
Functions¶
|
Add a mapping between a unit and the corresponding physical type(s). |
|
Return the physical type that corresponds to a unit (or another physical type representation). |
Classes¶
|
Represents the physical type(s) that are dimensionally compatible with a set of units. |
Class Inheritance Diagram¶
astropy.units.equivalencies Module¶
A set of standard astronomical equivalencies.
Functions¶
|
Returns a list of equivalence pairs that handle the conversion between parallax angle and distance. |
|
Returns a list of equivalence pairs that handle spectral wavelength, wave number, frequency, and energy equivalencies. |
|
Returns a list of equivalence pairs that handle spectral density with regard to wavelength and frequency. |
|
Return the equivalency pairs for the radio convention for velocity. |
|
Return the equivalency pairs for the optical convention for velocity. |
|
Return the equivalency pairs for the relativistic convention for velocity. |
Returns the equivalence between Doppler redshift (unitless) and radial velocity. |
|
Returns a list of equivalence pairs that handle the conversion between mass and energy. |
|
|
Defines the conversion between Jy/sr and "brightness temperature", \(T_B\), in Kelvins. |
|
Defines the conversion between Jy/sr and "thermodynamic temperature", \(T_{CMB}\), in Kelvins. |
|
Convert between the |
Allow angles to be equivalent to dimensionless (with 1 rad = 1 m/m = 1). |
|
Allow logarithmic units to be converted to dimensionless fractions |
|
Convert between Kelvin, Celsius, Rankine and Fahrenheit here because Unit and CompositeUnit cannot do addition or subtraction properly. |
|
Convert between Kelvin and keV(eV) to an equivalent amount. |
|
Returns the equivalence between amu and molar mass. |
|
|
Convert between pixel distances (in units of |
|
Convert between lengths (to be interpreted as lengths in the focal plane) and angular units with a specified |
Classes¶
|
A container for a units equivalency. |
Class Inheritance Diagram¶
astropy.units.function.core Module¶
Function Units and Quantities.
Classes¶
|
Abstract base class for function units. |
|
A representation of a (scaled) function of a number with a unit. |
Class Inheritance Diagram¶
astropy.units.function.logarithmic Module¶
Classes¶
|
Logarithmic unit containing a physical one |
|
Logarithmic physical units expressed in magnitudes |
|
Logarithmic physical units expressed in magnitudes |
|
Logarithmic physical units expressed in dB |
|
A representation of a (scaled) logarithm of a number with a unit |
|
|
|
|
|
Variables¶
ST magnitude: STmag=-21.1 corresponds to 1 erg/s/cm2/A |
|
AB magnitude: ABmag=-48.6 corresponds to 1 erg/s/cm2/Hz |
|
Absolute bolometric magnitude: M_bol=0 corresponds to L_bol0=3.0128e+28 J / s |
|
Apparent bolometric magnitude: m_bol=0 corresponds to f_bol0=2.51802e-08 kg / s3 |
Class Inheritance Diagram¶
astropy.units.deprecated Module¶
This package defines deprecated units.
These units are not available in the top-level astropy.units
namespace. To use these units, you must import the astropy.units.deprecated
module:
>>> from astropy.units import deprecated
>>> q = 10. * deprecated.emu
To include them in compose
and the results of
find_equivalent_units
, do:
>>> from astropy.units import deprecated
>>> deprecated.enable()
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
|
Biot: CGS (EMU) unit of current |
\(\mathrm{Bi}\) |
No |
|
Prefixes for |
Earth mass prefixes |
\(\mathrm{5.9721679 \times 10^{24}\,kg}\) |
|
Only |
Prefixes for |
Earth radius prefixes |
\(\mathrm{6378100\,m}\) |
|
Only |
Prefixes for |
Jupiter mass prefixes |
\(\mathrm{1.8981246 \times 10^{27}\,kg}\) |
|
Only |
Prefixes for |
Jupiter radius prefixes |
\(\mathrm{71492000\,m}\) |
|
Only |
Functions¶
|
Enable deprecated units so they appear in results of |
astropy.units.required_by_vounit Module¶
This package defines SI prefixed units that are required by the VOUnit standard
but that are rarely used in practice and liable to lead to confusion (such as
msolMass
for milli-solar mass). They are in a separate module from
astropy.units.deprecated
because they need to be enabled by default for
astropy.units
to parse compliant VOUnit strings. As a result, e.g.,
Unit('msolMass')
will just work, but to access the unit directly, use
astropy.units.required_by_vounit.msolMass
instead of the more typical idiom
possible for the non-prefixed unit, astropy.units.solMass
.
Unit |
Description |
Represents |
Aliases |
SI Prefixes |
---|---|---|---|---|
Prefixes for |
Solar luminance prefixes |
\(\mathrm{3.828 \times 10^{26}\,W}\) |
|
Only |
Prefixes for |
Solar mass prefixes |
\(\mathrm{1.9884099 \times 10^{30}\,kg}\) |
|
Only |
Prefixes for |
Solar radius prefixes |
\(\mathrm{6.957 \times 10^{8}\,m}\) |
|
Only |