Remnant class¶
Treats the post-merger remnant of MW-M31 as a galaxy.
-
class
galaxy.remnant.Remnant(snap=801, datadir=None, usesql=False, stride=1, ptype=(2, 3))[source]¶ A class to work with the MW-M31 post-merger remant.
- Args:
- snap (int):
- Snap number, equivalent to time elapsed. Defaults to the last timepoint.
- datadir (str):
- Directory to search first for the required file. Optional, and a default list of locations will be searched.
- usesql (bool):
- If True, data will be taken from a PostgreSQL database instead of text files.
- stride (int):
- Optional. For stride=n, get every nth row in the table. Only valid with usesql=True.
- ptype (int or iterable of int):
- Particle type: 1, 2, 3 or a combination of these
- Class attributes:
- data (np.ndarray):
- type, mass, position_xyz, velocity_xyz for each particle
-
read_db(stride)[source]¶ Get relevant data from a PostgreSQL database and format it to be identical to that read from test files.
Ex-disk and ex-bulge particles are included, not DM particles.
- Args:
- stride (int):
- Optional. For stride=n, get every nth row in the table.
- Changes:
- self.time, self.particle_count and self.data are set.
Returns: nothing
-
I_tensor(m, x, y, z)[source]¶ - Args:
- m, x, y, z:
- 1-D arrays with mass and coordinates (no units)
- Returns:
- 3x3 array representing the moment of inertia tensor
-
ellipsoid_axes(m, x, y, z, r_lim=None)[source]¶ - Args:
- m, x, y, z:
- 1-D arrays with mass and coordinates (no units)
- r_lim : float
- Radius to include in calculation (implicit kpc, no units)
- Returns:
- Two 3-tuples: relative semimajor axes and principal axis vectors
-
sub_mass_enclosed(radii, m, xyz)[source]¶ Calculate the mass within a given radius of the origin. Based on code in MassProfile, but this version assumes CoM-centric coordinates are supplied.
- Args:
- radii (array of distances): spheres to integrate over m (array of masses): shape (N,) xyz (array of Cartesian coordinates): shape (3,N)
- Returns:
- array of masses, in units of M_sun
-
hernquist_mass(r, a, M_halo)[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
- Returns:
- Total DM mass enclosed within r (M_sun)
-
fit_hernquist_a(m, xyz, r_inner=1, r_outer=100)[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
-
Re(R, m, xyz)[source]¶ Find the radius enclosing half the mass.
- Args:
- R (array of Quantity):
- Radii to consider (kpc)
- m (array of float):
- masses (no units)
- xyz (array of float with shape (3,N)):
- coordinates (implicit kpc)
- Returns:
- sub_Re (Quantity) :
- Radius enclosing half light/mass (kpc)
- sub_total (numeric):
- Mass of entire system (M_sun, no units)
- subI (array of Quantity):
- Surface brightness at radii R (kpc^-2), assuming M/L=1
-
fit_sersic_n(R, sub_Re, sub_total, subI)[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