![]() |
![]() |
![]() |
This site is the PyEphem home page ![]() Simply scroll down to find:
Installation Guide |
Download PyEphem for Windows, Linux, or as source code, directly from the Python Package Index. ![]()
PyPI PyEphem page
|
Ask questions on Stack Overflow, or use our community support tools on GitHub! ![]()
PyEphem Q&A ![]() |
![]() |
![]() |
|
>>> 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.lon = '-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
.. raw:: html
PyEphem is in maintenance mode
==============================
The PyEphem astronomy library
has helped generations of Python programmers
locate the stars, planets, and Earth satellites.
It **will continue to receive bugfixes**
and **will be ported to new versions of Python**,
but it no longer stands at the cutting edge of astronomy in Python.
See below for newer alternatives
that offer a more Pythonic approach to astronomy in Python!
What is PyEphem?
================
**PyEphem** provides basic 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.
.. _Python: http://www.python.org/
The numerical routines that lie behind PyEphem
are those from the wonderful XEphem_ astronomy application,
whose author, Elwood Downey, generously gave permission
for us to use them as the basis for PyEphem.
.. _XEphem: http://www.clearskyinstitute.com/xephem/
Awkward edges
=============
PyEphem’s design has several flaws
that have been avoided by the newer astronomy libraries
listed in the next section.
Among the problems it creates for Python programmers are:
* Instead of offering a clear way for the user to specify units
of radians or degrees,
PyEphem uses the terrible and confusing convention
that floats like ``1.23`` mean radians
but strings like ``'1.23'`` mean degrees of declination
and hours of right ascension.
This has wasted many hours of programmer time and confusion over the years,
is completely unnatural and at odds with how Python usually works,
and can never be fixed
because it would break all existing PyEphem programs.
* The API is also awkward
because it mutates objects in-place instead of returning results.
Instead of returning coordinates directly,
``compute()`` updates several fields on its object —
reflecting how the underlying C library works, which I didn’t write.
This makes a second line of code necessary
to go fetch the coordinates from the object.
* PyEphem is difficult to release
and difficult for many people to install,
because some of its code is written in the C language
and so a compiler is needed.
* PyEphem does not interoperate with NumPy
and so is awkward to use in a modern IPython Notebook.
For all of these reasons, PyEphem might not be the best choice
for a new project.
Two Alternatives
----------------
As the principle author of PyEphem,
I — `Brandon Rhodes |