Skip to content

Using Pidgey

This tutorial is the same as Milky Way Orbit. It uses pidgey to streamline the interface to the galactic dynamics packages.

from commensurability.tessellation import Tessellation

# plotting
from matplotlib import pyplot as plt

Define a Milky Way potential with your package of choice. Initialize the corresponding backend with pidgey.

import pidgey
backend = pidgey.AgamaBackend()

import agama
agama.setUnits(length=1, mass=1, velocity=1)  # 1 kpc, 1 Msun, 1 km/s

from example_mw_bar_potential_new import makePotentialModel
potential = makePotentialModel()

Potential Definition

This example imports the Milky Way potential definition from here.

import pidgey
backend = pidgey.GalaBackend()

import gala.potential as gp
potential = gp.MilkyWayPotential()
import pidgey
backend = pidgey.GalpyBackend()

from galpy.potential import MWPotential2014
potential = MWPotential2014

Define initial conditions using astropy and perform the orbit integration routine.

import astropy.coordinates as c
import astropy.units as u

ics = c.SkyCoord(
    x = 4 * u.kpc,
    y = 0 * u.kpc,
    z = 1 * u.kpc,
    v_x = 0 * u.km/u.s,
    v_y = 250 * u.km/u.s,
    v_z = 0 * u.km/u.s,
    frame="galactocentric",
    representation_type="cartesian",
)
coords = backend.compute_orbit(ics, potential, 0.005 * u.Gyr, 200)

Extract the orbit points and plug them into Tessellation.

# extract points from SkyCoord object
points = coords.xyz.T
tess = Tessellation(points)

The tessellation can then be plotted.

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
tess.plot(ax, plot_removed=True)
plt.show()

Agama orbit

Gala orbit

Galpy orbit