PyEphem

The astronomy library for Python

Latest release: 3.7.2.3
2008 January 8


If you have the Python “setuptools” just run:
easy_install pyephem

Download “pyephem” at the Python Package Index
Windows Installer (for Python 2.5)
Windows Installer (for Python 2.4)


Source code: pyephem-3.7.2.3.tar.gz

This new version:
Computes the phases of the moon.
Improves support for risings, transits, and settings.
Includes a small database of world cities.
Comes with an improved Quick Reference!
See the CHANGELOG for more details!

PyEphem provides scientific-grade astronomical computations for the Python programming language. Given a date and location on the Earth's surface, it can compute the positions of the Sun and Moon, of the planets and their moons, and of any asteroids, comets, or earth satellites whose orbital elements the user can provide. Additional functions are provided to compute the angular separation between two objects in the sky, to determine the constellation in which an object lies, and to find the times at which an object rises, transits, and sets on a particular day.

A Quick Example
>>> import ephem

>>> mars = ephem.Mars()
>>> mars.compute()
>>> print mars.ra, mars.dec
6:05:56.34 23:23:40.0
>>> ephem.constellation(mars)
('Gem', 'Gemini')

>>> boston = ephem.Observer()
>>> boston.lat = '42.37'
>>> boston.long = '-71.03'
>>> mars.compute(boston)
>>> print mars.az, mars.alt
37:55:48.9 -14:23:11.8

>>> boston.next_rising(mars)
2007/10/2 02:31:51
>>> print mars.az
56:52:52.1

>>> boston.next_transit(mars)
2007/10/2 10:07:47
>>> print mars.alt
71:02:16.3

Resources


Catalogues

After learning to program with PyEphem you will probably want to download the orbital elements of comets or asteroids that interest you, or perhaps coordinates for stars and other fixed objects. Here are several sources from which such data may be obtained:
http://cfa-www.harvard.edu/iau/Ephemerides/Soft03.html
The International Astronomical Union's Central Bureau for Astronomical Telegrams and Minor Planet Center is where comet and asteroid discoveries are traditionally reported, and is a source of ephemerides and orbital elements for these objects. They provide updated orbital elements, in ephem format, for many currently visible comets and asteroids.
http://celestrak.com/NORAD/elements/
Orbital elements for man-made earth satellites are available from NORAD, whose Two-Line Element format can be understood by PyEphem's readtle() function.
http://www.maa.mhn.de/Tools/Xephem/
This directory has not been updated for several years, but has quite extensive collections of objects in ephem format. Though many of its comet and asteroid elements are doubtless out of date, its files of fixed objects like galaxies to pulsars should remain valuable.
http://toyvax.glendale.ca.us/
This page has elements in ephem format for several of our longer-lived space probes.

This page updated by Brandon Craig Rhodes on 2007 October 1.