.. galpy documentation master file, created by sphinx-quickstart on Sun Jul 11 15:58:27 2010. .. ifconfig:: not_on_rtd .. WARNING:: You are looking at the rarely updated, GitHub version of this documentation, **please go to** `galpy.readthedocs.io `_ **for the latest documentation**. 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: Try ``galpy`` ------------- Give ``galpy`` a try in the interactive ``IPython``-like shell below! .. raw:: html

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 ----------------- .. grid:: 1 2 3 4 :gutter: 4 .. grid-item-card:: Installation :link: installation :link-type: doc Install galpy on Linux, Mac, or Windows via pip or conda, including optional C extensions and configuration. Development installation from source and development setup. .. grid-item-card:: What's New :link: whatsnew :link-type: doc High-level release notes for all galpy versions. .. grid-item-card:: Rotation Curves, Units, and First Orbits :img-top: images/tutorials/getting_started_rotation_curves_and_units.png :link: tutorials/getting_started/rotation_curves_and_units :link-type: doc Set up basic potentials, plot rotation curves, understand galpy's natural and physical unit systems, and integrate a simple orbit. Potentials ^^^^^^^^^^ .. grid:: 1 2 3 4 :gutter: 4 .. grid-item-card:: Introduction to Potentials :img-top: images/tutorials/potentials_introduction.png :link: tutorials/potentials/introduction :link-type: doc Evaluate potentials, forces, and densities. Combine potentials, plot rotation curves and potential contours, compute orbital frequencies and Lindblad resonances. .. grid-item-card:: Milky Way-like Potentials :img-top: images/tutorials/potentials_milky_way_potentials.png :link: tutorials/potentials/milky_way_potentials :link-type: doc Use built-in Milky Way potentials: MWPotential2014, McMillan17, Irrgang13, Cautun20, DehnenBinney98. Add a central black hole or dynamical friction. .. grid-item-card:: Potential Wrappers :img-top: images/tutorials/potentials_wrappers.png :link: tutorials/potentials/wrappers :link-type: doc Modify potentials with time-dependent amplitudes, solid-body rotation, tilting, and offsetting using wrapper classes. .. grid-item-card:: SCF and Multipole Expansions :img-top: images/tutorials/potentials_scf_and_multipole.png :link: tutorials/potentials/scf_and_multipole :link-type: doc Represent arbitrary density distributions using basis-function (SCF) or multipole expansions, including time-dependent and disky potentials. .. grid-item-card:: Dissipative Forces :img-top: images/tutorials/potentials_dissipative.png :link: tutorials/potentials/dissipative :link-type: doc Use velocity-dependent forces like Chandrasekhar dynamical friction and non-inertial frame forces for orbit integration. Includes the Schwarzschild precession of S2 around Sgr A*. .. grid-item-card:: N-body Simulation Potentials :img-top: images/tutorials/potentials_nbody_snapshots.png :link: tutorials/potentials/nbody_snapshots :link-type: doc Use frozen N-body simulation potentials in galpy with pynbody for orbits, action-angle coordinates, and analysis. .. grid-item-card:: Using Potentials in Other Codes :img-top: images/potential-amuse-example.png :link: tutorials/potentials/other_codes :link-type: doc Export galpy potentials to NEMO, AMUSE, AGAMA, and gala for use in other simulation frameworks. Orbits ^^^^^^ .. grid:: 1 2 3 4 :gutter: 4 .. grid-item-card:: Orbit Initialization :img-top: images/tutorials/orbits_initialization.png :link: tutorials/orbits/initialization :link-type: doc Initialize orbits in cylindrical coordinates, with physical units, from observed coordinates (RA/Dec, Galactic), or from astropy SkyCoord objects. .. grid-item-card:: Multiple Orbits :img-top: images/tutorials/orbits_multiple_orbits.png :link: tutorials/orbits/multiple_orbits :link-type: doc Work with multiple orbits at once: array and SkyCoord initialization, slicing, reshaping, and parallel integration. .. grid-item-card:: Orbits of Known Objects :img-top: images/tutorials/orbits_known_objects.png :link: tutorials/orbits/known_objects :link-type: doc Initialize orbits from object names using built-in catalogs or SIMBAD. Load collections of MW globular clusters, satellite galaxies, or the solar system. .. grid-item-card:: Integration and Plotting :img-top: images/tutorials/orbits_integration_and_plotting.png :link: tutorials/orbits/integration_and_plotting :link-type: doc Integrate orbits, display various projections, access orbital quantities, check energy conservation, use non-inertial frames, and compute surfaces of section. .. grid-item-card:: Fast Orbit Characterization :img-top: images/tutorials/orbits_fast_characterization.png :link: tutorials/orbits/fast_characterization :link-type: doc Quickly compute eccentricity, peri/apocenter, and zmax using the Staeckel approximation without orbit integration. Also compute actions! .. grid-item-card:: Phase-Space Volumes and Chaos :img-top: images/tutorials/orbits_phase_space_volumes_and_chaos.png :link: tutorials/orbits/phase_space_volumes_and_chaos :link-type: doc Integrate phase-space deviations in 2D and 3D with the variational equations, verify Liouville's theorem, and compute Lyapunov exponents to detect chaos. .. grid-item-card:: Orbit Examples :img-top: images/tutorials/orbits_examples.png :link: tutorials/orbits/examples :link-type: doc Detailed examples: thick-disk eccentricity distribution, LMC orbit with dynamical friction, and barycentric acceleration from the LMC. Action-Angle Coordinates ^^^^^^^^^^^^^^^^^^^^^^^^ .. grid:: 1 2 3 4 :gutter: 4 .. grid-item-card:: Introduction to Action-Angle Coordinates :img-top: images/tutorials/action_angle_introduction.png :link: tutorials/action_angle/introduction :link-type: doc Overview of action-angle variables, using the Orbit interface, calculating actions for isochrone and spherical potentials, and exact inverse transforms in the isochrone case. .. grid-item-card:: Staeckel Approximation :img-top: images/tutorials/action_angle_staeckel.png :link: tutorials/action_angle/staeckel :link-type: doc The most accurate general method for computing actions in axisymmetric potentials, with grid-based interpolation for speed. Includes a Gaia example showing Lindblad resonances. .. grid-item-card:: Adiabatic Approximation :img-top: images/tutorials/action_angle_adiabatic.png :link: tutorials/action_angle/adiabatic :link-type: doc Fast action calculation by separating radial and vertical motions, best for thin-disk orbits. .. grid-item-card:: Orbit Integration-based Method :img-top: images/tutorials/action_angle_isochroneapprox.png :link: tutorials/action_angle/isochroneapprox :link-type: doc General action-angle calculation by integrating the orbit and using a best-fit isochrone potential. .. grid-item-card:: 1D Actions and Inverse Transformations :img-top: images/tutorials/action_angle_vertical_and_inverse.png :link: tutorials/action_angle/vertical_and_inverse :link-type: doc One-dimensional action-angle coordinates for harmonic oscillators and vertical oscillations, and their inverse transformations. .. grid-item-card:: Inverse Transformations (TorusMapping) :img-top: images/tutorials/action_angle_torus.png :link: tutorials/action_angle/torus :link-type: doc Compute phase-space coordinates from given actions and angles using the Torus Mapper. Distribution Functions ^^^^^^^^^^^^^^^^^^^^^^ .. grid:: 1 2 3 4 :gutter: 4 .. grid-item-card:: Two-dimensional Disk DFs :img-top: images/tutorials/distribution_functions_disk_df_2d.png :link: tutorials/distribution_functions/disk_df_2d :link-type: doc Dehnen, Shu, and Schwarzschild distribution functions for razor-thin disks: moments, asymmetric drift, Oort constants, sampling, and non-axisymmetric evolution. .. grid-item-card:: Three-dimensional Disk DFs :img-top: images/tutorials/distribution_functions_disk_df_3d.png :link: tutorials/distribution_functions/disk_df_3d :link-type: doc Quasi-isothermal distribution function for 3D disk populations using action-angle variables: moments, velocity ellipsoid tilt, and velocity sampling. .. grid-item-card:: Spherical DFs :img-top: images/tutorials/distribution_functions_spherical_dfs.png :link: tutorials/distribution_functions/spherical_dfs :link-type: doc Isotropic and anisotropic distribution functions for spherical systems: Hernquist, NFW, King, Plummer, Power-law, and general models. Includes N-body initial conditions for a truncated NFW halo and a two-component dwarf galaxy (stars embedded in dark matter). Tidal Streams ^^^^^^^^^^^^^ .. grid:: 1 2 3 4 :gutter: 4 .. grid-item-card:: Stream Modeling with streamdf :img-top: images/tutorials/streams_streamdf.png :link: tutorials/streams/streamdf :link-type: doc Model tidal streams in action-angle coordinates: predict stream tracks, compute densities, sample mock data, and evaluate the full phase-space PDF. And model gaps. .. grid-item-card:: Particle-spray with streamspraydf :img-top: images/tutorials/streams_streamspraydf.png :link: tutorials/streams/streamspraydf :link-type: doc Generate tidal streams using particle-spray techniques with chen24spraydf and fardal15spraydf. Extending galpy ^^^^^^^^^^^^^^^ .. grid:: 1 2 3 4 :gutter: 4 .. grid-item-card:: New Potentials in Python :img-top: images/tutorials/extending_new_potential_python.png :link: tutorials/extending/new_potential_python :link-type: doc Define custom potential classes and dissipative forces in Python by implementing force and potential evaluation methods, with full support for orbit integration and physical units. .. grid-item-card:: New Potentials in C :link: tutorials/extending/new_potential_c :link-type: doc Add C implementations of potentials for fast orbit integration and action-angle calculations. .. toctree:: :hidden: installation.rst whatsnew.rst Library reference ----------------- .. toctree:: :maxdepth: 2 reference/orbit.rst reference/potential.rst reference/aa.rst reference/df.rst reference/util.rst 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: * ``galpy.actionAngle.EccZmaxRperiRap`` and ``galpy.orbit.Orbit`` methods with ``analytic=True``: Fast method for computing orbital parameters: please cite `Mackereth & Bovy (2018) `__. * ``galpy.actionAngle.actionAngleAdiabatic``: please cite `Binney (2010) `__. * ``galpy.actionAngle.actionAngleStaeckel``: please cite `Bovy & Rix (2013) `__ and `Binney (2012) `__. * ``galpy.actionAngle.actionAngleIsochroneApprox``: please cite `Bovy (2014) `__. * ``galpy.df.streamdf``: please cite `Bovy (2014) `__. * ``galpy.df.streamgapdf``: please cite `Sanders, Bovy, & Erkal (2016) `__. * ``galpy.df.chen24spraydf``: please cite `Chen et al. (2024) `__ for the method and the ``galpy`` implementation * ``galpy.df.fardal15spraydf``: please cite `Fardal et al. (2015) `__ for the method and `Qian et al. (2022) `__ for the ``galpy`` implementation * ``galpy.potential.ttensor`` and ``galpy.potential.rtide``: please cite `Webb et al. (2019a) `__. * ``galpy.potential.to_amuse``: please cite `Webb et al. (2019b) `_. 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 -------------------- .. raw:: html

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 ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search`