galpy is a Python package for galactic dynamics.
Loading ...
Explore
Easy to get started with, get advanced galactic dynamics at your fingertips
Get started with integrating orbits in a Milky-Way potential in just a few lines of code. Or build your own galactic models using a flexible set of components. From simple orbit integration to fast action-angle calculations, galpy has you covered.
Simple installation on all major operating systems
Whether you are on a Linux, Mac, or Windows system, installation is quick and painless. Use miniconda for a single-line installation of galpy and all of its dependencies with
conda install galpy -c conda-forge
or use pip for installing the latest release or the bleeding-edge main branch with all of the latest in-development features.
Extensive documentation and many ways to get help
All of galpy's features are documented with a rich set of examples in the quick-start guide and the full library reference guide. If you run into problems, open an issue on galpy's GitHub page, join the galpy slack community (join here), or email the code's maintainer. We're always happy to help!
Open-source, continuously-integrated, with >99.8% test coverage
Fully open-source development since day 1. All of galpy's development happens on GitHub, from simple maintenance to bleeding-edge new features. All code updates and pull requests are built and tested using continuous integration provided by GitHub Actions and appveyor. With test coverage exceeding 99.8%, galpy is as reliable as code gets.
galpy in action
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:
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 the Sun
from galpy.orbit import Orbit
from galpy.potential import MWPotential2014
import numpy
ts= numpy.linspace(0.,5.,2001)*u.Gyr
o= Orbit() # default = the sun
o.integrate(ts,MWPotential2014)
o.plot()
or calculate its orbital actions
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))
and much more...
(This interactive shell runs using the pyodide Python kernel, a version of Python that runs in your browser.)
Support and acknowledge galpy
The best way to support galpy is to acknowledge galpy in any work that you do with it, by linking to the code (at https://github.com/jobovy/galpy) and by citing the galpy paper:
galpy: A Python Library for Galactic Dynamics, Jo Bovy (2015), Astrophys. J. Supp., 216, 29
Make sure to check the detailed acknowledgement guide for additional essential references for certain parts of galpy.