This subpackage contains classes and functions for defining and converting between different physical units, as well as the units themselves.
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# Classes# Class Inheritance Diagram# astropy.units.si Module#This package defines the SI units. They are also available in (and should be used through) the astropy.units
namespace.
This package defines the CGS units. They are also available in (and should be used through) the astropy.units
namespace.
This package defines the astrophysics-specific units. They are also available in (and should be used through) the astropy.units
namespace.
This package defines miscellaneous units. They are also available in (and should be used through) the astropy.units
namespace.
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.
It also defines a few commonly used magnitude unit instances, like STmag, for which the physical units are defined in astropy.units.photometric
.
All units are also available in (and should be used through) the astropy.units
namespace.
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 astropy.units.function.units
).
Both the units and magnitudes are available in (and should be used through) the astropy.units
namespace.
Colloquially used Imperial units.
These units 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()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()
Note, however, that this can introduce conflicts between CDS and other units in the top-level namespace. A safer way to use CDS units is to enable them inside a context manager. For instance, you could do the following if you have a string that uses CDS units:
>>> import astropy.units as u >>> unit_string = "mmHg" >>> with cds.enable(): ... pressure_unit = u.Unit(unit_string) >>> (720*pressure_unit).to(u.bar) <Quantity 0.95992119 bar>Functions# astropy.units.physical Module#
Defines the physical types that correspond to different units.
The classes and functions defined here are also available in (and should be used through) the astropy.units
namespace.
A collection of different unit formats.
General usage is by their name in the UnitBase
constructor or in the to_string()
method, i.e., these classes rarely if ever need to be imported directly.
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). The units here are enabled so, 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
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4