Skip to article frontmatterSkip to article content

Hands-on Practice: Local Group Cartography

Astro-RPS Week 6 Saturday Bootcamp

Mapping the Local Group of Galaxies

Context

In this practice, we are going to make a map of the Local Group of galaxies (and associated star clusters). Roughly speaking, the Local Group refers to the gravitationally-bound group of galaxies within which the Milky Way resides; it spans out to roughly 10 million light years from the Milky Way (3 Megaparsecs, in more common units in the field). This volume contains just two massive galaxies -- the Milky Way and Andromeda -- in addition to hundreds of low-mass dwarf galaxies and thousands of star clusters.

We usually think of the positions of things in the Local Group in Galactocentric Cartesian coordinates (X, Y, Z), where the origin is at the center of the Milky Way galaxy. However, we cannot observe these directly. Instead, we typically record the angular positions of stars/galaxies, etc., in “Right Ascension” (0-360 degrees) and “Declination” (-90 to 90 degrees) as well as their distances with respect to the Sun (their “heliocentric distances”). These measurable quantities can be converted to the Galactocentric coordinate system, assuming a reference frame for the Milky Way.

For today’s exercise, we’re going to give you this conversion in the form of a function below.

from astropy import units as u
from astropy.coordinates import SkyCoord, Galactocentric
import numpy as np

def convert_to_galactocentric(ra, dec, distance_kpc):
    """
    Convert RA, Dec, and heliocentric distance to Galactocentric Coordinates.
    
    Parameters:
        ra (float): Right Ascension in degrees
        dec (float): Declination in degrees
        distance_kpc (float): Heliocentric distance in kpc
        
    Returns:
        tuple: (GCX, GCY, GCZ) in kpc
    """
    # Create a SkyCoord object
    coord = SkyCoord(ra=ra * u.deg, dec=dec * u.deg, distance=distance_kpc * u.kpc, frame='icrs')
    
    # Convert to Galactocentric coordinates
    gc_coord = coord.transform_to(Galactocentric())
    
    # Convert to Cartesian coordinates
    gcx = gc_coord.cartesian.x.to(u.kpc).value
    gcy = gc_coord.cartesian.y.to(u.kpc).value
    gcz = gc_coord.cartesian.z.to(u.kpc).value
    
    return gcx, gcy, gcz

An example of using this function for a single trio of (RA,DEC,distance):

# Example usage:
ra = 180.0  # degrees
dec = 45.0  # degrees
distance = 10.0  # kpc
x, y, z = convert_to_galactocentric(ra, dec, distance)
print(f"X: {sgx:.2f} kpc")
print(f"Y: {sgy:.2f} kpc")
print(f"Z: {sgz:.2f} kpc")
X: -11.13 kpc
Y: 1.79 kpc
Z: 9.39 kpc