.. include:: references.txt .. _astropy-coordinates-transforming: Transforming Between Systems ---------------------------- `astropy.coordinates` supports a rich system for transforming coordinates from one system to another. While common astronomy frames are built into Astropy, the transformation infrastructure is dynamic. This means it allows users to define new coordinate frames and their transformations. The topic of writing your own coordinate frame or transforms is detailed in :ref:`astropy-coordinates-design`, and this section is focused on how to *use* transformations. The simplest method of transformation is shown below:: >>> import astropy.units as u >>> from astropy.coordinates import SkyCoord >>> gc = SkyCoord(l=0*u.degree, b=45*u.degree, frame='galactic') >>> gc.fk5 # doctest: +FLOAT_CMP While this appears to be simple attribute-style access, it is actually syntactic sugar for the more general :meth:`~astropy.coordinates.SkyCoord.transform_to` method, which can accept either a frame name, class or instance:: >>> from astropy.coordinates import FK5 >>> gc.transform_to('fk5') # doctest: +FLOAT_CMP >>> gc.transform_to(FK5) # doctest: +FLOAT_CMP >>> gc.transform_to(FK5(equinox='J1980.0')) # doctest: +FLOAT_CMP As a convenience it is also possible to use a |SkyCoord| object as the frame in :meth:`~astropy.coordinates.SkyCoord.transform_to`. This allows easily putting one coordinate object into the frame of another:: >>> sc = SkyCoord(ra=1.0, dec=2.0, unit='deg', frame=FK5, equinox='J1980.0') >>> gc.transform_to(sc) # doctest: +FLOAT_CMP The table below summarizes the built-in coordinate frames. For details of these frames and the transformations between them see the `astropy.coordinates` API documentation and the `~astropy.coordinates.BaseCoordinateFrame` class which forms the basis for all `astropy.coordinates` coordinate frames. ================================== ================ Frame class Frame name ================================== ================ `~astropy.coordinates.ICRS` ``icrs`` `~astropy.coordinates.FK5` ``fk5`` `~astropy.coordinates.FK4` ``fk4`` `~astropy.coordinates.FK4NoETerms` ``fk4noeterms`` `~astropy.coordinates.Galactic` ``galactic`` ================================== ================ Additionally, some coordinate frames (including `~astropy.coordinates.FK5`, `~astropy.coordinates.FK4`, and `~astropy.coordinates.FK4NoETerms`) support "self transformations", meaning the *type* of frame doesn't change, but the frame attributes do. Any example is precessing a coordinate from one equinox to another in an equatorial system. This is done by passing ``transform_to`` a frame class with the relevant attributes, as shown below. Note that these systems use a default equinox if you don't specify one:: >>> fk5c = FK5('02h31m49.09s', '+89d15m50.8s') >>> fk5c.equinox