# 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.)

## 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: