CONSTANT_OF_GRAVITATION = Constant(
    name='Constant of gravitation',
    value=6.67428e-11,
    unit='m3 / (kg s2)',
    uncertainty=6.7e-15,
    reference='IAU 2009/2012 System of Astronomical Constants') MERCURY_RADIUS_EQUATORIAL = Constant(
    name='Equatorial radius of Mercury',
    value=2439.9,
    unit='km',
    uncertainty=1,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') MERCURY_RADIUS_POLAR = Constant(
    name='Polar radius of Mercury',
    value=2439.9,
    unit='km',
    uncertainty=1,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') VENUS_RADIUS_EQUATORIAL = Constant(
    name='Equatorial radius of Venus',
    value=6051.8,
    unit='km',
    uncertainty=1,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') VENUS_RADIUS_POLAR = Constant(
    name='Polar radius of Venus',
    value=6051.8,
    unit='km',
    uncertainty=1,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') MARS_RADIUS_EQUATORIAL = Constant(
    name='Equatorial radius of Mars',
    value=3396.19,
    unit='km',
    uncertainty=0.1,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') MARS_RADIUS_POLAR = Constant(
    name='Polar radius of Mars',
    value=3376.20,
    unit='km',
    uncertainty=0.1,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') JUPITER_RADIUS_EQUATORIAL = Constant(
    name='Equatorial radius of Jupiter',
    value=71492,
    unit='km',
    uncertainty=4,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') JUPITER_RADIUS_POLAR = Constant(
    name='Polar radius of Jupiter',
    value=66854,
    unit='km',
    uncertainty=10,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') SATURN_RADIUS_EQUATORIAL = Constant(
    name='Equatorial radius of Saturn',
    value=60268,
    unit='km',
    uncertainty=4,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') SATURN_RADIUS_POLAR = Constant(
    name='Polar radius of Saturn',
    value=54364,
    unit='km',
    uncertainty=10,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') URANUS_RADIUS_EQUATORIAL = Constant(
    name='Equatorial radius of Uranus',
    value=25559,
    unit='km',
    uncertainty=4,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') URANUS_RADIUS_POLAR = Constant(
    name='Polar radius of Uranus',
    value=24973,
    unit='km',
    uncertainty=20,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') NEPTUNE_RADIUS_EQUATORIAL = Constant(
    name='Equatorial radius of Neptune',
    value=24764,
    unit='km',
    uncertainty=15,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') NEPTUNE_RADIUS_POLAR = Constant(
    name='Polar radius of Neptune',
    value=24341,
    unit='km',
    uncertainty=30,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') PLUTO_RADIUS_EQUATORIAL = Constant(
    name='Equatorial radius of Pluto (134340)',
    value=1195,
    unit='km',
    uncertainty=5,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') PLUTO_RADIUS_POLAR = Constant(
    name='Polar radius of Pluto (134340)',
    value=1195,
    unit='km',
    uncertainty=5,
    reference='IAU WG on Cartographic Coordinates and Rotational Elements 2009') MERCURY_MASS = SUN_MASS / MASS_RATIO_SUN_TO_MERCURY VENUS_MASS = SUN_MASS / MASS_RATIO_SUN_TO_VENUS MARS_MASS = SUN_MASS / MASS_RATIO_SUN_TO_MARS JUPITER_MASS = SUN_MASS / MASS_RATIO_SUN_TO_JUPITER SATURN_MASS = SUN_MASS / MASS_RATIO_SUN_TO_SATURN URANUS_MASS = SUN_MASS / MASS_RATIO_SUN_TO_URANUS NEPTUNE_MASS = SUN_MASS / MASS_RATIO_SUN_TO_NEPTUNE PLUTO_MASS = SUN_MASS / MASS_RATIO_SUN_TO_PLUTO def read_only_property(name, docstring=None):
    """Return property for accessing attribute with name `name`

    Parameters:
        name: Attribute name
        docstring: Optional docstring for getter.

    Example:
        .. code-block:: python

            class Circle:
                def __init__(self, radius):
                    self._radius = radius

                radius = read_only_property('_radius')
    """
    def fget(self):
        return getattr(self, name)

    fget.__doc__ = docstring
    return property(fget) def verify_unit(quantity, unit):
    """Verify unit of passed quantity and return it.

    Parameters:
        quantity: :py:class:`~astropy.units.Quantity` to be verified. Bare
                  numbers are valid if the unit is dimensionless.
        unit: Equivalent unit, or string parsable by
              :py:class:`astropy.units.Unit`

    Raises:
        ValueError: Units are not equivalent.

    Returns:
        ``quantity`` unchanged. Bare numbers will be converted to a dimensionless
        :py:class:`~astropy.units.Quantity`.

    Example:
        .. code-block:: python

            def __init__(self, a):
                self.a = verify_unit(a, astropy.units.m)

    """
    if not isinstance(unit, UnitBase):
        unit = Unit(unit)

    q = quantity * u.one
    if unit.is_equivalent(q.unit):
        return q
    else:
        raise ValueError(
            "Unit '{}' not equivalent to quantity '{}'.".format(unit, quantity)) class Ellipsoid(ReprHelperMixin, object):
class ReferenceEllipsoid(Ellipsoid):
    def __init__(self, a, b=None, f=None):
    def _repr_helper_(self, r):
    def __init__(self, a, f, mu, spin):
    def _repr_helper_(self, r):
from astropy.units import Quantity
from represent import ReprHelperMixin
from ..constants import (
    CONSTANT_OF_GRAVITATION, JUPITER_MASS, JUPITER_RADIUS_EQUATORIAL,
    JUPITER_RADIUS_POLAR, MARS_MASS, MARS_RADIUS_EQUATORIAL, MARS_RADIUS_POLAR,
    MERCURY_MASS, MERCURY_RADIUS_EQUATORIAL, MERCURY_RADIUS_POLAR,
    NEPTUNE_MASS, NEPTUNE_RADIUS_EQUATORIAL, NEPTUNE_RADIUS_POLAR, PLUTO_MASS,
    PLUTO_RADIUS_EQUATORIAL, PLUTO_RADIUS_POLAR, SATURN_MASS,
    SATURN_RADIUS_EQUATORIAL, SATURN_RADIUS_POLAR, URANUS_MASS,
    URANUS_RADIUS_EQUATORIAL, URANUS_RADIUS_POLAR, VENUS_MASS,
    VENUS_RADIUS_EQUATORIAL, VENUS_RADIUS_POLAR)
from ..utils import read_only_property, verify_unit
from .ellipsoid import Ellipsoid, wgs84
# coding: utf-8
from __future__ import absolute_import, division, print_function



__all__ = (
    'CelestialBody',
    'mercury',
    'venus',
    'earth',
    'mars',
    'jupiter',
    'saturn',
    'uranus',
    'neptune',
    'pluto',
)


class CelestialBody(ReprHelperMixin, object):
    """Celestial body.

    Parameters:
        name: Name of the celestial body.
        ellipsoid: Representative ellipsoid.
        mu: Standard gravitational parameter [m\ :sup:`3`\ ·s\ :sup:`-2`]
        naif_id: :term:`NAIF ID` for body.

    :type ellipsoid: :py:class:`~astrodynamics.bodies.ellipsoid.Ellipsoid`
    """
    def __init__(self, name, ellipsoid, mu, naif_id):
        self.name = name
        self._ellipsoid = ellipsoid
        self._mu = verify_unit(mu, 'm3 / s2')
        self._naif_id = naif_id

        self._mass = verify_unit(mu / CONSTANT_OF_GRAVITATION, 'kg')

    @classmethod
    def from_reference_ellipsoid(cls, name, ellipsoid, naif_id):
        """Construct from a
        :py:class:`~astrodynamics.bodies.ellipsoid.ReferenceEllipsoid`, which
        provides ``mu``.

        Parameters:
            name: Name of the celestial body.
            ellipsoid: Representative ellipsoid.
            naif_id: :term:`NAIF ID` for celestial body.

        :type ellipsoid: :py:class:`~astrodynamics.bodies.ellipsoid.ReferenceEllipsoid`
        """
        return cls(name=name, ellipsoid=ellipsoid, mu=ellipsoid.mu, naif_id=naif_id)

    ellipsoid = read_only_property('_ellipsoid')
    mu = read_only_property('_mu')
    mass = read_only_property('_mass')

    def _repr_helper_(self, r):
        r.keyword_from_attr('name')
        r.keyword_from_attr('ellipsoid')
        # View as Quantity to prevent full Constant repr.
        r.keyword_with_value('mu', self.mu.view(Quantity))
        r.keyword_from_attr('naif_id', '_naif_id')


G = CONSTANT_OF_GRAVITATION

mercury = CelestialBody(
    name='Mercury',

    ellipsoid=Ellipsoid(a=MERCURY_RADIUS_EQUATORIAL, b=MERCURY_RADIUS_POLAR),