Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ New Features
- Added furlong to imperial units. [#3529]
- Added mil to imperial units. [#3716]
- Added stone to imperial units. [#4192]
- Added Earth Mass (``M_earth``) and Jupiter mass (``M_jup``) to units [#3907]

- Added support for functional units, in particular the logarithmic ones
``Magnitude``, ``Decibel``, and ``Dex``. [#1894]
Expand Down
10 changes: 9 additions & 1 deletion astropy/units/astrophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
def_unit(['solMass', 'M_sun', 'Msun'], _si.M_sun.value * si.kg, namespace=_ns,
prefixes=True, doc="Solar mass",
format={'latex': r'M_{\odot}', 'unicode': 'M⊙'})
def_unit(['jupiterMass', 'M_jup', 'Mjup','M_jupiter', 'Mjupiter'],
_si.M_jup.value * si.kg, namespace=_ns,
prefixes=True, doc="Jupiter mass",
# LaTeX jupiter symbol requires wasysym
format={'latex': r'M_{\rm J}', 'unicode': 'M♃'})
def_unit(['earthMass', 'M_earth', 'Mearth'], _si.M_earth.value * si.kg, namespace=_ns,
prefixes=True, doc="Earth mass",
# LaTeX earth symbol requires wasysym
format={'latex': r'M_{\oplus}', 'unicode': 'M⊕'})
def_unit(['M_p'], _si.m_p.value * si.kg, namespace=_ns,
doc="Proton mass",
format={'latex': r'M_{p}', 'unicode': 'Mₚ'})
Expand All @@ -65,7 +74,6 @@
prefixes=True, exclude_prefixes=['a', 'da'],
doc="Unified atomic mass unit")


##########################################################################
# ENERGY

Expand Down
4 changes: 2 additions & 2 deletions astropy/units/cds.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _initialize_module():
(['G'], _si.G, "Gravitation constant"),
(['g'], u.g, "gram"),
(['gauss'], u.G, "Gauss"),
(['geoMass', 'Mgeo'], _si.M_earth, "Earth mass"),
(['geoMass', 'Mgeo'], u.M_earth, "Earth mass"),
(['H'], u.H, "Henry"),
(['h'], u.h, "hour", ['p']),
(['hr'], u.h, "hour"),
Expand All @@ -85,7 +85,7 @@ def _initialize_module():
(['inch'], 0.0254 * u.m, "inch"),
(['J'], u.J, "Joule"),
(['JD'], u.d, "Julian day", ['M']),
(['jovMass', 'Mjup'], _si.M_jup, "Jupiter mass"),
(['jovMass', 'Mjup'], u.M_jup, "Jupiter mass"),
(['Jy'], u.Jy, "Jansky"),
(['K'], u.K, "Kelvin"),
(['k'], _si.k_B, "Boltzmann"),
Expand Down
4 changes: 2 additions & 2 deletions astropy/units/tests/test_equivalencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ def test_equivalent_units():
units = u.g.find_equivalent_units()
units_set = set(units)
match = set(
[u.M_e, u.M_p, u.g, u.kg, u.solMass, u.t, u.u,
imperial.oz, imperial.lb, imperial.st, imperial.ton])
[u.M_e, u.M_p, u.g, u.kg, u.solMass, u.t, u.u, u.M_earth,
u.M_jup, imperial.oz, imperial.lb, imperial.st, imperial.ton])
assert units_set == match

r = repr(units)
Expand Down
1 change: 0 additions & 1 deletion astropy/units/tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,6 @@ def test_fractional_rounding_errors_simple():

def test_enable_unit_groupings():
from ...units import cds
assert cds.geoMass not in u.kg.find_equivalent_units()

with cds.enable():
assert cds.geoMass in u.kg.find_equivalent_units()
Expand Down
16 changes: 9 additions & 7 deletions docs/units/standard_units.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ all the existing predefined units of a given type::
>>> u.g.find_equivalent_units()
Primary name | Unit definition | Aliases
[
M_e | 9.10938e-31 kg | ,
M_p | 1.67262e-27 kg | ,
g | 0.001 kg | gram ,
kg | irreducible | kilogram ,
solMass | 1.9891e+30 kg | M_sun, Msun ,
t | 1000 kg | tonne ,
u | 1.66054e-27 kg | Da, Dalton ,
M_e | 9.10938e-31 kg | ,
M_p | 1.67262e-27 kg | ,
earthMass | 5.9742e+24 kg | M_earth, Mearth ,
g | 0.001 kg | gram ,
jupiterMass | 1.8987e+27 kg | M_jup, Mjup, M_jupiter, Mjupiter ,
kg | irreducible | kilogram ,
solMass | 1.9891e+30 kg | M_sun, Msun ,
t | 1000 kg | tonne ,
u | 1.66054e-27 kg | Da, Dalton ,
]

The dimensionless unit
Expand Down