Related Topics

Quick search

This document describes how to use PyEphem
to convert between equatorial, ecliptic, and galactic coordinates,
and how to convert coordinates between different epochs.

Celestial bodies in PyEphem
can directly express their coordinates in only two ways;
you can ask for their equatorial position,
which provides a right ascension and a declination
relative to the Earth’s equator and poles,
or you can ask where they stand in the sky above a particular observer,
which yields an azimuth and an altitude.
(There are actually several versions of the equatorial position available;
see the Right Ascension and Declination document for details.)

But PyEphem does support two other coordinate systems,
which differ by which great circle they use as the equator of the sky:

Ecliptic Coordinates

This involves a pair of coordinates,
ecliptic longitude and ecliptic latitude,
which measure position from the ecliptic —
the plane in which the earth orbits around the sun,
and thus, approximately,
the plane in which all of the major planets orbit.

Galactic Coordinates

The galactic longitude and galactic latitude of an object
measure its location from the tilted plane that our own galaxy,
the Milky Way, makes across our sky.

As explained below,
the user can either simply ask for a body’s coordinates
to be re-expressed in either of these alternate systems,
or can convert freely between the three main systems of coordinate
without getting bodies involved at all.

If you call the get() method of any coordinate,
then it will return the value of its two angles in a tuple,
with the “big angle” (longitude or right ascension) first
and then the “small angle” (latitude or declination) second.

All of the examples below
are constructed using some combination of the possibilities above.

If you have, say, the position of Mars in J2000 coordinates,
and now want the same position to be expressed in B1950 coordinates,
then you could, of course, simply call compute() again
with the other epoch.
But you can also ask PyEphem to translate the coordinates directly:

You can also convert raw coordinates to another epoch
rather than the position of a body like Mars.
For example, we can ask where the point in the sky
that we call the North Pole in J2000 coordinates
was back in 2500 BC, when the pyramids were being built,
by manually typing ninety degrees for the declination:

The epoch of the resulting coordinates
is the same as that used by the body for its astrometric coordinates:

>>> print(ecl.epoch)2000/1/1 12:00:00

Using Another Right Ascension and Declination

In the first above example,
when we passed a body directly to Ecliptic() and Galactic(),
they automatically used the body’s
astrometric right ascension and declination.
If for some particular application
you want to use the apparent version of the coordinates instead,
then use the alternative right ascension and declination
to build your own Equatorial object: