Dataset Viewer
repo
stringclasses 10
values | instance_id
stringlengths 18
32
| html_url
stringlengths 41
55
| feature_patch
stringlengths 805
8.42M
| test_patch
stringlengths 548
207k
| doc_changes
listlengths 0
92
| version
stringclasses 57
values | base_commit
stringlengths 40
40
| PASS2PASS
listlengths 0
3.51k
| FAIL2PASS
listlengths 0
5.17k
| augmentations
dict | mask_doc_diff
listlengths 0
92
| problem_statement
stringlengths 0
54.8k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
astropy/astropy
|
astropy__astropy-14763
|
https://github.com/astropy/astropy/pull/14763
|
diff --git a/astropy/coordinates/earth.py b/astropy/coordinates/earth.py
index f7f1eba81a40..88c5f7672057 100644
--- a/astropy/coordinates/earth.py
+++ b/astropy/coordinates/earth.py
@@ -8,39 +8,29 @@
import urllib.request
from warnings import warn
-import erfa
import numpy as np
from astropy import constants as consts
from astropy import units as u
from astropy.units.quantity import QuantityInfoBase
from astropy.utils import data
-from astropy.utils.decorators import format_doc
from astropy.utils.exceptions import AstropyUserWarning
from .angles import Angle, Latitude, Longitude
from .errors import UnknownSiteException
from .matrix_utilities import matrix_transpose
from .representation import (
- BaseRepresentation,
CartesianDifferential,
CartesianRepresentation,
)
+from .representation.geodetic import ELLIPSOIDS
__all__ = [
"EarthLocation",
- "BaseGeodeticRepresentation",
- "WGS84GeodeticRepresentation",
- "WGS72GeodeticRepresentation",
- "GRS80GeodeticRepresentation",
]
GeodeticLocation = collections.namedtuple("GeodeticLocation", ["lon", "lat", "height"])
-ELLIPSOIDS = {}
-"""Available ellipsoids (defined in erfam.h, with numbers exposed in erfa)."""
-# Note: they get filled by the creation of the geodetic classes.
-
OMEGA_EARTH = (1.002_737_811_911_354_48 * u.cycle / u.day).to(
1 / u.s, u.dimensionless_angles()
)
@@ -905,87 +895,3 @@ def _to_value(self, unit, equivalencies=[]):
equivalencies = self._equivalencies
new_array = self.unit.to(unit, array_view, equivalencies=equivalencies)
return new_array.view(self.dtype).reshape(self.shape)
-
-
-geodetic_base_doc = """{__doc__}
-
- Parameters
- ----------
- lon, lat : angle-like
- The longitude and latitude of the point(s), in angular units. The
- latitude should be between -90 and 90 degrees, and the longitude will
- be wrapped to an angle between 0 and 360 degrees. These can also be
- instances of `~astropy.coordinates.Angle` and either
- `~astropy.coordinates.Longitude` not `~astropy.coordinates.Latitude`,
- depending on the parameter.
- height : `~astropy.units.Quantity` ['length']
- The height to the point(s).
- copy : bool, optional
- If `True` (default), arrays will be copied. If `False`, arrays will
- be references, though possibly broadcast to ensure matching shapes.
-
-"""
-
-
-@format_doc(geodetic_base_doc)
-class BaseGeodeticRepresentation(BaseRepresentation):
- """Base geodetic representation."""
-
- attr_classes = {"lon": Longitude, "lat": Latitude, "height": u.Quantity}
-
- def __init_subclass__(cls, **kwargs):
- super().__init_subclass__(**kwargs)
- if "_ellipsoid" in cls.__dict__:
- ELLIPSOIDS[cls._ellipsoid] = cls
-
- def __init__(self, lon, lat=None, height=None, copy=True):
- if height is None and not isinstance(lon, self.__class__):
- height = 0 << u.m
-
- super().__init__(lon, lat, height, copy=copy)
- if not self.height.unit.is_equivalent(u.m):
- raise u.UnitTypeError(
- f"{self.__class__.__name__} requires height with units of length."
- )
-
- def to_cartesian(self):
- """
- Converts WGS84 geodetic coordinates to 3D rectangular (geocentric)
- cartesian coordinates.
- """
- xyz = erfa.gd2gc(
- getattr(erfa, self._ellipsoid), self.lon, self.lat, self.height
- )
- return CartesianRepresentation(xyz, xyz_axis=-1, copy=False)
-
- @classmethod
- def from_cartesian(cls, cart):
- """
- Converts 3D rectangular cartesian coordinates (assumed geocentric) to
- WGS84 geodetic coordinates.
- """
- lon, lat, height = erfa.gc2gd(
- getattr(erfa, cls._ellipsoid), cart.get_xyz(xyz_axis=-1)
- )
- return cls(lon, lat, height, copy=False)
-
-
-@format_doc(geodetic_base_doc)
-class WGS84GeodeticRepresentation(BaseGeodeticRepresentation):
- """Representation of points in WGS84 3D geodetic coordinates."""
-
- _ellipsoid = "WGS84"
-
-
-@format_doc(geodetic_base_doc)
-class WGS72GeodeticRepresentation(BaseGeodeticRepresentation):
- """Representation of points in WGS72 3D geodetic coordinates."""
-
- _ellipsoid = "WGS72"
-
-
-@format_doc(geodetic_base_doc)
-class GRS80GeodeticRepresentation(BaseGeodeticRepresentation):
- """Representation of points in GRS80 3D geodetic coordinates."""
-
- _ellipsoid = "GRS80"
diff --git a/astropy/coordinates/representation/__init__.py b/astropy/coordinates/representation/__init__.py
index 13356d1f78fd..f91d47e3ae56 100644
--- a/astropy/coordinates/representation/__init__.py
+++ b/astropy/coordinates/representation/__init__.py
@@ -6,6 +6,12 @@
from .base import BaseRepresentationOrDifferential, BaseRepresentation, BaseDifferential
from .cartesian import CartesianRepresentation, CartesianDifferential
from .cylindrical import CylindricalRepresentation, CylindricalDifferential
+from .geodetic import (
+ BaseGeodeticRepresentation,
+ WGS84GeodeticRepresentation,
+ WGS72GeodeticRepresentation,
+ GRS80GeodeticRepresentation,
+)
from .spherical import (
SphericalRepresentation,
UnitSphericalRepresentation,
@@ -49,4 +55,8 @@
"RadialDifferential",
"CylindricalDifferential",
"PhysicsSphericalDifferential",
+ "BaseGeodeticRepresentation",
+ "WGS84GeodeticRepresentation",
+ "WGS72GeodeticRepresentation",
+ "GRS80GeodeticRepresentation",
]
diff --git a/astropy/coordinates/representation/geodetic.py b/astropy/coordinates/representation/geodetic.py
new file mode 100644
index 000000000000..6663199a1fd2
--- /dev/null
+++ b/astropy/coordinates/representation/geodetic.py
@@ -0,0 +1,121 @@
+# Licensed under a 3-clause BSD style license - see LICENSE.rst
+
+import erfa
+
+from astropy import units as u
+from astropy.coordinates.angles import Latitude, Longitude
+from astropy.utils.decorators import format_doc
+
+from .base import BaseRepresentation
+from .cartesian import CartesianRepresentation
+
+
+ELLIPSOIDS = {}
+"""Available ellipsoids (defined in erfam.h, with numbers exposed in erfa)."""
+# Note: they get filled by the creation of the geodetic classes.
+
+
+geodetic_base_doc = """{__doc__}
+
+ Parameters
+ ----------
+ lon, lat : angle-like
+ The longitude and latitude of the point(s), in angular units. The
+ latitude should be between -90 and 90 degrees, and the longitude will
+ be wrapped to an angle between 0 and 360 degrees. These can also be
+ instances of `~astropy.coordinates.Angle` and either
+ `~astropy.coordinates.Longitude` not `~astropy.coordinates.Latitude`,
+ depending on the parameter.
+
+ height : `~astropy.units.Quantity` ['length']
+ The height to the point(s).
+
+ copy : bool, optional
+ If `True` (default), arrays will be copied. If `False`, arrays will
+ be references, though possibly broadcast to ensure matching shapes.
+"""
+
+
+@format_doc(geodetic_base_doc)
+class BaseGeodeticRepresentation(BaseRepresentation):
+ """
+ Base class for geodetic representations.
+
+ Subclasses need to set attributes ``_equatorial_radius`` and ``_flattening``
+ to quantities holding correct values (with units of length and dimensionless,
+ respectively), or alternatively an ``_ellipsoid`` attribute to the relevant ERFA
+ index (as passed in to `erfa.eform`).
+ """
+
+ attr_classes = {"lon": Longitude, "lat": Latitude, "height": u.Quantity}
+
+ def __init_subclass__(cls, **kwargs):
+ if "_ellipsoid" in cls.__dict__:
+ equatorial_radius, flattening = erfa.eform(getattr(erfa, cls._ellipsoid))
+ cls._equatorial_radius = equatorial_radius * u.m
+ cls._flattening = flattening * u.dimensionless_unscaled
+ ELLIPSOIDS[cls._ellipsoid] = cls
+ elif (
+ "_equatorial_radius" not in cls.__dict__
+ or "_flattening" not in cls.__dict__
+ ):
+ raise AttributeError(
+ f"{cls.__name__} requires '_ellipsoid' or '_equatorial_radius' and '_flattening'."
+ )
+ super().__init_subclass__(**kwargs)
+
+ def __init__(self, lon, lat=None, height=None, copy=True):
+ if height is None and not isinstance(lon, self.__class__):
+ height = 0 << u.m
+
+ super().__init__(lon, lat, height, copy=copy)
+ if not self.height.unit.is_equivalent(u.m):
+ raise u.UnitTypeError(
+ f"{self.__class__.__name__} requires height with units of length."
+ )
+
+ def to_cartesian(self):
+ """
+ Converts geodetic coordinates to 3D rectangular (geocentric)
+ cartesian coordinates.
+ """
+ xyz = erfa.gd2gce(
+ self._equatorial_radius,
+ self._flattening,
+ self.lon,
+ self.lat,
+ self.height,
+ )
+ return CartesianRepresentation(xyz, xyz_axis=-1, copy=False)
+
+ @classmethod
+ def from_cartesian(cls, cart):
+ """
+ Converts 3D rectangular cartesian coordinates (assumed geocentric) to
+ geodetic coordinates.
+ """
+ lon, lat, height = erfa.gc2gde(
+ cls._equatorial_radius, cls._flattening, cart.get_xyz(xyz_axis=-1)
+ )
+ return cls(lon, lat, height, copy=False)
+
+
+@format_doc(geodetic_base_doc)
+class WGS84GeodeticRepresentation(BaseGeodeticRepresentation):
+ """Representation of points in WGS84 3D geodetic coordinates."""
+
+ _ellipsoid = "WGS84"
+
+
+@format_doc(geodetic_base_doc)
+class WGS72GeodeticRepresentation(BaseGeodeticRepresentation):
+ """Representation of points in WGS72 3D geodetic coordinates."""
+
+ _ellipsoid = "WGS72"
+
+
+@format_doc(geodetic_base_doc)
+class GRS80GeodeticRepresentation(BaseGeodeticRepresentation):
+ """Representation of points in GRS80 3D geodetic coordinates."""
+
+ _ellipsoid = "GRS80"
diff --git a/astropy/units/quantity_helper/erfa.py b/astropy/units/quantity_helper/erfa.py
index b8cc02ca47ed..ae5b0ed10a54 100644
--- a/astropy/units/quantity_helper/erfa.py
+++ b/astropy/units/quantity_helper/erfa.py
@@ -104,7 +104,7 @@ def helper_gc2gde(f, unit_r, unit_flat, unit_xyz):
return [
get_converter(unit_r, m),
- get_converter(unit_flat, dimensionless_unscaled),
+ get_converter(_d(unit_flat), dimensionless_unscaled),
get_converter(unit_xyz, m),
], (
radian,
@@ -138,7 +138,7 @@ def helper_gd2gce(f, unit_r, unit_flat, unit_long, unit_lat, unit_h):
return [
get_converter(unit_r, m),
- get_converter(unit_flat, dimensionless_unscaled),
+ get_converter(_d(unit_flat), dimensionless_unscaled),
get_converter(unit_long, radian),
get_converter(unit_lat, radian),
get_converter(unit_h, m),
diff --git a/docs/changes/coordinates/14763.feature.rst b/docs/changes/coordinates/14763.feature.rst
new file mode 100644
index 000000000000..d4733abb2abc
--- /dev/null
+++ b/docs/changes/coordinates/14763.feature.rst
@@ -0,0 +1,4 @@
+Support has been added to create geodetic representations not just for existing ellipsoids
+from ERFA, but also with explicitly provided values, by defining a subclass of
+``BaseGeodeticRepresentation`` with the equatorial radius and flattening assigned to
+``_equatorial_radius`` and ``_flattening`` attributes.
diff --git a/docs/coordinates/representations.rst b/docs/coordinates/representations.rst
index 8d66fab1ede8..dc496fade830 100644
--- a/docs/coordinates/representations.rst
+++ b/docs/coordinates/representations.rst
@@ -31,6 +31,24 @@ The built-in representation classes are:
cylindrical polar coordinates, represented by a cylindrical radius
(``rho``), azimuthal angle (``phi``), and height (``z``).
+
+Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` useful to
+create specific representations on spheroidal bodies.
+This is used internally for the standard Earth ellipsoids used in
+`~astropy.coordinates.EarthLocation`
+(`~astropy.coordinates.WGS84GeodeticRepresentation`,
+`~astropy.coordinates.WGS72GeodeticRepresentation`, and
+`~astropy.coordinates.GRS80GeodeticRepresentation`), but
+can also be customized; see :ref:`astropy-coordinates-create-geodetic`.
+All these are coordinates on a surface of a spheroid (an ellipsoid with equal
+equatorial radii), represented by a longitude (``lon``) a geodetical latitude (``lat``)
+and a height (``height``) above the surface.
+The geodetical latitude is defined by the angle
+between the vertical to the surface at a specific point of the spheroid and its
+projection onto the equatorial plane.
+The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360
+degrees.
+
.. Note::
For information about using and changing the representation of
`~astropy.coordinates.SkyCoord` objects, see the
@@ -685,3 +703,21 @@ In pseudo-code, this means that a class will look like::
class MyDifferential(BaseDifferential):
base_representation = MyRepresentation
+
+.. _astropy-coordinates-create-geodetic:
+
+Creating Your Own Geodetic Representation
+-----------------------------------------
+
+If you would like to use geodetic coordinates on planetary bodies other than the Earth,
+you can define a new class that inherits from `~astropy.coordinates.BaseGeodeticRepresentation`.
+The equatorial radius and flattening must be both assigned via the attributes
+`_equatorial_radius` and `_flattening`.
+
+For example the spheroid describing Mars as in the
+`1979 IAU standard <https://doi.org/10.1007/BF01229508>`_ could be defined like::
+
+ class IAUMARS1979GeodeticRepresentation(BaseGeodeticRepresentation):
+
+ _equatorial_radius = 3393400.0 * u.m
+ _flattening = 0.518650 * u.percent
diff --git a/docs/whatsnew/6.0.rst b/docs/whatsnew/6.0.rst
index 055b5eb86aa0..bf5407a6810a 100644
--- a/docs/whatsnew/6.0.rst
+++ b/docs/whatsnew/6.0.rst
@@ -12,7 +12,7 @@ the 5.3 release.
In particular, this release includes:
-* nothing yet
+* :ref:`whatsnew-6.0-geodetic-representation-geometry`
In addition to these major changes, Astropy v6.0 includes a large number of
smaller improvements and bug fixes, which are described in the :ref:`changelog`.
@@ -22,6 +22,32 @@ By the numbers:
* X pull requests have been merged since v5.3
* X distinct people have contributed code
+.. _whatsnew-6.0-geodetic-representation-geometry:
+
+Define Geodetic Representations via their geometric parameters
+==============================================================
+
+The user may now define custom spheroidal models for the Earth or other planetary
+bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defining
+``_equatorial_radius`` and ``_flattening`` attributes::
+
+
+ >>> from astropy.coordinates import BaseGeodeticRepresentation, WGS84GeodeticRepresentation
+ >>> from astropy import units as u
+ >>> class IAU1976EarthGeodeticRepresentation(BaseGeodeticRepresentation):
+ ... _equatorial_radius = 6378140 * u.m
+ ... _flattening = 0.3352805 * u.percent
+ >>> representation = IAU1976EarthGeodeticRepresentation(lon=45.8366*u.deg,
+ ... lat=56.1499*u.deg, height=367*u.m)
+ >>> representation.to_cartesian() # doctest: +FLOAT_CMP
+ <CartesianRepresentation (x, y, z) in m
+ (2481112.60371134, 2554647.09482601, 5274064.55958489)>
+ >>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP
+ <WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)
+ (0.79999959, 0.98000063, 370.01796023)>
+
+See :ref:`astropy-coordinates-create-geodetic` for more details.
+
Full change log
===============
|
diff --git a/astropy/coordinates/tests/test_earth.py b/astropy/coordinates/tests/test_earth.py
index e21c390e72ff..0c8c3a140bfb 100644
--- a/astropy/coordinates/tests/test_earth.py
+++ b/astropy/coordinates/tests/test_earth.py
@@ -10,8 +10,9 @@
from astropy import constants
from astropy import units as u
from astropy.coordinates.angles import Latitude, Longitude
-from astropy.coordinates.earth import ELLIPSOIDS, EarthLocation
+from astropy.coordinates.earth import EarthLocation
from astropy.coordinates.name_resolve import NameResolveError
+from astropy.coordinates.representation.geodetic import ELLIPSOIDS
from astropy.time import Time
from astropy.units import allclose as quantity_allclose
from astropy.units.tests.test_quantity_erfa_ufuncs import vvd
diff --git a/astropy/coordinates/tests/test_geodetic_representations.py b/astropy/coordinates/tests/test_geodetic_representations.py
index dd3012cfe45e..0a5d4ccee13d 100644
--- a/astropy/coordinates/tests/test_geodetic_representations.py
+++ b/astropy/coordinates/tests/test_geodetic_representations.py
@@ -2,49 +2,68 @@
"""Test geodetic representations"""
import pytest
-from numpy.testing import assert_array_equal
from astropy import units as u
-from astropy.coordinates.earth import (
+from astropy.coordinates.representation import (
+ CartesianRepresentation,
+ REPRESENTATION_CLASSES,
+ BaseGeodeticRepresentation,
GRS80GeodeticRepresentation,
WGS72GeodeticRepresentation,
WGS84GeodeticRepresentation,
)
-from astropy.coordinates.representation import CartesianRepresentation
-from astropy.units import allclose as quantity_allclose
+from astropy.coordinates.representation.geodetic import ELLIPSOIDS
+from astropy.tests.helper import assert_quantity_allclose
+from astropy.units.tests.test_quantity_erfa_ufuncs import vvd
+
+# Preserve the original REPRESENTATION_CLASSES dict so that importing
+# the test file doesn't add a persistent test subclass
+from astropy.coordinates.tests.test_representation import ( # noqa: F401
+ setup_function,
+ teardown_function,
+)
+
+class CustomGeodetic(BaseGeodeticRepresentation):
+ _flattening = 0.01832
+ _equatorial_radius = 4000000.0 * u.m
-def test_cartesian_wgs84geodetic_roundtrip():
+
+@pytest.mark.parametrize(
+ "geodeticrepresentation", [CustomGeodetic, WGS84GeodeticRepresentation]
+)
+def test_cartesian_geodetic_roundtrip(geodeticrepresentation):
# Test array-valued input in the process.
- s1 = CartesianRepresentation(
+ initial_cartesian = CartesianRepresentation(
x=[1, 3000.0] * u.km, y=[7000.0, 4.0] * u.km, z=[5.0, 6000.0] * u.km
)
- s2 = WGS84GeodeticRepresentation.from_representation(s1)
+ transformed = geodeticrepresentation.from_representation(initial_cartesian)
- s3 = CartesianRepresentation.from_representation(s2)
+ roundtripped = CartesianRepresentation.from_representation(transformed)
- s4 = WGS84GeodeticRepresentation.from_representation(s3)
+ assert_quantity_allclose(initial_cartesian.x, roundtripped.x)
+ assert_quantity_allclose(initial_cartesian.y, roundtripped.y)
+ assert_quantity_allclose(initial_cartesian.z, roundtripped.z)
- assert quantity_allclose(s1.x, s3.x)
- assert quantity_allclose(s1.y, s3.y)
- assert quantity_allclose(s1.z, s3.z)
- assert quantity_allclose(s2.lon, s4.lon)
- assert quantity_allclose(s2.lat, s4.lat)
- assert quantity_allclose(s2.height, s4.height)
-
- # Test initializer just for the sake of it.
- s5 = WGS84GeodeticRepresentation(s2.lon, s2.lat, s2.height)
+@pytest.mark.parametrize(
+ "geodeticrepresentation", [CustomGeodetic, WGS84GeodeticRepresentation]
+)
+def test_geodetic_cartesian_roundtrip(geodeticrepresentation):
+ initial_geodetic = geodeticrepresentation(
+ lon=[0.8, 1.3] * u.radian,
+ lat=[0.3, 0.98] * u.radian,
+ height=[100.0, 367.0] * u.m,
+ )
- assert_array_equal(s2.lon, s5.lon)
- assert_array_equal(s2.lat, s5.lat)
- assert_array_equal(s2.height, s5.height)
+ transformed = CartesianRepresentation.from_representation(initial_geodetic)
+ roundtripped = geodeticrepresentation.from_representation(transformed)
-def vvd(val, valok, dval, func, test, status):
- """Mimic routine of erfa/src/t_erfa_c.c (to help copy & paste)"""
- assert quantity_allclose(val, valok * val.unit, atol=dval * val.unit)
+ assert_quantity_allclose(initial_geodetic.lon, roundtripped.lon)
+ assert_quantity_allclose(initial_geodetic.lat, roundtripped.lat)
+ assert_quantity_allclose(initial_geodetic.height, roundtripped.height)
def test_geocentric_to_geodetic():
@@ -118,3 +137,26 @@ def test_non_angle_error():
def test_non_length_error():
with pytest.raises(u.UnitTypeError, match="units of length"):
WGS84GeodeticRepresentation(10 * u.deg, 20 * u.deg, 30)
+
+
+def test_geodetic_subclass_bad_ellipsoid():
+ # Test incomplete initialization.
+
+ msg = "module 'erfa' has no attribute 'foo'"
+ with pytest.raises(AttributeError, match=msg):
+
+ class InvalidCustomGeodeticEllipsoid(BaseGeodeticRepresentation):
+ _ellipsoid = "foo"
+
+ assert "foo" not in ELLIPSOIDS
+ assert "customgeodeticellipsoiderror" not in REPRESENTATION_CLASSES
+
+
+def test_geodetic_subclass_missing_equatorial_radius():
+ msg = "MissingCustomGeodeticAttribute requires '_ellipsoid' or '_equatorial_radius' and '_flattening'."
+ with pytest.raises(AttributeError, match=msg):
+
+ class MissingCustomGeodeticAttribute(BaseGeodeticRepresentation):
+ _flattening = 0.075 * u.dimensionless_unscaled
+
+ assert "customgeodeticerror" not in REPRESENTATION_CLASSES
|
[
{
"path": "docs/changes/coordinates/14763.feature.rst",
"old_path": "/dev/null",
"new_path": "b/docs/changes/coordinates/14763.feature.rst",
"metadata": "diff --git a/docs/changes/coordinates/14763.feature.rst b/docs/changes/coordinates/14763.feature.rst\nnew file mode 100644\nindex 000000000000..d4733abb2abc\n--- /dev/null\n+++ b/docs/changes/coordinates/14763.feature.rst\n@@ -0,0 +1,4 @@\n+Support has been added to create geodetic representations not just for existing ellipsoids\n+from ERFA, but also with explicitly provided values, by defining a subclass of\n+``BaseGeodeticRepresentation`` with the equatorial radius and flattening assigned to\n+``_equatorial_radius`` and ``_flattening`` attributes.\n"
},
{
"path": "docs/coordinates/representations.rst",
"old_path": "a/docs/coordinates/representations.rst",
"new_path": "b/docs/coordinates/representations.rst",
"metadata": "diff --git a/docs/coordinates/representations.rst b/docs/coordinates/representations.rst\nindex 8d66fab1ede8..dc496fade830 100644\n--- a/docs/coordinates/representations.rst\n+++ b/docs/coordinates/representations.rst\n@@ -31,6 +31,24 @@ The built-in representation classes are:\n cylindrical polar coordinates, represented by a cylindrical radius\n (``rho``), azimuthal angle (``phi``), and height (``z``).\n \n+\n+Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` useful to\n+create specific representations on spheroidal bodies.\n+This is used internally for the standard Earth ellipsoids used in\n+`~astropy.coordinates.EarthLocation`\n+(`~astropy.coordinates.WGS84GeodeticRepresentation`,\n+`~astropy.coordinates.WGS72GeodeticRepresentation`, and\n+`~astropy.coordinates.GRS80GeodeticRepresentation`), but\n+can also be customized; see :ref:`astropy-coordinates-create-geodetic`.\n+All these are coordinates on a surface of a spheroid (an ellipsoid with equal\n+equatorial radii), represented by a longitude (``lon``) a geodetical latitude (``lat``)\n+and a height (``height``) above the surface.\n+The geodetical latitude is defined by the angle\n+between the vertical to the surface at a specific point of the spheroid and its\n+projection onto the equatorial plane.\n+The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360\n+degrees.\n+\n .. Note::\n For information about using and changing the representation of\n `~astropy.coordinates.SkyCoord` objects, see the\n@@ -685,3 +703,21 @@ In pseudo-code, this means that a class will look like::\n \n class MyDifferential(BaseDifferential):\n base_representation = MyRepresentation\n+\n+.. _astropy-coordinates-create-geodetic:\n+\n+Creating Your Own Geodetic Representation\n+-----------------------------------------\n+\n+If you would like to use geodetic coordinates on planetary bodies other than the Earth,\n+you can define a new class that inherits from `~astropy.coordinates.BaseGeodeticRepresentation`.\n+The equatorial radius and flattening must be both assigned via the attributes\n+`_equatorial_radius` and `_flattening`.\n+\n+For example the spheroid describing Mars as in the\n+`1979 IAU standard <https://doi.org/10.1007/BF01229508>`_ could be defined like::\n+\n+ class IAUMARS1979GeodeticRepresentation(BaseGeodeticRepresentation):\n+\n+ _equatorial_radius = 3393400.0 * u.m\n+ _flattening = 0.518650 * u.percent\n"
},
{
"path": "docs/whatsnew/6.0.rst",
"old_path": "a/docs/whatsnew/6.0.rst",
"new_path": "b/docs/whatsnew/6.0.rst",
"metadata": "diff --git a/docs/whatsnew/6.0.rst b/docs/whatsnew/6.0.rst\nindex 055b5eb86aa0..bf5407a6810a 100644\n--- a/docs/whatsnew/6.0.rst\n+++ b/docs/whatsnew/6.0.rst\n@@ -12,7 +12,7 @@ the 5.3 release.\n \n In particular, this release includes:\n \n-* nothing yet\n+* :ref:`whatsnew-6.0-geodetic-representation-geometry`\n \n In addition to these major changes, Astropy v6.0 includes a large number of\n smaller improvements and bug fixes, which are described in the :ref:`changelog`.\n@@ -22,6 +22,32 @@ By the numbers:\n * X pull requests have been merged since v5.3\n * X distinct people have contributed code\n \n+.. _whatsnew-6.0-geodetic-representation-geometry:\n+\n+Define Geodetic Representations via their geometric parameters\n+==============================================================\n+\n+The user may now define custom spheroidal models for the Earth or other planetary\n+bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defining\n+``_equatorial_radius`` and ``_flattening`` attributes::\n+\n+\n+ >>> from astropy.coordinates import BaseGeodeticRepresentation, WGS84GeodeticRepresentation\n+ >>> from astropy import units as u\n+ >>> class IAU1976EarthGeodeticRepresentation(BaseGeodeticRepresentation):\n+ ... _equatorial_radius = 6378140 * u.m\n+ ... _flattening = 0.3352805 * u.percent\n+ >>> representation = IAU1976EarthGeodeticRepresentation(lon=45.8366*u.deg,\n+ ... lat=56.1499*u.deg, height=367*u.m)\n+ >>> representation.to_cartesian() # doctest: +FLOAT_CMP\n+ <CartesianRepresentation (x, y, z) in m\n+ (2481112.60371134, 2554647.09482601, 5274064.55958489)>\n+ >>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP\n+ <WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)\n+ (0.79999959, 0.98000063, 370.01796023)>\n+\n+See :ref:`astropy-coordinates-create-geodetic` for more details.\n+\n Full change log\n ===============\n \n"
}
] |
6.0
|
eadcd73a38639e9695ecb2190b65e045b445d0ea
|
[] |
[
"astropy/coordinates/tests/test_earth.py::TestInput::test_invalid_input",
"astropy/coordinates/tests/test_geodetic_representations.py::test_non_length_error",
"astropy/coordinates/tests/test_earth.py::TestInput::test_ellipsoid[WGS84]",
"astropy/coordinates/tests/test_earth.py::TestInput::test_attribute_classes",
"astropy/coordinates/tests/test_geodetic_representations.py::test_non_angle_error",
"astropy/coordinates/tests/test_geodetic_representations.py::test_cartesian_geodetic_roundtrip[CustomGeodetic]",
"astropy/coordinates/tests/test_earth.py::TestInput::test_ellipsoid[WGS72]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_cartesian_roundtrip[WGS84GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_cartesian_geodetic_roundtrip[WGS84GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_to_geocentric",
"astropy/coordinates/tests/test_earth.py::test_pickling",
"astropy/coordinates/tests/test_earth.py::test_info",
"astropy/coordinates/tests/test_earth.py::TestInput::test_invalid_ellipsoid",
"astropy/coordinates/tests/test_earth.py::TestInput::test_slicing",
"astropy/coordinates/tests/test_earth.py::test_gd2gc",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_subclass_bad_ellipsoid",
"astropy/coordinates/tests/test_earth.py::TestInput::test_ellipsoid[GRS80]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_default_height_is_zero",
"astropy/coordinates/tests/test_earth.py::TestInput::test_geo_attributes",
"astropy/coordinates/tests/test_earth.py::test_gc2gd",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_cartesian_roundtrip[CustomGeodetic]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_subclass_missing_equatorial_radius",
"astropy/coordinates/tests/test_earth.py::TestInput::test_default_ellipsoid",
"astropy/coordinates/tests/test_earth.py::test_read_only_input",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geocentric_to_geodetic",
"astropy/coordinates/tests/test_earth.py::test_repr_latex",
"astropy/coordinates/tests/test_earth.py::TestInput::test_input",
"astropy/coordinates/tests/test_earth.py::test_geodetic_tuple"
] |
{
"header": "If completing this task requires creating new files, classes, fields, or error messages, you may consider using the following suggested entity names:",
"data": [
{
"type": "file",
"name": "astropy/coordinates/representation/geodetic.py"
},
{
"type": "field",
"name": "_ellipsoid"
},
{
"type": "field",
"name": "AttributeError"
},
{
"type": "field",
"name": "dimensionless_unscaled"
},
{
"type": "field",
"name": "ELLIPSOIDS"
}
]
}
|
[
{
"path": "docs/changes/coordinates/<PRID>.feature.rst",
"old_path": "/dev/null",
"new_path": "b/docs/changes/coordinates/<PRID>.feature.rst",
"metadata": "diff --git a/docs/changes/coordinates/<PRID>.feature.rst b/docs/changes/coordinates/<PRID>.feature.rst\nnew file mode 100644\nindex 000000000000..d4733abb2abc\n--- /dev/null\n+++ b/docs/changes/coordinates/<PRID>.feature.rst\n@@ -0,0 +1,4 @@\n+Support has been added to create geodetic representations not just for existing ellipsoids\n+from ERFA, but also with explicitly provided values, by defining a subclass of\n+``BaseGeodeticRepresentation`` with the equatorial radius and flattening assigned to\n+``_equatorial_radius`` and ``_flattening`` attributes.\n"
},
{
"path": "docs/coordinates/representations.rst",
"old_path": "a/docs/coordinates/representations.rst",
"new_path": "b/docs/coordinates/representations.rst",
"metadata": "diff --git a/docs/coordinates/representations.rst b/docs/coordinates/representations.rst\nindex 8d66fab1ede8..dc496fade830 100644\n--- a/docs/coordinates/representations.rst\n+++ b/docs/coordinates/representations.rst\n@@ -31,6 +31,24 @@ The built-in representation classes are:\n cylindrical polar coordinates, represented by a cylindrical radius\n (``rho``), azimuthal angle (``phi``), and height (``z``).\n \n+\n+Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` useful to\n+create specific representations on spheroidal bodies.\n+This is used internally for the standard Earth ellipsoids used in\n+`~astropy.coordinates.EarthLocation`\n+(`~astropy.coordinates.WGS84GeodeticRepresentation`,\n+`~astropy.coordinates.WGS72GeodeticRepresentation`, and\n+`~astropy.coordinates.GRS80GeodeticRepresentation`), but\n+can also be customized; see :ref:`astropy-coordinates-create-geodetic`.\n+All these are coordinates on a surface of a spheroid (an ellipsoid with equal\n+equatorial radii), represented by a longitude (``lon``) a geodetical latitude (``lat``)\n+and a height (``height``) above the surface.\n+The geodetical latitude is defined by the angle\n+between the vertical to the surface at a specific point of the spheroid and its\n+projection onto the equatorial plane.\n+The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360\n+degrees.\n+\n .. Note::\n For information about using and changing the representation of\n `~astropy.coordinates.SkyCoord` objects, see the\n@@ -685,3 +703,21 @@ In pseudo-code, this means that a class will look like::\n \n class MyDifferential(BaseDifferential):\n base_representation = MyRepresentation\n+\n+.. _astropy-coordinates-create-geodetic:\n+\n+Creating Your Own Geodetic Representation\n+-----------------------------------------\n+\n+If you would like to use geodetic coordinates on planetary bodies other than the Earth,\n+you can define a new class that inherits from `~astropy.coordinates.BaseGeodeticRepresentation`.\n+The equatorial radius and flattening must be both assigned via the attributes\n+`_equatorial_radius` and `_flattening`.\n+\n+For example the spheroid describing Mars as in the\n+`1979 IAU standard <https://doi.org/10.1007/BF01229508>`_ could be defined like::\n+\n+ class IAUMARS1979GeodeticRepresentation(BaseGeodeticRepresentation):\n+\n+ _equatorial_radius = 3393400.0 * u.m\n+ _flattening = 0.518650 * u.percent\n"
},
{
"path": "docs/whatsnew/6.0.rst",
"old_path": "a/docs/whatsnew/6.0.rst",
"new_path": "b/docs/whatsnew/6.0.rst",
"metadata": "diff --git a/docs/whatsnew/6.0.rst b/docs/whatsnew/6.0.rst\nindex 055b5eb86aa0..bf5407a6810a 100644\n--- a/docs/whatsnew/6.0.rst\n+++ b/docs/whatsnew/6.0.rst\n@@ -12,7 +12,7 @@ the 5.3 release.\n \n In particular, this release includes:\n \n-* nothing yet\n+* :ref:`whatsnew-6.0-geodetic-representation-geometry`\n \n In addition to these major changes, Astropy v6.0 includes a large number of\n smaller improvements and bug fixes, which are described in the :ref:`changelog`.\n@@ -22,6 +22,32 @@ By the numbers:\n * X pull requests have been merged since v5.3\n * X distinct people have contributed code\n \n+.. _whatsnew-6.0-geodetic-representation-geometry:\n+\n+Define Geodetic Representations via their geometric parameters\n+==============================================================\n+\n+The user may now define custom spheroidal models for the Earth or other planetary\n+bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defining\n+``_equatorial_radius`` and ``_flattening`` attributes::\n+\n+\n+ >>> from astropy.coordinates import BaseGeodeticRepresentation, WGS84GeodeticRepresentation\n+ >>> from astropy import units as u\n+ >>> class IAU1976EarthGeodeticRepresentation(BaseGeodeticRepresentation):\n+ ... _equatorial_radius = 6378140 * u.m\n+ ... _flattening = 0.3352805 * u.percent\n+ >>> representation = IAU1976EarthGeodeticRepresentation(lon=45.8366*u.deg,\n+ ... lat=56.1499*u.deg, height=367*u.m)\n+ >>> representation.to_cartesian() # doctest: +FLOAT_CMP\n+ <CartesianRepresentation (x, y, z) in m\n+ (2481112.60371134, 2554647.09482601, 5274064.55958489)>\n+ >>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP\n+ <WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)\n+ (0.79999959, 0.98000063, 370.01796023)>\n+\n+See :ref:`astropy-coordinates-create-geodetic` for more details.\n+\n Full change log\n ===============\n \n"
}
] |
diff --git a/docs/changes/coordinates/<PRID>.feature.rst b/docs/changes/coordinates/<PRID>.feature.rst
new file mode 100644
index 000000000000..d4733abb2abc
--- /dev/null
+++ b/docs/changes/coordinates/<PRID>.feature.rst
@@ -0,0 +1,4 @@
+Support has been added to create geodetic representations not just for existing ellipsoids
+from ERFA, but also with explicitly provided values, by defining a subclass of
+``BaseGeodeticRepresentation`` with the equatorial radius and flattening assigned to
+``_equatorial_radius`` and ``_flattening`` attributes.
diff --git a/docs/coordinates/representations.rst b/docs/coordinates/representations.rst
index 8d66fab1ede8..dc496fade830 100644
--- a/docs/coordinates/representations.rst
+++ b/docs/coordinates/representations.rst
@@ -31,6 +31,24 @@ The built-in representation classes are:
cylindrical polar coordinates, represented by a cylindrical radius
(``rho``), azimuthal angle (``phi``), and height (``z``).
+
+Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` useful to
+create specific representations on spheroidal bodies.
+This is used internally for the standard Earth ellipsoids used in
+`~astropy.coordinates.EarthLocation`
+(`~astropy.coordinates.WGS84GeodeticRepresentation`,
+`~astropy.coordinates.WGS72GeodeticRepresentation`, and
+`~astropy.coordinates.GRS80GeodeticRepresentation`), but
+can also be customized; see :ref:`astropy-coordinates-create-geodetic`.
+All these are coordinates on a surface of a spheroid (an ellipsoid with equal
+equatorial radii), represented by a longitude (``lon``) a geodetical latitude (``lat``)
+and a height (``height``) above the surface.
+The geodetical latitude is defined by the angle
+between the vertical to the surface at a specific point of the spheroid and its
+projection onto the equatorial plane.
+The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360
+degrees.
+
.. Note::
For information about using and changing the representation of
`~astropy.coordinates.SkyCoord` objects, see the
@@ -685,3 +703,21 @@ In pseudo-code, this means that a class will look like::
class MyDifferential(BaseDifferential):
base_representation = MyRepresentation
+
+.. _astropy-coordinates-create-geodetic:
+
+Creating Your Own Geodetic Representation
+-----------------------------------------
+
+If you would like to use geodetic coordinates on planetary bodies other than the Earth,
+you can define a new class that inherits from `~astropy.coordinates.BaseGeodeticRepresentation`.
+The equatorial radius and flattening must be both assigned via the attributes
+`_equatorial_radius` and `_flattening`.
+
+For example the spheroid describing Mars as in the
+`1979 IAU standard <https://doi.org/10.1007/BF01229508>`_ could be defined like::
+
+ class IAUMARS1979GeodeticRepresentation(BaseGeodeticRepresentation):
+
+ _equatorial_radius = 3393400.0 * u.m
+ _flattening = 0.518650 * u.percent
diff --git a/docs/whatsnew/6.0.rst b/docs/whatsnew/6.0.rst
index 055b5eb86aa0..bf5407a6810a 100644
--- a/docs/whatsnew/6.0.rst
+++ b/docs/whatsnew/6.0.rst
@@ -12,7 +12,7 @@ the 5.3 release.
In particular, this release includes:
-* nothing yet
+* :ref:`whatsnew-6.0-geodetic-representation-geometry`
In addition to these major changes, Astropy v6.0 includes a large number of
smaller improvements and bug fixes, which are described in the :ref:`changelog`.
@@ -22,6 +22,32 @@ By the numbers:
* X pull requests have been merged since v5.3
* X distinct people have contributed code
+.. _whatsnew-6.0-geodetic-representation-geometry:
+
+Define Geodetic Representations via their geometric parameters
+==============================================================
+
+The user may now define custom spheroidal models for the Earth or other planetary
+bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defining
+``_equatorial_radius`` and ``_flattening`` attributes::
+
+
+ >>> from astropy.coordinates import BaseGeodeticRepresentation, WGS84GeodeticRepresentation
+ >>> from astropy import units as u
+ >>> class IAU1976EarthGeodeticRepresentation(BaseGeodeticRepresentation):
+ ... _equatorial_radius = 6378140 * u.m
+ ... _flattening = 0.3352805 * u.percent
+ >>> representation = IAU1976EarthGeodeticRepresentation(lon=45.8366*u.deg,
+ ... lat=56.1499*u.deg, height=367*u.m)
+ >>> representation.to_cartesian() # doctest: +FLOAT_CMP
+ <CartesianRepresentation (x, y, z) in m
+ (2481112.60371134, 2554647.09482601, 5274064.55958489)>
+ >>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP
+ <WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)
+ (0.79999959, 0.98000063, 370.01796023)>
+
+See :ref:`astropy-coordinates-create-geodetic` for more details.
+
Full change log
===============
If completing this task requires creating new files, classes, fields, or error messages, you may consider using the following suggested entity names:
[{'type': 'file', 'name': 'astropy/coordinates/representation/geodetic.py'}, {'type': 'field', 'name': '_ellipsoid'}, {'type': 'field', 'name': 'AttributeError'}, {'type': 'field', 'name': 'dimensionless_unscaled'}, {'type': 'field', 'name': 'ELLIPSOIDS'}]
|
astropy/astropy
|
astropy__astropy-14851
|
https://github.com/astropy/astropy/pull/14851
|
diff --git a/astropy/coordinates/representation/__init__.py b/astropy/coordinates/representation/__init__.py
index f91d47e3ae56..e92af318ba87 100644
--- a/astropy/coordinates/representation/__init__.py
+++ b/astropy/coordinates/representation/__init__.py
@@ -8,6 +8,7 @@
from .cylindrical import CylindricalRepresentation, CylindricalDifferential
from .geodetic import (
BaseGeodeticRepresentation,
+ BaseBodycentricRepresentation,
WGS84GeodeticRepresentation,
WGS72GeodeticRepresentation,
GRS80GeodeticRepresentation,
@@ -56,6 +57,7 @@
"CylindricalDifferential",
"PhysicsSphericalDifferential",
"BaseGeodeticRepresentation",
+ "BaseBodycentricRepresentation",
"WGS84GeodeticRepresentation",
"WGS72GeodeticRepresentation",
"GRS80GeodeticRepresentation",
diff --git a/astropy/coordinates/representation/geodetic.py b/astropy/coordinates/representation/geodetic.py
index 6663199a1fd2..3fef88947acc 100644
--- a/astropy/coordinates/representation/geodetic.py
+++ b/astropy/coordinates/representation/geodetic.py
@@ -1,5 +1,6 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
+import numpy as np
import erfa
from astropy import units as u
@@ -44,7 +45,9 @@ class BaseGeodeticRepresentation(BaseRepresentation):
Subclasses need to set attributes ``_equatorial_radius`` and ``_flattening``
to quantities holding correct values (with units of length and dimensionless,
respectively), or alternatively an ``_ellipsoid`` attribute to the relevant ERFA
- index (as passed in to `erfa.eform`).
+ index (as passed in to `erfa.eform`). The geodetic latitude is defined by the
+ angle between the vertical to the surface at a specific point of the spheroid and
+ its projection onto the equatorial plane.
"""
attr_classes = {"lon": Longitude, "lat": Latitude, "height": u.Quantity}
@@ -94,12 +97,81 @@ def from_cartesian(cls, cart):
Converts 3D rectangular cartesian coordinates (assumed geocentric) to
geodetic coordinates.
"""
+ # Compute geodetic/planetodetic angles
lon, lat, height = erfa.gc2gde(
cls._equatorial_radius, cls._flattening, cart.get_xyz(xyz_axis=-1)
)
return cls(lon, lat, height, copy=False)
+@format_doc(geodetic_base_doc)
+class BaseBodycentricRepresentation(BaseRepresentation):
+ """Representation of points in bodycentric 3D coordinates.
+
+ Subclasses need to set attributes ``_equatorial_radius`` and ``_flattening``
+ to quantities holding correct values (with units of length and dimensionless,
+ respectively). the bodycentric latitude and longitude are spherical latitude
+ and longitude relative to the barycenter of the body.
+ """
+
+ attr_classes = {"lon": Longitude, "lat": Latitude, "height": u.Quantity}
+
+ def __init_subclass__(cls, **kwargs):
+ if (
+ "_equatorial_radius" not in cls.__dict__
+ or "_flattening" not in cls.__dict__
+ ):
+ raise AttributeError(
+ f"{cls.__name__} requires '_equatorial_radius' and '_flattening'."
+ )
+ super().__init_subclass__(**kwargs)
+
+ def __init__(self, lon, lat=None, height=None, copy=True):
+ if height is None and not isinstance(lon, self.__class__):
+ height = 0 << u.m
+
+ super().__init__(lon, lat, height, copy=copy)
+ if not self.height.unit.is_equivalent(u.m):
+ raise u.UnitTypeError(
+ f"{self.__class__.__name__} requires height with units of length."
+ )
+
+ def to_cartesian(self):
+ """
+ Converts bodycentric coordinates to 3D rectangular (geocentric)
+ cartesian coordinates.
+ """
+ coslat = np.cos(self.lat)
+ sinlat = np.sin(self.lat)
+ coslon = np.cos(self.lon)
+ sinlon = np.sin(self.lon)
+ r = (
+ self._equatorial_radius * np.hypot(coslat, (1 - self._flattening) * sinlat)
+ + self.height
+ )
+ x = r * coslon * coslat
+ y = r * sinlon * coslat
+ z = r * sinlat
+ return CartesianRepresentation(x=x, y=y, z=z, copy=False)
+
+ @classmethod
+ def from_cartesian(cls, cart):
+ """
+ Converts 3D rectangular cartesian coordinates (assumed geocentric) to
+ bodycentric coordinates.
+ """
+ # Compute bodycentric latitude
+ p = np.hypot(cart.x, cart.y)
+ d = np.hypot(p, cart.z)
+ lat = np.arctan2(cart.z, p)
+ p_spheroid = cls._equatorial_radius * np.cos(lat)
+ z_spheroid = cls._equatorial_radius * (1 - cls._flattening) * np.sin(lat)
+ r_spheroid = np.hypot(p_spheroid, z_spheroid)
+ height = d - r_spheroid
+ lon = np.arctan2(cart.y, cart.x)
+ return cls(lon, lat, height, copy=False)
+
+
@format_doc(geodetic_base_doc)
class WGS84GeodeticRepresentation(BaseGeodeticRepresentation):
"""Representation of points in WGS84 3D geodetic coordinates."""
diff --git a/docs/changes/coordinates/14851.feature.rst b/docs/changes/coordinates/14851.feature.rst
new file mode 100644
index 000000000000..c74e2aa8435c
--- /dev/null
+++ b/docs/changes/coordinates/14851.feature.rst
@@ -0,0 +1,2 @@
+Add ``BaseBodycentricRepresentation``, a new spheroidal representation for bodycentric
+latitudes and longitudes.
diff --git a/docs/coordinates/representations.rst b/docs/coordinates/representations.rst
index dc496fade830..a4408a71c279 100644
--- a/docs/coordinates/representations.rst
+++ b/docs/coordinates/representations.rst
@@ -32,23 +32,39 @@ The built-in representation classes are:
(``rho``), azimuthal angle (``phi``), and height (``z``).
-Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` useful to
+Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` and
+a `~astropy.coordinates.BaseBodycentricRepresentation` useful to
create specific representations on spheroidal bodies.
-This is used internally for the standard Earth ellipsoids used in
-`~astropy.coordinates.EarthLocation`
-(`~astropy.coordinates.WGS84GeodeticRepresentation`,
-`~astropy.coordinates.WGS72GeodeticRepresentation`, and
-`~astropy.coordinates.GRS80GeodeticRepresentation`), but
-can also be customized; see :ref:`astropy-coordinates-create-geodetic`.
-All these are coordinates on a surface of a spheroid (an ellipsoid with equal
-equatorial radii), represented by a longitude (``lon``) a geodetical latitude (``lat``)
+
+`~astropy.coordinates.BaseGeodeticRepresentation` is the coordinate representation on
+a surface of a spheroid (an ellipsoid with equal
+equatorial radii), represented by a longitude (``lon``) a geodetic latitude (``lat``)
and a height (``height``) above the surface.
-The geodetical latitude is defined by the angle
+The geodetic latitude is defined by the angle
between the vertical to the surface at a specific point of the spheroid and its
projection onto the equatorial plane.
The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360
+degrees, the height is the elevation above the surface of the spheroid (measured
+perpendicular to the surface).
+
+`~astropy.coordinates.BaseBodycentricRepresentation` is the coordinate representation
+recommended by the Cartographic Coordinates & Rotational Elements Working Group
+(see for example its `2019 report <https://rdcu.be/b32WL>`_): the bodycentric latitude
+and longitude are spherical latitude and longitude relative to the barycenter of the
+body, the height is the distance from the spheroid surface (measured radially).
+The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360
degrees.
+`~astropy.coordinates.BaseGeodeticRepresentation` is used internally for the standard
+Earth ellipsoids used in
+`~astropy.coordinates.EarthLocation`
+(`~astropy.coordinates.WGS84GeodeticRepresentation`,
+`~astropy.coordinates.WGS72GeodeticRepresentation`, and
+`~astropy.coordinates.GRS80GeodeticRepresentation`).
+`~astropy.coordinates.BaseGeodeticRepresentation` and
+`~astropy.coordinates.BaseBodycentricRepresentation`
+can be customized as described in :ref:`astropy-coordinates-create-geodetic`.
+
.. Note::
For information about using and changing the representation of
`~astropy.coordinates.SkyCoord` objects, see the
@@ -706,11 +722,13 @@ In pseudo-code, this means that a class will look like::
.. _astropy-coordinates-create-geodetic:
-Creating Your Own Geodetic Representation
------------------------------------------
+Creating Your Own Geodetic and Bodycentric Representations
+----------------------------------------------------------
If you would like to use geodetic coordinates on planetary bodies other than the Earth,
-you can define a new class that inherits from `~astropy.coordinates.BaseGeodeticRepresentation`.
+you can define a new class that inherits from
+`~astropy.coordinates.BaseGeodeticRepresentation` or
+`~astropy.coordinates.BaseBodycentricRepresentation`.
The equatorial radius and flattening must be both assigned via the attributes
`_equatorial_radius` and `_flattening`.
@@ -721,3 +739,11 @@ For example the spheroid describing Mars as in the
_equatorial_radius = 3393400.0 * u.m
_flattening = 0.518650 * u.percent
+
+The bodycentric coordinate system representing Mars as in the
+`2000 IAU standard <https://doi.org/10.1023/A:1013939327465>`_ could be defined as::
+
+ class IAUMARS2000BodycentricRepresentation(BaseBodycentricRepresentation):
+
+ _equatorial_radius = 3396190.0 * u.m
+ _flattening = 0.5886008 * u.percent
diff --git a/docs/whatsnew/6.0.rst b/docs/whatsnew/6.0.rst
index 86ad59e033e0..de25addd78b7 100644
--- a/docs/whatsnew/6.0.rst
+++ b/docs/whatsnew/6.0.rst
@@ -25,15 +25,17 @@ By the numbers:
.. _whatsnew-6.0-geodetic-representation-geometry:
-Define Geodetic Representations via their geometric parameters
-==============================================================
+Define Geodetic and Bodycentric Representations via their geometric parameters
+==============================================================================
The user may now define custom spheroidal models for the Earth or other planetary
-bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defining
+bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` or
+`~astropy.coordinates.BaseBodycentricRepresentation` and defining
``_equatorial_radius`` and ``_flattening`` attributes::
- >>> from astropy.coordinates import BaseGeodeticRepresentation, WGS84GeodeticRepresentation
+ >>> from astropy.coordinates import (BaseGeodeticRepresentation,
+ ... WGS84GeodeticRepresentation, BaseBodycentricRepresentation)
>>> from astropy import units as u
>>> class IAU1976EarthGeodeticRepresentation(BaseGeodeticRepresentation):
... _equatorial_radius = 6378140 * u.m
@@ -46,6 +48,12 @@ bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defi
>>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP
<WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)
(0.79999959, 0.98000063, 370.01796023)>
+ >>> class IAU1976EarthBodycentricRepresentation(BaseBodycentricRepresentation):
+ ... _equatorial_radius = 6378140 * u.m
+ ... _flattening = 0.3352805 * u.percent
+ >>> representation.represent_as(IAU1976EarthBodycentricRepresentation) # doctest: +FLOAT_CMP
+ <IAU1976EarthBodycentricRepresentation (lon, lat, height) in (rad, rad, m)
+ (0.79999959, 0.9768896, 336.12620429)>
See :ref:`astropy-coordinates-create-geodetic` for more details.
|
diff --git a/astropy/coordinates/tests/test_geodetic_representations.py b/astropy/coordinates/tests/test_geodetic_representations.py
index 0a5d4ccee13d..fb72255c02e3 100644
--- a/astropy/coordinates/tests/test_geodetic_representations.py
+++ b/astropy/coordinates/tests/test_geodetic_representations.py
@@ -8,6 +8,7 @@
CartesianRepresentation,
REPRESENTATION_CLASSES,
BaseGeodeticRepresentation,
+ BaseBodycentricRepresentation,
GRS80GeodeticRepresentation,
WGS72GeodeticRepresentation,
WGS84GeodeticRepresentation,
@@ -29,8 +30,46 @@ class CustomGeodetic(BaseGeodeticRepresentation):
_equatorial_radius = 4000000.0 * u.m
+class CustomSphericGeodetic(BaseGeodeticRepresentation):
+ _flattening = 0.0
+ _equatorial_radius = 4000000.0 * u.m
+
+
+class CustomSphericBodycentric(BaseBodycentricRepresentation):
+ _flattening = 0.0
+ _equatorial_radius = 4000000.0 * u.m
+
+
+class IAUMARS2000GeodeticRepresentation(BaseGeodeticRepresentation):
+ _equatorial_radius = 3396190.0 * u.m
+ _flattening = 0.5886007555512007 * u.percent
+
+
+class IAUMARS2000BodycentricRepresentation(BaseBodycentricRepresentation):
+ _equatorial_radius = 3396190.0 * u.m
+ _flattening = 0.5886007555512007 * u.percent
+
+
+def test_geodetic_bodycentric_equivalence_spherical_bodies():
+ initial_cartesian = CartesianRepresentation(
+ x=[1, 3000.0] * u.km, y=[7000.0, 4.0] * u.km, z=[5.0, 6000.0] * u.km
+ )
+
+ gd_transformed = CustomSphericGeodetic.from_representation(initial_cartesian)
+ bc_transformed = CustomSphericBodycentric.from_representation(initial_cartesian)
+ assert_quantity_allclose(gd_transformed.lon, bc_transformed.lon)
+ assert_quantity_allclose(gd_transformed.lat, bc_transformed.lat)
+ assert_quantity_allclose(gd_transformed.height, bc_transformed.height)
+
+
@pytest.mark.parametrize(
- "geodeticrepresentation", [CustomGeodetic, WGS84GeodeticRepresentation]
+ "geodeticrepresentation",
+ [
+ CustomGeodetic,
+ WGS84GeodeticRepresentation,
+ IAUMARS2000GeodeticRepresentation,
+ IAUMARS2000BodycentricRepresentation,
+ ],
)
def test_cartesian_geodetic_roundtrip(geodeticrepresentation):
# Test array-valued input in the process.
@@ -48,7 +87,13 @@ def test_cartesian_geodetic_roundtrip(geodeticrepresentation):
@pytest.mark.parametrize(
- "geodeticrepresentation", [CustomGeodetic, WGS84GeodeticRepresentation]
+ "geodeticrepresentation",
+ [
+ CustomGeodetic,
+ WGS84GeodeticRepresentation,
+ IAUMARS2000GeodeticRepresentation,
+ IAUMARS2000BodycentricRepresentation,
+ ],
)
def test_geodetic_cartesian_roundtrip(geodeticrepresentation):
initial_geodetic = geodeticrepresentation(
@@ -122,41 +167,57 @@ def test_geodetic_to_geocentric():
vvd(xyz[2], -3040908.6861467111, 1e-7, "eraGd2gc", "2/3", status)
-def test_default_height_is_zero():
- gd = WGS84GeodeticRepresentation(10 * u.deg, 20 * u.deg)
+@pytest.mark.parametrize(
+ "representation",
+ [WGS84GeodeticRepresentation, IAUMARS2000BodycentricRepresentation],
+)
+def test_default_height_is_zero(representation):
+ gd = representation(10 * u.deg, 20 * u.deg)
assert gd.lon == 10 * u.deg
assert gd.lat == 20 * u.deg
assert gd.height == 0 * u.m
-def test_non_angle_error():
- with pytest.raises(u.UnitTypeError):
- WGS84GeodeticRepresentation(20 * u.m, 20 * u.deg, 20 * u.m)
+@pytest.mark.parametrize(
+ "representation",
+ [WGS84GeodeticRepresentation, IAUMARS2000BodycentricRepresentation],
+)
+def test_non_angle_error(representation):
+ with pytest.raises(u.UnitTypeError, match="require units equivalent to 'rad'"):
+ representation(20 * u.m, 20 * u.deg, 20 * u.m)
-def test_non_length_error():
+@pytest.mark.parametrize(
+ "representation",
+ [WGS84GeodeticRepresentation, IAUMARS2000BodycentricRepresentation],
+)
+def test_non_length_error(representation):
with pytest.raises(u.UnitTypeError, match="units of length"):
- WGS84GeodeticRepresentation(10 * u.deg, 20 * u.deg, 30)
+ representation(10 * u.deg, 20 * u.deg, 30)
-def test_geodetic_subclass_bad_ellipsoid():
+def test_subclass_bad_ellipsoid():
# Test incomplete initialization.
msg = "module 'erfa' has no attribute 'foo'"
with pytest.raises(AttributeError, match=msg):
- class InvalidCustomGeodeticEllipsoid(BaseGeodeticRepresentation):
+ class InvalidCustomEllipsoid(BaseGeodeticRepresentation):
_ellipsoid = "foo"
assert "foo" not in ELLIPSOIDS
- assert "customgeodeticellipsoiderror" not in REPRESENTATION_CLASSES
+ assert "invalidcustomellipsoid" not in REPRESENTATION_CLASSES
-def test_geodetic_subclass_missing_equatorial_radius():
- msg = "MissingCustomGeodeticAttribute requires '_ellipsoid' or '_equatorial_radius' and '_flattening'."
+@pytest.mark.parametrize(
+ "baserepresentation",
+ [BaseGeodeticRepresentation, BaseBodycentricRepresentation],
+)
+def test_geodetic_subclass_missing_equatorial_radius(baserepresentation):
+ msg = "'_equatorial_radius' and '_flattening'."
with pytest.raises(AttributeError, match=msg):
- class MissingCustomGeodeticAttribute(BaseGeodeticRepresentation):
+ class MissingCustomAttribute(baserepresentation):
_flattening = 0.075 * u.dimensionless_unscaled
- assert "customgeodeticerror" not in REPRESENTATION_CLASSES
+ assert "missingcustomattribute" not in REPRESENTATION_CLASSES
diff --git a/astropy/coordinates/tests/test_representation.py b/astropy/coordinates/tests/test_representation.py
index b50eb4555aa9..1f0d5089bcd0 100644
--- a/astropy/coordinates/tests/test_representation.py
+++ b/astropy/coordinates/tests/test_representation.py
@@ -1870,8 +1870,9 @@ def test_represent_as(self):
# TODO: Converting a CartesianDifferential to a
# RadialDifferential fails, even on `main`
continue
- elif name.endswith("geodetic"):
- # TODO: Geodetic representations do not have differentials yet
+ elif "geodetic" in name or "bodycentric" in name:
+ # TODO: spheroidal representations (geodetic or bodycentric)
+ # do not have differentials yet
continue
new_rep = rep1.represent_as(
REPRESENTATION_CLASSES[name], DIFFERENTIAL_CLASSES[name]
|
[
{
"path": "docs/changes/coordinates/14851.feature.rst",
"old_path": "/dev/null",
"new_path": "b/docs/changes/coordinates/14851.feature.rst",
"metadata": "diff --git a/docs/changes/coordinates/14851.feature.rst b/docs/changes/coordinates/14851.feature.rst\nnew file mode 100644\nindex 000000000000..c74e2aa8435c\n--- /dev/null\n+++ b/docs/changes/coordinates/14851.feature.rst\n@@ -0,0 +1,2 @@\n+Add ``BaseBodycentricRepresentation``, a new spheroidal representation for bodycentric\n+latitudes and longitudes.\n"
},
{
"path": "docs/coordinates/representations.rst",
"old_path": "a/docs/coordinates/representations.rst",
"new_path": "b/docs/coordinates/representations.rst",
"metadata": "diff --git a/docs/coordinates/representations.rst b/docs/coordinates/representations.rst\nindex dc496fade830..a4408a71c279 100644\n--- a/docs/coordinates/representations.rst\n+++ b/docs/coordinates/representations.rst\n@@ -32,23 +32,39 @@ The built-in representation classes are:\n (``rho``), azimuthal angle (``phi``), and height (``z``).\n \n \n-Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` useful to\n+Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` and\n+a `~astropy.coordinates.BaseBodycentricRepresentation` useful to\n create specific representations on spheroidal bodies.\n-This is used internally for the standard Earth ellipsoids used in\n-`~astropy.coordinates.EarthLocation`\n-(`~astropy.coordinates.WGS84GeodeticRepresentation`,\n-`~astropy.coordinates.WGS72GeodeticRepresentation`, and\n-`~astropy.coordinates.GRS80GeodeticRepresentation`), but\n-can also be customized; see :ref:`astropy-coordinates-create-geodetic`.\n-All these are coordinates on a surface of a spheroid (an ellipsoid with equal\n-equatorial radii), represented by a longitude (``lon``) a geodetical latitude (``lat``)\n+\n+`~astropy.coordinates.BaseGeodeticRepresentation` is the coordinate representation on\n+a surface of a spheroid (an ellipsoid with equal\n+equatorial radii), represented by a longitude (``lon``) a geodetic latitude (``lat``)\n and a height (``height``) above the surface.\n-The geodetical latitude is defined by the angle\n+The geodetic latitude is defined by the angle\n between the vertical to the surface at a specific point of the spheroid and its\n projection onto the equatorial plane.\n The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360\n+degrees, the height is the elevation above the surface of the spheroid (measured\n+perpendicular to the surface).\n+\n+`~astropy.coordinates.BaseBodycentricRepresentation` is the coordinate representation\n+recommended by the Cartographic Coordinates & Rotational Elements Working Group\n+(see for example its `2019 report <https://rdcu.be/b32WL>`_): the bodycentric latitude\n+and longitude are spherical latitude and longitude relative to the barycenter of the\n+body, the height is the distance from the spheroid surface (measured radially).\n+The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360\n degrees.\n \n+`~astropy.coordinates.BaseGeodeticRepresentation` is used internally for the standard\n+Earth ellipsoids used in\n+`~astropy.coordinates.EarthLocation`\n+(`~astropy.coordinates.WGS84GeodeticRepresentation`,\n+`~astropy.coordinates.WGS72GeodeticRepresentation`, and\n+`~astropy.coordinates.GRS80GeodeticRepresentation`).\n+`~astropy.coordinates.BaseGeodeticRepresentation` and\n+`~astropy.coordinates.BaseBodycentricRepresentation`\n+can be customized as described in :ref:`astropy-coordinates-create-geodetic`.\n+\n .. Note::\n For information about using and changing the representation of\n `~astropy.coordinates.SkyCoord` objects, see the\n@@ -706,11 +722,13 @@ In pseudo-code, this means that a class will look like::\n \n .. _astropy-coordinates-create-geodetic:\n \n-Creating Your Own Geodetic Representation\n------------------------------------------\n+Creating Your Own Geodetic and Bodycentric Representations\n+----------------------------------------------------------\n \n If you would like to use geodetic coordinates on planetary bodies other than the Earth,\n-you can define a new class that inherits from `~astropy.coordinates.BaseGeodeticRepresentation`.\n+you can define a new class that inherits from\n+`~astropy.coordinates.BaseGeodeticRepresentation` or\n+`~astropy.coordinates.BaseBodycentricRepresentation`.\n The equatorial radius and flattening must be both assigned via the attributes\n `_equatorial_radius` and `_flattening`.\n \n@@ -721,3 +739,11 @@ For example the spheroid describing Mars as in the\n \n _equatorial_radius = 3393400.0 * u.m\n _flattening = 0.518650 * u.percent\n+\n+The bodycentric coordinate system representing Mars as in the\n+`2000 IAU standard <https://doi.org/10.1023/A:1013939327465>`_ could be defined as::\n+\n+ class IAUMARS2000BodycentricRepresentation(BaseBodycentricRepresentation):\n+\n+ _equatorial_radius = 3396190.0 * u.m\n+ _flattening = 0.5886008 * u.percent\n"
},
{
"path": "docs/whatsnew/6.0.rst",
"old_path": "a/docs/whatsnew/6.0.rst",
"new_path": "b/docs/whatsnew/6.0.rst",
"metadata": "diff --git a/docs/whatsnew/6.0.rst b/docs/whatsnew/6.0.rst\nindex 86ad59e033e0..de25addd78b7 100644\n--- a/docs/whatsnew/6.0.rst\n+++ b/docs/whatsnew/6.0.rst\n@@ -25,15 +25,17 @@ By the numbers:\n \n .. _whatsnew-6.0-geodetic-representation-geometry:\n \n-Define Geodetic Representations via their geometric parameters\n-==============================================================\n+Define Geodetic and Bodycentric Representations via their geometric parameters\n+==============================================================================\n \n The user may now define custom spheroidal models for the Earth or other planetary\n-bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defining\n+bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` or\n+`~astropy.coordinates.BaseBodycentricRepresentation` and defining\n ``_equatorial_radius`` and ``_flattening`` attributes::\n \n \n- >>> from astropy.coordinates import BaseGeodeticRepresentation, WGS84GeodeticRepresentation\n+ >>> from astropy.coordinates import (BaseGeodeticRepresentation,\n+ ... WGS84GeodeticRepresentation, BaseBodycentricRepresentation)\n >>> from astropy import units as u\n >>> class IAU1976EarthGeodeticRepresentation(BaseGeodeticRepresentation):\n ... _equatorial_radius = 6378140 * u.m\n@@ -46,6 +48,12 @@ bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defi\n >>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP\n <WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)\n (0.79999959, 0.98000063, 370.01796023)>\n+ >>> class IAU1976EarthBodycentricRepresentation(BaseBodycentricRepresentation):\n+ ... _equatorial_radius = 6378140 * u.m\n+ ... _flattening = 0.3352805 * u.percent\n+ >>> representation.represent_as(IAU1976EarthBodycentricRepresentation) # doctest: +FLOAT_CMP\n+ <IAU1976EarthBodycentricRepresentation (lon, lat, height) in (rad, rad, m)\n+ (0.79999959, 0.9768896, 336.12620429)>\n \n See :ref:`astropy-coordinates-create-geodetic` for more details.\n \n"
}
] |
6.0
|
4fba338b907356185c5a9dd60cc7f65f54e58a4d
|
[
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_init_lonlat",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_transform",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_represent_as",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_init_array",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_broadcasting_mismatch",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_getitem_scalar",
"astropy/coordinates/tests/test_representation.py::test_dtype_preservation_in_indexing",
"astropy/coordinates/tests/test_representation.py::test_representation_str",
"astropy/coordinates/tests/test_representation.py::TestInfo::test_roundtrip[rep_w_diff]",
"astropy/coordinates/tests/test_representation.py::test_differential_norm_noncartesian[PhysicsSphericalDifferential]",
"astropy/coordinates/tests/test_representation.py::TestRadialRepresentation::test_transform",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_getitem_len_iterable",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_init_differential",
"astropy/coordinates/tests/test_representation.py::test_spherical_physics_spherical_roundtrip",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_transform_with_NaN",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_reprobj",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_getitem",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_getitem_len_iterable_scalar",
"astropy/coordinates/tests/test_representation.py::TestInfo::test_roundtrip[diff]",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_init_subclass",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_init_no_mutate_input",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_transform",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_empty_init",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_getitem",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_getitem",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_unit_mismatch",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_init_array_nocopy",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_readonly",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_nan_distance",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_with_differentials",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_empty_init",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_init_array",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_transform",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_getitem_scalar",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_raise_on_extra_arguments",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_transform",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_reprobj",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_name",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_represent_as_unit_spherical_with_diff[SphericalDifferential-UnitSphericalDifferential]",
"astropy/coordinates/tests/test_representation.py::test_cartesian_setting_with_other",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_representation_shortcuts",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_init_quantity",
"astropy/coordinates/tests/test_representation.py::test_minimal_subclass",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_name",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_broadcasting_mismatch",
"astropy/coordinates/tests/test_representation.py::test_repr_with_differentials",
"astropy/coordinates/tests/test_representation.py::TestInfo::test_info_unit",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_reprobj",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_broadcasting",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_transform",
"astropy/coordinates/tests/test_representation.py::test_cartesian_spherical_roundtrip",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_init_float32_array",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalCosLatDifferential::test_transform[matrix1]",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_representation_shortcuts",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_readonly",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_broadcasting_mismatch",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_represent_as_unit_spherical_with_diff[SphericalCosLatDifferential-UnitSphericalCosLatDifferential]",
"astropy/coordinates/tests/test_representation.py::test_differential_norm_noncartesian[UnitSphericalCosLatDifferential]",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_broadcasting_mismatch",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_broadcasting",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_init_array_nocopy",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_unit_non_length",
"astropy/coordinates/tests/test_representation.py::test_unit_spherical_roundtrip",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_name",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_init_quantity",
"astropy/coordinates/tests/test_representation.py::test_differential_norm_noncartesian[SphericalDifferential]",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_xyz",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_transform_with_NaN",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_broadcasting",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_broadcasting",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_init_quantity",
"astropy/coordinates/tests/test_representation.py::test_subclass_representation",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_init_array_nocopy",
"astropy/coordinates/tests/test_representation.py::test_cartesian_physics_spherical_roundtrip",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_init_array",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_broadcasting_and_nocopy",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_init_differential_compatible",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_empty_init",
"astropy/coordinates/tests/test_representation.py::test_distance_warning",
"astropy/coordinates/tests/test_representation.py::TestInfo::test_roundtrip[rep]",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_init_one_array",
"astropy/coordinates/tests/test_representation.py::test_cartesian_cylindrical_roundtrip",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_broadcasting_mismatch",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_init_differential_multiple_equivalent_keys",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_negative_distance",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_init_array",
"astropy/coordinates/tests/test_representation.py::test_duplicate_warning",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_init_array_nocopy",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_name",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_init_lonlat",
"astropy/coordinates/tests/test_representation.py::test_representation_str_multi_d",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_getitem_scalar",
"astropy/coordinates/tests/test_representation.py::test_differential_norm_radial",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_init_singleunit",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_init_phitheta",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_getitem",
"astropy/coordinates/tests/test_representation.py::test_no_unnecessary_copies",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_readonly",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_init_quantity",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_setitem",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_init_array_broadcasting",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_init_array",
"astropy/coordinates/tests/test_representation.py::test_differential_norm_noncartesian[SphericalCosLatDifferential]",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_readonly",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_readonly",
"astropy/coordinates/tests/test_representation.py::test_differential_norm_noncartesian[CylindricalDifferential]",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalCosLatDifferential::test_transform[matrix0]",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_xyz_is_view_if_possible",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_broadcasting",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_init_array_nocopy",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_getitem_scalar",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_init_one_array_yz_fail",
"astropy/coordinates/tests/test_representation.py::test_representation_repr_multi_d",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_setitem",
"astropy/coordinates/tests/test_representation.py::TestCylindricalRepresentation::test_reprobj",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_name",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_initialize_with_nan",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_reprobj",
"astropy/coordinates/tests/test_representation.py::test_differential_norm_noncartesian[UnitSphericalDifferential]",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_empty_init",
"astropy/coordinates/tests/test_representation.py::test_representation_repr",
"astropy/coordinates/tests/test_representation.py::TestUnitSphericalRepresentation::test_representation_shortcuts",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentationWithDifferential::test_readonly",
"astropy/coordinates/tests/test_representation.py::test_to_cartesian",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_init_xyz_but_more_than_one_array_fail",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_transform",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_empty_init",
"astropy/coordinates/tests/test_representation.py::test_unitphysics",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_reprobj",
"astropy/coordinates/tests/test_representation.py::TestCartesianRepresentation::test_init_one_array_size_fail",
"astropy/coordinates/tests/test_representation.py::TestSphericalRepresentation::test_init_quantity",
"astropy/coordinates/tests/test_representation.py::TestPhysicsSphericalRepresentation::test_getitem"
] |
[
"astropy/coordinates/tests/test_geodetic_representations.py::test_geocentric_to_geodetic",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_cartesian_roundtrip[IAUMARS2000BodycentricRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_subclass_bad_ellipsoid",
"astropy/coordinates/tests/test_geodetic_representations.py::test_cartesian_geodetic_roundtrip[WGS84GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_subclass_missing_equatorial_radius[BaseGeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_cartesian_roundtrip[IAUMARS2000GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_non_length_error[IAUMARS2000BodycentricRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_to_geocentric",
"astropy/coordinates/tests/test_geodetic_representations.py::test_cartesian_geodetic_roundtrip[IAUMARS2000BodycentricRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_cartesian_roundtrip[WGS84GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_bodycentric_equivalence_spherical_bodies",
"astropy/coordinates/tests/test_geodetic_representations.py::test_default_height_is_zero[WGS84GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_default_height_is_zero[IAUMARS2000BodycentricRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_cartesian_geodetic_roundtrip[CustomGeodetic]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_non_angle_error[WGS84GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_subclass_missing_equatorial_radius[BaseBodycentricRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_non_length_error[WGS84GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_cartesian_geodetic_roundtrip[IAUMARS2000GeodeticRepresentation]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_geodetic_cartesian_roundtrip[CustomGeodetic]",
"astropy/coordinates/tests/test_geodetic_representations.py::test_non_angle_error[IAUMARS2000BodycentricRepresentation]"
] |
{
"header": "If completing this task requires creating new files, classes, fields, or error messages, you may consider using the following suggested entity names:",
"data": []
}
|
[
{
"path": "docs/changes/coordinates/<PRID>.feature.rst",
"old_path": "/dev/null",
"new_path": "b/docs/changes/coordinates/<PRID>.feature.rst",
"metadata": "diff --git a/docs/changes/coordinates/<PRID>.feature.rst b/docs/changes/coordinates/<PRID>.feature.rst\nnew file mode 100644\nindex 000000000000..c74e2aa8435c\n--- /dev/null\n+++ b/docs/changes/coordinates/<PRID>.feature.rst\n@@ -0,0 +1,2 @@\n+Add ``BaseBodycentricRepresentation``, a new spheroidal representation for bodycentric\n+latitudes and longitudes.\n"
},
{
"path": "docs/coordinates/representations.rst",
"old_path": "a/docs/coordinates/representations.rst",
"new_path": "b/docs/coordinates/representations.rst",
"metadata": "diff --git a/docs/coordinates/representations.rst b/docs/coordinates/representations.rst\nindex dc496fade830..a4408a71c279 100644\n--- a/docs/coordinates/representations.rst\n+++ b/docs/coordinates/representations.rst\n@@ -32,23 +32,39 @@ The built-in representation classes are:\n (``rho``), azimuthal angle (``phi``), and height (``z``).\n \n \n-Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` useful to\n+Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` and\n+a `~astropy.coordinates.BaseBodycentricRepresentation` useful to\n create specific representations on spheroidal bodies.\n-This is used internally for the standard Earth ellipsoids used in\n-`~astropy.coordinates.EarthLocation`\n-(`~astropy.coordinates.WGS84GeodeticRepresentation`,\n-`~astropy.coordinates.WGS72GeodeticRepresentation`, and\n-`~astropy.coordinates.GRS80GeodeticRepresentation`), but\n-can also be customized; see :ref:`astropy-coordinates-create-geodetic`.\n-All these are coordinates on a surface of a spheroid (an ellipsoid with equal\n-equatorial radii), represented by a longitude (``lon``) a geodetical latitude (``lat``)\n+\n+`~astropy.coordinates.BaseGeodeticRepresentation` is the coordinate representation on\n+a surface of a spheroid (an ellipsoid with equal\n+equatorial radii), represented by a longitude (``lon``) a geodetic latitude (``lat``)\n and a height (``height``) above the surface.\n-The geodetical latitude is defined by the angle\n+The geodetic latitude is defined by the angle\n between the vertical to the surface at a specific point of the spheroid and its\n projection onto the equatorial plane.\n The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360\n+degrees, the height is the elevation above the surface of the spheroid (measured\n+perpendicular to the surface).\n+\n+`~astropy.coordinates.BaseBodycentricRepresentation` is the coordinate representation\n+recommended by the Cartographic Coordinates & Rotational Elements Working Group\n+(see for example its `2019 report <https://rdcu.be/b32WL>`_): the bodycentric latitude\n+and longitude are spherical latitude and longitude relative to the barycenter of the\n+body, the height is the distance from the spheroid surface (measured radially).\n+The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360\n degrees.\n \n+`~astropy.coordinates.BaseGeodeticRepresentation` is used internally for the standard\n+Earth ellipsoids used in\n+`~astropy.coordinates.EarthLocation`\n+(`~astropy.coordinates.WGS84GeodeticRepresentation`,\n+`~astropy.coordinates.WGS72GeodeticRepresentation`, and\n+`~astropy.coordinates.GRS80GeodeticRepresentation`).\n+`~astropy.coordinates.BaseGeodeticRepresentation` and\n+`~astropy.coordinates.BaseBodycentricRepresentation`\n+can be customized as described in :ref:`astropy-coordinates-create-geodetic`.\n+\n .. Note::\n For information about using and changing the representation of\n `~astropy.coordinates.SkyCoord` objects, see the\n@@ -706,11 +722,13 @@ In pseudo-code, this means that a class will look like::\n \n .. _astropy-coordinates-create-geodetic:\n \n-Creating Your Own Geodetic Representation\n------------------------------------------\n+Creating Your Own Geodetic and Bodycentric Representations\n+----------------------------------------------------------\n \n If you would like to use geodetic coordinates on planetary bodies other than the Earth,\n-you can define a new class that inherits from `~astropy.coordinates.BaseGeodeticRepresentation`.\n+you can define a new class that inherits from\n+`~astropy.coordinates.BaseGeodeticRepresentation` or\n+`~astropy.coordinates.BaseBodycentricRepresentation`.\n The equatorial radius and flattening must be both assigned via the attributes\n `_equatorial_radius` and `_flattening`.\n \n@@ -721,3 +739,11 @@ For example the spheroid describing Mars as in the\n \n _equatorial_radius = 3393400.0 * u.m\n _flattening = 0.518650 * u.percent\n+\n+The bodycentric coordinate system representing Mars as in the\n+`2000 IAU standard <https://doi.org/10.1023/A:1013939327465>`_ could be defined as::\n+\n+ class IAUMARS2000BodycentricRepresentation(BaseBodycentricRepresentation):\n+\n+ _equatorial_radius = 3396190.0 * u.m\n+ _flattening = 0.5886008 * u.percent\n"
},
{
"path": "docs/whatsnew/6.0.rst",
"old_path": "a/docs/whatsnew/6.0.rst",
"new_path": "b/docs/whatsnew/6.0.rst",
"metadata": "diff --git a/docs/whatsnew/6.0.rst b/docs/whatsnew/6.0.rst\nindex 86ad59e033e0..de25addd78b7 100644\n--- a/docs/whatsnew/6.0.rst\n+++ b/docs/whatsnew/6.0.rst\n@@ -25,15 +25,17 @@ By the numbers:\n \n .. _whatsnew-6.0-geodetic-representation-geometry:\n \n-Define Geodetic Representations via their geometric parameters\n-==============================================================\n+Define Geodetic and Bodycentric Representations via their geometric parameters\n+==============================================================================\n \n The user may now define custom spheroidal models for the Earth or other planetary\n-bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defining\n+bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` or\n+`~astropy.coordinates.BaseBodycentricRepresentation` and defining\n ``_equatorial_radius`` and ``_flattening`` attributes::\n \n \n- >>> from astropy.coordinates import BaseGeodeticRepresentation, WGS84GeodeticRepresentation\n+ >>> from astropy.coordinates import (BaseGeodeticRepresentation,\n+ ... WGS84GeodeticRepresentation, BaseBodycentricRepresentation)\n >>> from astropy import units as u\n >>> class IAU1976EarthGeodeticRepresentation(BaseGeodeticRepresentation):\n ... _equatorial_radius = 6378140 * u.m\n@@ -46,6 +48,12 @@ bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defi\n >>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP\n <WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)\n (0.79999959, 0.98000063, 370.01796023)>\n+ >>> class IAU1976EarthBodycentricRepresentation(BaseBodycentricRepresentation):\n+ ... _equatorial_radius = 6378140 * u.m\n+ ... _flattening = 0.3352805 * u.percent\n+ >>> representation.represent_as(IAU1976EarthBodycentricRepresentation) # doctest: +FLOAT_CMP\n+ <IAU1976EarthBodycentricRepresentation (lon, lat, height) in (rad, rad, m)\n+ (0.79999959, 0.9768896, 336.12620429)>\n \n See :ref:`astropy-coordinates-create-geodetic` for more details.\n \n"
}
] |
diff --git a/docs/changes/coordinates/<PRID>.feature.rst b/docs/changes/coordinates/<PRID>.feature.rst
new file mode 100644
index 000000000000..c74e2aa8435c
--- /dev/null
+++ b/docs/changes/coordinates/<PRID>.feature.rst
@@ -0,0 +1,2 @@
+Add ``BaseBodycentricRepresentation``, a new spheroidal representation for bodycentric
+latitudes and longitudes.
diff --git a/docs/coordinates/representations.rst b/docs/coordinates/representations.rst
index dc496fade830..a4408a71c279 100644
--- a/docs/coordinates/representations.rst
+++ b/docs/coordinates/representations.rst
@@ -32,23 +32,39 @@ The built-in representation classes are:
(``rho``), azimuthal angle (``phi``), and height (``z``).
-Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` useful to
+Astropy also offers a `~astropy.coordinates.BaseGeodeticRepresentation` and
+a `~astropy.coordinates.BaseBodycentricRepresentation` useful to
create specific representations on spheroidal bodies.
-This is used internally for the standard Earth ellipsoids used in
-`~astropy.coordinates.EarthLocation`
-(`~astropy.coordinates.WGS84GeodeticRepresentation`,
-`~astropy.coordinates.WGS72GeodeticRepresentation`, and
-`~astropy.coordinates.GRS80GeodeticRepresentation`), but
-can also be customized; see :ref:`astropy-coordinates-create-geodetic`.
-All these are coordinates on a surface of a spheroid (an ellipsoid with equal
-equatorial radii), represented by a longitude (``lon``) a geodetical latitude (``lat``)
+
+`~astropy.coordinates.BaseGeodeticRepresentation` is the coordinate representation on
+a surface of a spheroid (an ellipsoid with equal
+equatorial radii), represented by a longitude (``lon``) a geodetic latitude (``lat``)
and a height (``height``) above the surface.
-The geodetical latitude is defined by the angle
+The geodetic latitude is defined by the angle
between the vertical to the surface at a specific point of the spheroid and its
projection onto the equatorial plane.
The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360
+degrees, the height is the elevation above the surface of the spheroid (measured
+perpendicular to the surface).
+
+`~astropy.coordinates.BaseBodycentricRepresentation` is the coordinate representation
+recommended by the Cartographic Coordinates & Rotational Elements Working Group
+(see for example its `2019 report <https://rdcu.be/b32WL>`_): the bodycentric latitude
+and longitude are spherical latitude and longitude relative to the barycenter of the
+body, the height is the distance from the spheroid surface (measured radially).
+The latitude is a value ranging from -90 to 90 degrees, the longitude from 0 to 360
degrees.
+`~astropy.coordinates.BaseGeodeticRepresentation` is used internally for the standard
+Earth ellipsoids used in
+`~astropy.coordinates.EarthLocation`
+(`~astropy.coordinates.WGS84GeodeticRepresentation`,
+`~astropy.coordinates.WGS72GeodeticRepresentation`, and
+`~astropy.coordinates.GRS80GeodeticRepresentation`).
+`~astropy.coordinates.BaseGeodeticRepresentation` and
+`~astropy.coordinates.BaseBodycentricRepresentation`
+can be customized as described in :ref:`astropy-coordinates-create-geodetic`.
+
.. Note::
For information about using and changing the representation of
`~astropy.coordinates.SkyCoord` objects, see the
@@ -706,11 +722,13 @@ In pseudo-code, this means that a class will look like::
.. _astropy-coordinates-create-geodetic:
-Creating Your Own Geodetic Representation
------------------------------------------
+Creating Your Own Geodetic and Bodycentric Representations
+----------------------------------------------------------
If you would like to use geodetic coordinates on planetary bodies other than the Earth,
-you can define a new class that inherits from `~astropy.coordinates.BaseGeodeticRepresentation`.
+you can define a new class that inherits from
+`~astropy.coordinates.BaseGeodeticRepresentation` or
+`~astropy.coordinates.BaseBodycentricRepresentation`.
The equatorial radius and flattening must be both assigned via the attributes
`_equatorial_radius` and `_flattening`.
@@ -721,3 +739,11 @@ For example the spheroid describing Mars as in the
_equatorial_radius = 3393400.0 * u.m
_flattening = 0.518650 * u.percent
+
+The bodycentric coordinate system representing Mars as in the
+`2000 IAU standard <https://doi.org/10.1023/A:1013939327465>`_ could be defined as::
+
+ class IAUMARS2000BodycentricRepresentation(BaseBodycentricRepresentation):
+
+ _equatorial_radius = 3396190.0 * u.m
+ _flattening = 0.5886008 * u.percent
diff --git a/docs/whatsnew/6.0.rst b/docs/whatsnew/6.0.rst
index 86ad59e033e0..de25addd78b7 100644
--- a/docs/whatsnew/6.0.rst
+++ b/docs/whatsnew/6.0.rst
@@ -25,15 +25,17 @@ By the numbers:
.. _whatsnew-6.0-geodetic-representation-geometry:
-Define Geodetic Representations via their geometric parameters
-==============================================================
+Define Geodetic and Bodycentric Representations via their geometric parameters
+==============================================================================
The user may now define custom spheroidal models for the Earth or other planetary
-bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defining
+bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` or
+`~astropy.coordinates.BaseBodycentricRepresentation` and defining
``_equatorial_radius`` and ``_flattening`` attributes::
- >>> from astropy.coordinates import BaseGeodeticRepresentation, WGS84GeodeticRepresentation
+ >>> from astropy.coordinates import (BaseGeodeticRepresentation,
+ ... WGS84GeodeticRepresentation, BaseBodycentricRepresentation)
>>> from astropy import units as u
>>> class IAU1976EarthGeodeticRepresentation(BaseGeodeticRepresentation):
... _equatorial_radius = 6378140 * u.m
@@ -46,6 +48,12 @@ bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defi
>>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP
<WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)
(0.79999959, 0.98000063, 370.01796023)>
+ >>> class IAU1976EarthBodycentricRepresentation(BaseBodycentricRepresentation):
+ ... _equatorial_radius = 6378140 * u.m
+ ... _flattening = 0.3352805 * u.percent
+ >>> representation.represent_as(IAU1976EarthBodycentricRepresentation) # doctest: +FLOAT_CMP
+ <IAU1976EarthBodycentricRepresentation (lon, lat, height) in (rad, rad, m)
+ (0.79999959, 0.9768896, 336.12620429)>
See :ref:`astropy-coordinates-create-geodetic` for more details.
|
astropy/astropy
|
astropy__astropy-14701
|
https://github.com/astropy/astropy/pull/14701
| "diff --git a/astropy/cosmology/io/__init__.py b/astropy/cosmology/io/__init__.py\nindex 9ed9a995e63(...TRUNCATED) | "diff --git a/astropy/cosmology/io/tests/test_latex.py b/astropy/cosmology/io/tests/test_latex.py\nn(...TRUNCATED) | [{"path":"docs/changes/cosmology/14701.feature.rst","old_path":"/dev/null","new_path":"b/docs/change(...TRUNCATED) |
6.0
|
a429c3984a14c995584455e51a6f3d7d9c16e914
|
[] | ["astropy/cosmology/tests/test_connect.py::TestCosmologyReadWrite::test_readwrite_ecsv_mutlirow[WMAP(...TRUNCATED) | {"header":"If completing this task requires creating new files, classes, fields, or error messages, (...TRUNCATED) | [{"path":"docs/changes/cosmology/<PRID>.feature.rst","old_path":"/dev/null","new_path":"b/docs/chang(...TRUNCATED) | "diff --git a/docs/changes/cosmology/<PRID>.feature.rst b/docs/changes/cosmology/<PRID>.feature.rst\(...TRUNCATED) |
astropy/astropy
|
astropy__astropy-14780
|
https://github.com/astropy/astropy/pull/14780
| "diff --git a/astropy/cosmology/_io/ecsv.py b/astropy/cosmology/_io/ecsv.py\nindex 06603a95ed82..fef(...TRUNCATED) | "diff --git a/astropy/cosmology/_io/tests/test_ecsv.py b/astropy/cosmology/_io/tests/test_ecsv.py\ni(...TRUNCATED) | [{"path":"docs/changes/cosmology/14780.feature.rst","old_path":"/dev/null","new_path":"b/docs/change(...TRUNCATED) |
6.0
|
3a145a38d3f6fd531df5e6d9bcd81b0f72e3a6db
| ["astropy/cosmology/_io/tests/test_table.py::TestToFromTable::test_to_table_cls[cosmo4-QTable]","ast(...TRUNCATED) | ["astropy/cosmology/_io/tests/test_mapping.py::TestToFromMapping::test_to_mapping_rename_conflict[co(...TRUNCATED) | {"header":"If completing this task requires creating new files, classes, fields, or error messages, (...TRUNCATED) | [{"path":"docs/changes/cosmology/<PRID>.feature.rst","old_path":"/dev/null","new_path":"b/docs/chang(...TRUNCATED) | "diff --git a/docs/changes/cosmology/<PRID>.feature.rst b/docs/changes/cosmology/<PRID>.feature.rst\(...TRUNCATED) |
astropy/astropy
|
astropy__astropy-14878
|
https://github.com/astropy/astropy/pull/14878
| "diff --git a/astropy/table/row.py b/astropy/table/row.py\nindex 03b7d13219b9..cab570e837c6 100644\n(...TRUNCATED) | "diff --git a/astropy/table/tests/test_row.py b/astropy/table/tests/test_row.py\nindex 8ad9f46ba80b.(...TRUNCATED) | [{"path":"docs/changes/table/14878.feature.rst","old_path":"/dev/null","new_path":"b/docs/changes/ta(...TRUNCATED) |
6.0
|
88790514bdf248e43c2fb15ee18cfd3390846145
| ["astropy/table/tests/test_row.py::TestRow::test_row_keys_values[masked]","astropy/table/tests/test_(...TRUNCATED) |
[
"astropy/table/tests/test_row.py::test_row_get"
] | {"header":"If completing this task requires creating new files, classes, fields, or error messages, (...TRUNCATED) | [{"path":"docs/changes/table/<PRID>.feature.rst","old_path":"/dev/null","new_path":"b/docs/changes/t(...TRUNCATED) | "diff --git a/docs/changes/table/<PRID>.feature.rst b/docs/changes/table/<PRID>.feature.rst\nnew fil(...TRUNCATED) |
astropy/astropy
|
astropy__astropy-14729
|
https://github.com/astropy/astropy/pull/14729
| "diff --git a/astropy/units/quantity_helper/erfa.py b/astropy/units/quantity_helper/erfa.py\nindex 6(...TRUNCATED) | "diff --git a/astropy/coordinates/tests/test_earth.py b/astropy/coordinates/tests/test_earth.py\nind(...TRUNCATED) | [{"path":"docs/changes/units/14729.feature.rst","old_path":"/dev/null","new_path":"b/docs/changes/un(...TRUNCATED) |
6.0
|
51332ce5bccc1862e9b59a8ff698bed48d0ee9d6
| ["astropy/coordinates/tests/test_earth.py::TestInput::test_invalid_input","astropy/units/tests/test_(...TRUNCATED) | ["astropy/units/tests/test_quantity_erfa_ufuncs.py::TestGeodetic::test_gc2gde","astropy/units/tests/(...TRUNCATED) | {"header":"If completing this task requires creating new files, classes, fields, or error messages, (...TRUNCATED) | [{"path":"docs/changes/units/<PRID>.feature.rst","old_path":"/dev/null","new_path":"b/docs/changes/u(...TRUNCATED) | "diff --git a/docs/changes/units/<PRID>.feature.rst b/docs/changes/units/<PRID>.feature.rst\nnew fil(...TRUNCATED) |
astropy/astropy
|
astropy__astropy-13993
|
https://github.com/astropy/astropy/pull/13993
| "diff --git a/astropy/coordinates/earth.py b/astropy/coordinates/earth.py\nindex 724298b99075..15d10(...TRUNCATED) | "diff --git a/astropy/coordinates/tests/test_sites.py b/astropy/coordinates/tests/test_sites.py\nind(...TRUNCATED) | [{"path":"docs/changes/coordinates/13993.feature.rst","old_path":"/dev/null","new_path":"b/docs/chan(...TRUNCATED) |
5.3
|
aca313fd13b760c6d3d6af9cc68c744f03c1c2dc
| ["astropy/coordinates/tests/test_sites.py::test_Earthlocation_refresh_cache_is_mandatory_kwarg[of_si(...TRUNCATED) | ["astropy/coordinates/tests/test_sites.py::test_Earthlocation_refresh_cache[False-of_site-args1]","a(...TRUNCATED) | {"header":"If completing this task requires creating new files, classes, fields, or error messages, (...TRUNCATED) | [{"path":"docs/changes/coordinates/<PRID>.feature.rst","old_path":"/dev/null","new_path":"b/docs/cha(...TRUNCATED) | "diff --git a/docs/changes/coordinates/<PRID>.feature.rst b/docs/changes/coordinates/<PRID>.feature.(...TRUNCATED) |
astropy/astropy
|
astropy__astropy-14371
|
https://github.com/astropy/astropy/pull/14371
| "diff --git a/astropy/coordinates/matrix_utilities.py b/astropy/coordinates/matrix_utilities.py\nind(...TRUNCATED) | "diff --git a/astropy/coordinates/tests/test_matrix_utilities.py b/astropy/coordinates/tests/test_ma(...TRUNCATED) | [{"path":"docs/changes/coordinates/14371.feature.rst","old_path":"/dev/null","new_path":"b/docs/chan(...TRUNCATED) |
5.3
|
e2a2ca3eab1defc71aedf4cf3982f7d4793faacf
| ["astropy/coordinates/tests/test_matrix_utilities.py::test_rotation_matrix","astropy/coordinates/tes(...TRUNCATED) | ["astropy/coordinates/tests/test_matrix_utilities.py::test_is_rotation","astropy/coordinates/tests/t(...TRUNCATED) | {"header":"If completing this task requires creating new files, classes, fields, or error messages, (...TRUNCATED) | [{"path":"docs/changes/coordinates/<PRID>.feature.rst","old_path":"/dev/null","new_path":"b/docs/cha(...TRUNCATED) | "diff --git a/docs/changes/coordinates/<PRID>.feature.rst b/docs/changes/coordinates/<PRID>.feature.(...TRUNCATED) |
astropy/astropy
|
astropy__astropy-14628
|
https://github.com/astropy/astropy/pull/14628
| "diff --git a/astropy/coordinates/earth.py b/astropy/coordinates/earth.py\nindex bf8de3ebd60e..f7f1e(...TRUNCATED) | "diff --git a/astropy/coordinates/tests/test_intermediate_transformations.py b/astropy/coordinates/t(...TRUNCATED) | [{"path":"docs/changes/coordinates/14628.feature.rst","old_path":"/dev/null","new_path":"b/docs/chan(...TRUNCATED) |
5.3
|
c667e73df92215cf1446c3eda71a56fdaebba426
| ["astropy/coordinates/tests/test_intermediate_transformations.py::test_gcrs_altaz_bothroutes[testfra(...TRUNCATED) |
[
"astropy/coordinates/tests/test_intermediate_transformations.py::test_itrs_straight_overhead"
] | {"header":"If completing this task requires creating new files, classes, fields, or error messages, (...TRUNCATED) | [{"path":"docs/changes/coordinates/<PRID>.feature.rst","old_path":"/dev/null","new_path":"b/docs/cha(...TRUNCATED) | "diff --git a/docs/changes/coordinates/<PRID>.feature.rst b/docs/changes/coordinates/<PRID>.feature.(...TRUNCATED) |
astropy/astropy
|
astropy__astropy-12353
|
https://github.com/astropy/astropy/pull/12353
| "diff --git a/astropy/cosmology/flrw/scalar_inv_efuncs.pyx b/astropy/cosmology/flrw/scalar_inv_efunc(...TRUNCATED) | "diff --git a/astropy/cosmology/flrw/tests/test_w0wzcdm.py b/astropy/cosmology/flrw/tests/test_w0wzc(...TRUNCATED) | [{"path":"docs/changes/cosmology/12353.feature.rst","old_path":"/dev/null","new_path":"b/docs/change(...TRUNCATED) |
5.3
|
4e88b6dddf4a6cc6c8d7cbd7a3de10e6cd6d64d3
|
[] | ["astropy/cosmology/flrw/tests/test_wpwazpcdm.py::TestFlatwpwaCDM::test_readwrite_html_subclass_part(...TRUNCATED) | {"header":"If completing this task requires creating new files, classes, fields, or error messages, (...TRUNCATED) | [{"path":"docs/changes/cosmology/<PRID>.feature.rst","old_path":"/dev/null","new_path":"b/docs/chang(...TRUNCATED) | "diff --git a/docs/changes/cosmology/<PRID>.feature.rst b/docs/changes/cosmology/<PRID>.feature.rst\(...TRUNCATED) |
End of preview. Expand
in Data Studio
Dataset Summary
NoCode-bench is a dataset that tests systems’ no-code feature addition ability automatically.
Languages
The text of the dataset is primarily English, but we make no effort to filter or otherwise clean based on language type.
Dataset Structure
An example of a SWE-bench datum is as follows:
repo: (str) - The repository owner/name identifier from GitHub.
instance_id: (str) - A formatted instance identifier, usually as repo_owner__repo_name-PR-number.
html_url: (str) - The URL of the PR web page where the instances are collected.
feature_patch: (str) - The gold patch, the patch generated by the PR (minus test-related code), that resolved the issue.
test_patch: (str) - A test-file patch that was contributed by the solution PR.
doc_changes: (list) - The documentation changes in a certain PR.
version: (str) - Installation version to use for running evaluation.
base_commit: (str) - The commit hash of the repository representing the HEAD of the repository before the solution PR is applied.
PASS2PASS: (str) - A json list of strings that represent tests that should pass before and after the PR application.
FAIL2PASS: (str) - A json list of strings that represent the set of tests resolved by the PR and tied to the issue resolution.
augmentations: (dict) - A set of names of the entity used to implement the feature.
mask_doc_diff: (list) - The documentation changes in a certain PR, which masked the PR number.
problem_statement: (str) - The main input contained `mask_doc_diff` and `augmentations`.
- Downloads last month
- 14