Related Topics

Quick search

PyEphem measures all angles in radians.
But rather than simply returning angles as bare Python floats,
it returns each of them as an ephem.Angle
which can print itself out in a more attractive format
than do raw floating-point numbers.

The vast majority of angles print as degrees.
For example,
the declination of Jupiter will print itself attractively
as degrees, minutes of arc, and seconds of arc:

If you want to display the result of a computation
as an attractively formatted angle,
you can convert the float back to a PyEphem angle type
using either the degrees() function
or, for right ascension, the hours() function.
For example,
here are the results of adding fifteen degrees
to both Jupiter’s declination and right ascension;
whereas the declination simply moves north by fifteen degrees
(passing north across the celestial equator into positive numbers),
the right ascension calls fifteen additional degrees “one hour” of motion:

Often when adding or subtracting with angles,
you will get a very large or small result
that you will want to normalize back to a respectable angle.
PyEphem angles offer two ways to make this convenient:
a norm attribute that returns the angle
normalized to the interval [0, 2π)
and a znorm attribute that returns the angle
normalized to the interval (-π, π] centered on zero.