Welcome to galpy’s documentation

galpy is a Python package for galactic dynamics. It supports orbit integration in a variety of potentials, evaluating and sampling various distribution functions, and the calculation of action-angle coordinates for all static potentials. galpy is an astropy affiliated package and provides full support for astropy’s Quantity framework for variables with units.

galpy is developed on GitHub. If you are looking to report an issue, join the galpy slack community, or for information on how to contribute to the code, please head over to galpy’s GitHub page for more information.

Try galpy

Give galpy a try in the interactive IPython-like shell below!

Plot the rotation curve of the Milky Way

>>> from galpy.potential import (plotRotcurve,
        MWPotential2014 as mwp14)
>>> import matplotlib.pyplot as plt
>>> plotRotcurve(mwp14)
>>> plotRotcurve(mwp14[0],label='Bulge',overplot=True)
>>> plotRotcurve(mwp14[1],label='Disk',overplot=True)
>>> plotRotcurve(mwp14[2],label='Halo',overplot=True)
>>> plt.legend()

or integrate the orbit of MW satellites

>>> from galpy.orbit import Orbit
>>> from galpy.potential import MWPotential2014
>>> import numpy
>>> ts= numpy.linspace(0.,5.,2001)*u.Gyr
>>> o= Orbit.from_name('MW satellite galaxies')
>>> o.integrate(ts,MWPotential2014)
>>> o.plot(xrange=[0.,100.],yrange=[-100.,100.])
>>> o[o.name=='LMC'].plot(c='r',lw=5.,overplot=True)

or calculate the Sun's orbital actions, frequencies, and angles

>>> from galpy.orbit import Orbit
>>> from galpy.potential import (
        MWPotential2014 as mwp14)
>>> o= Orbit()
>>> print(o.jr(pot=mwp14),o.Lz(),o.jz(pot=mwp14))
>>> print(o.Or(pot=mwp14),o.Op(pot=mwp14),o.Oz(pot=mwp14))
>>> print(o.wr(pot=mwp14),o.wp(pot=mwp14),o.wz(pot=mwp14))

and much more... Start your journey below


(This interactive shell runs using the pyodide Python kernel, a version of Python that runs in your browser. galpy runs in your browser at compiled-C-like speed! Please open an Issue for any problems that you find with the interactive session.)

Quick-start guide

Acknowledging galpy

If you use galpy in a publication, please cite the following paper

  • galpy: A Python Library for Galactic Dynamics, Jo Bovy (2015), Astrophys. J. Supp., 216, 29 (arXiv/1412.3451).

and link to http://github.com/jobovy/galpy. Some of the code’s functionality is introduced in separate papers:

Please also send me a reference to the paper or send a pull request including your paper in the list of galpy papers on this page (this page is at doc/source/index.rst). Thanks!

Papers using galpy

galpy has been used in more than 200 scientific publications in the astrophysical literature. Covering topics as diverse as the properties of planetary systems around distant stars, the kinematics of pulsars and stars ejected from the Milky Way by supernova explosions, binary evolution in stellar clusters, chemo-dynamical modeling of stellar populations in the Milky Way, and the dynamics of satellites around external galaxies, galpy is widely used throughout astrophysics.

Check out the gallery below for examples:

Indices and tables