CenterOfMass class

Determines position and velocity of the COM for a galaxy/particle type combination.

class galaxy.centerofmass.CenterOfMass(gal, ptype=2)[source]

Class to define COM position and velocity properties of a given galaxy and simulation snapshot

Args:
gal (Galaxy object):
The desired galaxy/snap to operate on
ptype (int):
for particles, 1=DM/halo, 2=disk, 3=bulge
Throws:
ValueError, if there are no particles of this type in this galaxy (typically, halo particles in M33)
com_define(xyz, m)[source]

Function to compute the center of mass position or velocity generically

Args:
xyz (array with shape (3, N)):
(x, y, z) positions or velocities
m (1-D array):
particle masses
Returns:
3-element array, the center of mass coordinates
com_p(delta=0.1, vol_dec=2.0)[source]

Function to specifically return the center of mass position and velocity .

Kwargs:
delta (tolerance)
Returns:
One 3-vector, coordinates of the center of mass position (kpc)
com_v(xyz_com)[source]

Center of Mass velocity

Args: X, Y, Z positions of the COM (no units)

Returns: 3-Vector of COM velocities

center_com(com_p=None, com_v=None)[source]

Positions and velocities of disk particles relative to the CoM

Returns : two (3, N) arrays
CoM-centric position and velocity
angular_momentum(com_p=None, com_v=None, r_lim=None)[source]
Returns:
L : 3-vector as array
The (x,y,x) components of the angular momentum vector about the CoM, summed over all disk particles
pos, v : arrays with shape (3, N)
Position and velocity for each particle
r_lim : float
Radius to include in calculation (implicit kpc, no units)
rotate_frame(to_axis=None, com_p=None, com_v=None, r_lim=None)[source]
Arg: to_axis (3-vector)
Angular momentum vector will be aligned to this (default z-hat)
Returns: (positions, velocities), two arrays of shape (3, N)
New values for every particle. self.data remains unchanged.

Based on Rodrigues’ rotation formula Ref: https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula

shell_h(radii, m, xyz, vxyz)[source]

Calculate specific angular momentum of spherical shells.

Args:
radii ((M,0) array of float):
boundaries of shells (implicit kpc from center)
m ((N,) array of float):
masses (implicit Msun)
xyz, vxyz ((3,N) arrays of float):
positions and velocities (implicit kpc, km/s)
Returns:
rad ((M-1,) array):
midpoints of shells (implicit kpc)
L ((M-1,3) array of float):
total angular momentum
h ((M-1,3) array of float):
specific angular momentum, i.e. L/m
sphere_h(radii, m, xyz, vxyz)[source]

Calculate specific angular momentum within spheres.

Args:
radii ((M,0) array of float):
boundaries of shells (implicit kpc from center)
m ((N,) array of float):
masses (implicit Msun)
xyz, vxyz ((3,N) arrays of float):
positions and velocities (implicit kpc, km/s)
Returns:
L ((M,3) array of float):
total angular momentum
h ((M,3) array of float):
specific angular momentum, i.e. L/m
disp_by_radius(x, vy, xbins, binwidth=None)[source]

Calculate mean velocity and dispersion sigma for a set of radius bins

Args:
x (array of float):
lateral distance from CoM
vy (array of float):
radial velocity
xbins (array of float)
midpoints of equally-spaced bins
binwidth (float):
optional and probably useless