Python implementation of Jean Meeus astronomical routines
Library of astronomical algorithms in Python.
PyMeeus is a Python implementation of the astronomical algorithms described in the classical book 'Astronomical Algorithms, 2nd Edition, Willmann-Bell Inc. (1998)' by Jean Meeus.
There are great astronomical libraries out there. For instance, if
you're looking for high precision and speed you should take a look at
libnova <http://libnova.sourceforge.net/>
. For a set of python
modules aimed at professional astronomers, you should look at
Astropy <http://www.astropy.org/>
. On the other hand, the advantages
of PyMeeus are its simplicity, ease of use, ease of reading, ease of
installation (it has the minimum amount of dependencies) and abundant
documentation.
The easiest way of installing PyMeeus is using pip:
.. code:: sh
pip install pymeeus
Or, for a per-user installation:
.. code:: sh
pip install --user pymeeus
If you prefer Python3, you can use:
.. code:: sh
pip3 install --user pymeeus
If you have PyMeeus already installed, but want to upgrade to the latest version:
.. code:: sh
pip3 install -U pymeeus
It is very common to try to run PyMeeus like this:
.. code:: sh
import pymeeus
mydate = pymeeus.Epoch(1992, 10, 13.0)
But if you do that, you'll get an error like this:
.. code:: sh
Traceback (most recent call last):
File "/home/user/test/test.py", line 3, in
This issue points to a misunderstanding that is very common in the
Python world. The keyword import
is used to import MODULES\ ...
but PyMeeus is NOT a module: It is a LIBRARY composed of
MULTIPLE modules (Angle
, Epoch
, Coordinates
, etc). As of
today, the library Pymeeus has 19 different modules (if you look into
the directory where pip
stores the library, you'll find one ".py"
file per module).
Therefore if you want to use, for example, the module Angle
you
should use:
.. code:: sh
import pymeeus.Angle
I.e., your module is pymeeus.Angle
, and not just Angle
.
But there is more! When you use import
to fetch a module, you must
then use the dot notation to access the components of the module
(classes, functions, etc). For instance:
.. code:: sh
import pymeeus.Angle
i = pymeeus.Angle.Angle(11.94524)
In this case, you are telling the Python interpreter that you want to
use the class Angle
(with parameter '11.94524') from the module
Angle
belonging to the library pymeeus
.
There is, however, a more practical (and common) way to handle modules
using the statement from <MODULE> import <COMPONENT>
. For instance:
.. code:: sh
from pymeeus.Angle import Angle from pymeeus.Epoch import Epoch, JDE2000 from math import sin, cos, tan, acos, atan2, sqrt, radians, log10
This way is preferred because, among other reasons, only the required components are loaded into memory instead of the whole module. Also, now the component is directly added to your execution environment, which means that you no longer need to use the dot notation.
Therefore, the script at the beginning would become:
.. code:: sh
from pymeeus.Epoch import Epoch
mydate = Epoch(1992, 10, 13.0)
Author: Dagoberto Salazar
Distributed under the GNU Lesser General Public License v3 (LGPLv3). See
LICENSE.txt
and COPYING.LESSER
for more information.
Documentation: https://pymeeus.readthedocs.io/en/latest/
GitHub: https://github.com/architest/pymeeus
If you have Sphinx installed, you can generate your own, latest documentation going to directory 'docs' and issuing:
.. code:: sh
make html
Then the HTML documentation pages can be found in 'build/html'.
The preferred method to contribute is through forking and pull requests:
git checkout -b feature/fooBar
)git commit -am 'Add some fooBar'
)git push origin feature/fooBar
)Please bear in mind that PyMeeus follows the PEP8 style guide for Python
code (PEP8) <https://www.python.org/dev/peps/pep-0008/?>
. We suggest
you install and use a linter like
Flake8 <http://flake8.pycqa.org/en/latest/>
before contributing.
Additionally, PyMeeus makes heavy use of automatic tests. As a general
rule, every function or method added must have a corresponding test in
the proper place in tests
directory.
Finally, documentation is also a big thing here. Add proper and abundant documentation to your new code. This also includes in-line comments!!!.
Neil Freeman <https://github.com/fitnr>
__ - Fixed undefined
variable in Epoch.tt2utmolsen234 <https://github.com/molsen234>
__ - Fixed bug when using
fractional seconds, minutes, hours or daysSebastian Veigl <https://github.com/sebastian1306>
__ - Added
functionality for Jupiter's moonsBen Dilday <https://github.com/bdilday>
__ - Added __hash__()
method to class EpochZivoslav <https://github.com/zivoslav>
__ - Bug report of winter
solsticeDevid <https://github.com/sevdog>
, Hugo van Kemenade <https://github.com/hugovk>
- Test suggestions0.5.12
0.5.11
local
to the Epoch
class constructor and
the methods get_date()
and get_full_date()
.0.5.10
moon_librations()
and
moon_position_angle_axis()
.0.5.9
moon_maximum_declination()
.0.5.8
Epoch
class, and added method doy()
.0.5.7
moon_passage_nodes()
.0.5.6
moon_perigee_apogee()
.0.5.5
moon_phase()
.0.5.4
illuminated_fraction_disk()
and
position_bright_limb()
to Moon
class.0.5.3
Sun.equation_of_time()
.0.5.2
0.5.1
0.5.0
Moon
class and position()
methods.0.4.3
ring_parameters()
to Saturn class.0.4.2
__hash__()
to Epoch. Now Epoch objects can be
used as keys in a dictionary.0.4.1
0.4.0
0.3.13
0.3.12
encoding
keyword from setup.py, which was giving
problems.0.3.11
0.3.10
0.3.9
0.3.8
Epoch.tt2ut
.0.3.7
0.3.6
0.3.5
magnitude()
to planet classes.0.3.4
0.3.3
0.3.2
0.3.1
geocentric_position()
, and tests and
examples for Pluto
class.0.3.0
Pluto
class.