MassProfile class

Calculates mass vs. radius relations and rotation curves for a given galaxy.

class galaxy.massprofile.MassProfile(gal, com_p=None)[source]

Class to define mass enclosed as a function of radius and circular velocity profiles for a given galaxy and simulation snapshot

Args:
gal (Galaxy object):
The desired galaxy/snap to operate on
com_p (3-vector):
Optional. The position of the disk CoM.
mass_enclosed(radii, ptype=None)[source]

Calculate the mass within a given radius of the CoM for a given type of particle.

Args:
radii (array of distances): spheres to integrate over ptype (int): particle type from (1,2,3), or None for total
Returns:
array of masses, in units of M_sun
mass_enclosed_total(radii)[source]

Calculate the mass within a given radius of the CoM, summed for all types of particle.

Args:
radii (array of distances): spheres to integrate over
Returns:
array of masses, in units of M_sun
halo_mass()[source]

Utility function to get a parameter for Hernquist mass

hernquist_mass(r, a, M_halo=None)[source]

Calculate the mass enclosed for a theoretical profile

Args:
r (Quantity, units of kpc):
distance from center
a (Quantity, units of kpc):
scale radius
M_halo (Quantity, units of M_sun):
total DM mass (optional)
Returns:
Total DM mass enclosed within r (M_sun)
circular_velocity(radii, ptype=None)[source]

Calculate orbital velocity at a given radius from the CoM for a given type of particle.

Args:
radii (array of distances):
circular orbit
ptype (int):
particle type from (1,2,3), or None for total
Returns:
array of circular speeds, in units of km/s
circular_velocity_total(radii)[source]

Syntactic sugar for circular_velocity(radii, ptype=None)

circular_velocity_hernquist(radii, a, M_halo=None)[source]

Theoretical V_circ assuming halo mass follows a Hernquist profile

Args:
radii (array of distances):
circular orbit
a (Quantity, units of kpc):
scale radius
M_halo (Quantity, units of M_sun):
total DM mass (optional)
fit_hernquist_a(r_inner=1, r_outer=30, get_details=False)[source]

Get scipy.optimize to do a non-linear least squares fit to find the best scale radius a for the Hernquist profile.

Args:
r_inner (numeric):
Optional. Minimum radius to consider (implicit kpc). Avoid values < 1 as they cause numeric problems.
r_outer (numeric):
Optional. Maximum radius to consider (implicit kpc).
sersic(R, Re, n, Mtot)[source]

Function that returns Sersic Profile for an Elliptical System (See in-class lab 6)

Input
R:
radius (kpc)
Re:
half mass radius (kpc)
n:
sersic index
Mtot:
total stellar mass
Returns
Surface Brightness profile in Lsun/kpc^2
bulge_Re(R)[source]

Find the radius enclosing half the bulge mass.

Args:
R (array of Quantity):
Radii to consider (kpc)
Returns:
Re (Quantity) :
Radius enclosing half light/mass (kpc)
bulge_total (numeric):
Mass of entire bulge (M_sun, no units)
bulgeI (array of Quantity):
Surface brightness at radii R (kpc^-2), assuming M/L=1
fit_sersic_n(R, Re, bulge_total, bulgeI)[source]

Get scipy.optimize to do a non-linear least squares fit to find the best value of n for a Sersic profile.

Args:
R (array of quantity):
Radii at which to calculate fit (kpc)
Re (Quantity) :
Radius enclosing half light/mass (kpc)
bulge_total (numeric):
Mass of entire bulge (M_sun, no units)
bulgeI (array of Quantity):
Surface brightness at radii R (kpc^-2)
Returns:
best n value and error estimate
density_profile_shell(radii, m, xyz)[source]

Calculates mass density in successive spherical shells

Arg:
radii (array of float):
boundary values beteen shells (implicit kpc, no units)
m (shape (N,) array of float):
particle masses (implicit Msun, no units)
xyz ((3,N) array of float):
particle cartesian coordinates
Returns:
r_annuli: geometric mean of boundaries
(array is one shorter than input radii)
rho: densities (Msun/kpc^3)
(same length as r_annuli)
density_profile_sphere(radii, m, xyz)[source]

Calculates average mass density within successive spherical radii

Arg:
radii (array of float):
boundary values beteen shells (implicit kpc, no units)
m (shape (N,) array of float):
particle masses (implicit Msun, no units)
xyz ((3,N) array of float):
particle cartesian coordinates
Returns:
rho: densities (Msun/kpc^3)
(same length as radii)
virial_radius(r_min=20, r_max=1000, rho_c=None)[source]

Calculates radius where DM density falls to 200x critical density for the universe.

Args:
r_min, r_max (floats)
optional, limits for search (implicit kpc, no units)
rho_c (float or Quantity)
optional, critical density for chosen cosmology
Returns:
r_200 (float): virial radius, implicit kpc
virial_mass(r_200=None, ptype=None)[source]

Mass enclosed by the virial radius