Galaxy mass models

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

3D and 2D mass models for different mass and light profiles.

class galaxy.massModels.DoubleExponentialDisk(Re: Union[int, float], hz: Union[int, float], M_L: Union[int, float], q0: Optional[float] = None, Ie: Optional[float] = None, mag: Optional[float] = None, offset: Optional[float] = None, inc: Optional[float] = None, inc0: Optional[float] = None, unit_Re: str = 'kpc', unit_hz: str = 'kpc', unit_Ie: str = 'erg/(cm^2.s.A)', unit_M_L: str = 'solMass.s.A.cm^2/(erg.kpc^2)', **kwargs)[source]

Bases: galaxy.massModels.Sersic, galaxy.massModels.MassModelBase

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

Double exponential disk profile class implementing Bovy rotation curve.

Note

You can either provide:

  • M_L, hz, Re and Ie

  • M_L, hz, Re, mag and offset

You can also provide q0 instead of hz (which must be None in this case).

The observed or intrinsic inclination must be given with inc or inc0, respectively, if one wants to correct the central surface brightness for the effect of finite thickness.

Parameters
  • hz (int or float) – vertical scale height

  • M_L (int or float) – mass to light ratio

  • Re (int or float) – half-light radius in the plane of symmetry

  • inc (float) – (Optional) observed inclination (not corrected of the galaxy thickness)

  • inc0 (float) – (Optional) intrinsic inclination (corrected of the galaxy thickness)

  • Ie (float) – (Optional) intensity at half-light radius if the galaxy was seen face-on (must correct for inclination effects)

  • mag (float) – (Optional) galaxy total integrated magnitude used to compute Ie if not given

  • offset (float) – (Optional) magnitude offset in the magnitude system used

  • q0 (float) – (Optional) axis ratio equal to hz/Rd with Rd the disk scale length. If this value is different from None, it overrides hz.

  • unit_Ie (str) – (Optional) unit for the surface brightness

  • unit_M_L (str) – (Optional) unit of the mass to light ratio

  • unit_Re (str) – (Optional) unit for the scale radius Re

Rd

Disk scale length \(R_{\rm{d}} = R_{\rm{e}} / b_n\)

property _Rmax_razor_thin: Type[astropy.units.quantity.Quantity]

Position of the maximum of the razor-thin disk curve

property _Vmax_correction: Type[astropy.units.quantity.Quantity]

Maximum of the velocity correction

\[V_{\rm{c, max}} = \sqrt{2\pi G h_z \Upsilon \Sigma_0 / \exp\lbrace 1 \rbrace},\]

with \(\Sigma_0\) the central surface brightness if the disk was seen face-on, and \(\Upsilon\) the mass to light ratio.

property _Vmax_razor_thin: Type[astropy.units.quantity.Quantity]

Maximum velocity if the disk was razor thin.

__init__(Re: Union[int, float], hz: Union[int, float], M_L: Union[int, float], q0: Optional[float] = None, Ie: Optional[float] = None, mag: Optional[float] = None, offset: Optional[float] = None, inc: Optional[float] = None, inc0: Optional[float] = None, unit_Re: str = 'kpc', unit_hz: str = 'kpc', unit_Ie: str = 'erg/(cm^2.s.A)', unit_M_L: str = 'solMass.s.A.cm^2/(erg.kpc^2)', **kwargs) None[source]

Note

You can either provide:

  • n, Re and Ie

  • n, Re, mag and offset

Parameters
  • n (int or flat) – Sersic index

  • Re (int or float) – half-light radius

  • Ie (float) – (Optional) intensity at half-light radius

  • mag (float) – (Optional) galaxy total integrated magnitude used to compute Ie if not given

  • offset (float) – (Optional) magnitude offset in the magnitude system used

  • unit_Ie (str) – (Optional) unit for the surface brightness. If Ie already has a unit, it is converted to this unit.

  • unit_Re (str) – (Optional) unit for the scale radius Re. If Re already has a unit, it is converted to this unit.

Raises
  • TypeError – if n or Re are neither int, float, np.float16, np.float32 or np.float64

  • ValueError – if Ie and mag and offset are None, if n <= 0, if Re <= 0 or if Ie <= 0

property _ramp_radius: float

Compute the radius where the ramp approximation ends (same unit as Rd).

property _ramp_slope: float

Compute the slope for the ramp approximation.

_velocity_correction(R: Union[float, numpy.ndarray], *args, **kwargs) Union[float, Type[astropy.units.quantity.Quantity]][source]

Velocity correction necessary for the rotation curve

\[V_{\rm{corr}} (r) = V_{\rm{c, max}} \times \sqrt{\frac{r~e^{1-r/R_{\rm{d}}}}{R_{\rm{d}}}},\]

where \(R_{\rm{d}}\) is the disk scale length, and \(V_{\rm{c, max}}\) is the maximum of the velocity correction.

Parameters

R (float or ndarray[float]) – radius where the velocity correction is computed

Returns

velocity correction

Return type

float or ndarray[float]

_velocity_razor_thin(R: Union[float, numpy.ndarray], *args, **kwargs) Union[float, numpy.ndarray][source]

Velocity if the disk was razor thin.

Parameters

R (float or ndarray[float]) – radius where the velocity is computed

Returns

velocity if the disk was razor thin

Return type

float or ndarray[float]

hz

Scale height

inner_ramp_approximation(R: Union[float, numpy.ndarray], *args, **kwargs) Union[float, numpy.ndarray][source]

Inner ramp approximation. This gives the linear model which is tagent to the bovy rotation curve. It is used to correct the rotation curves in the inner parts where the bovy correction becomes larger than the razor thin disk velocity.

Parameters

R (float or ndarray[float]) – radius where to compute the velocity

Returns

velocity profile for the inner ramp

Return type

float or ndarray[float]

Raises
  • TypeError – if R is neither int, float, np.float16, np.float32, np.foat64 or ndarray

  • ValueError – if R is larger than the ramp radius

profile(R: Union[int, float], z: Union[int, float], *args, **kwargs) float[source]

Light density profile at radius R and height z

\[\rho(R, z) = \frac{\Sigma_0}{2 h_z} e^{-R/R_{\rm{e}} - |z|/h_z}\]

with \(\Sigma_0 = I_{\rm{e}} e^{b_1}\) the central surface density in the plane of the disk, \(R_{\rm{e}}\) the disk effective radius in the plane of symmetry and \(h_z\) the vertical scale height.

Parameters
  • R (int or float) – radial position in the plane of symmetry

  • z (int or float) – vertical position

Returns

double exponential profile computed at position (R, z)

Return type

float

q0

Axis ratio

velocity(R: Union[float, numpy.ndarray], *args, inner_correction: bool = False, **kwargs) Type[astropy.units.quantity.Quantity][source]

Velocity profile for a self-sustaining 3D double exponential disk against its own gravity through centripedal acceleration

\[V(r) = \sqrt{V_{\rm{RT}}^2 (r) - V_{\rm{corr}}^2 (r)},\]

where \(V_{\rm{RT}}\) is the rotation curve of a similar razor-thin disk, and \(V_{\rm{corr}}\) is the correction to apply to take into account the finite thickness of the disk.

Note

This formula is a Bovy rotation curve, i.e. an approximation for a thin (but non-zero thickness) disk.

This rotation curve is ill-defined below a certain radius which depends on the disk thickness since the correction will become too important near the centre of the galaxy.

To correct for this effect, one can use the inner_correction optional parameter. This parameter will approximate the rotation curve in the inner parts. The approximation, called inner ramp, corresponds to the tangent which passes through the origin. This simply writes as

\[V(r) = V_{\rm{d}} (R_0) \times r / R_0,\]

where \(V_{\rm{d}}\) is the Bovy rotation curve defined above and \(R_0\) is the radius at which the tangent line passes through the origin. From personal derivations, this radius is the solution of the following equation

\[x^2 \left [ I_1(x) K_0(x) - I_0(x) K_1(x) \right ] + x I_1(x) K_1(x) + q_0 (x + 0.5) e^{-2x} = 0,\]

where \(I_n\) and \(K_n\) are the modified Bessel functions of first and second kind, respectively, and \(q_0\) is the disk thickness.

A numerical approximation, incorrect by less than 1% in the \(0 < q_0 < 1\) range, is given by

\[\log R / R_{\rm{d}} = 0.767 + 0.86 \times x - 0.14 \times x^2 - 0.023 \times x^3 + 0.005 \times x^4 + 0.001 \times x^5,\]

where \(x = \log q_0\).

Parameters
  • R (float or ndarray[float]) – radius where the velocity is computed

  • inner_correction (bool) – (Optional) whether to apply the correction in the inner parts (ramp approximation) or not

Returns

velocity in \(\rm{km/s}\)

Return type

Astropy Quantity

Raises

TypeError – if R is neither int, float, np.float16, np.float32, np.foat64 or ndarray

class galaxy.massModels.ExponentialDisk(Re: Union[int, float], M_L: Union[int, float], Ie: Optional[float] = None, mag: Optional[float] = None, offset: Optional[float] = None, unit_Re: str = 'kpc', unit_Ie: str = 'erg/(cm^2.s.A)', unit_M_L: str = 'solMass.s.A.cm^2/(erg.kpc^2)', **kwargs)[source]

Bases: galaxy.massModels.Sersic, galaxy.massModels.MassModelBase

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

2D/3D exponential disk profile class (razor-thin).

Note

Some functions such as the light profile correspond to the 2D Sersic profiles, while others such as the velocity assume a 3D razor-thin disk.

Note

You can either provide:

  • M_L, Re and Ie

  • M_L, Re, mag and offset

Parameters
  • M_L (int or float) – mass to light ratio

  • Re (int or float) – half-light radius

  • Ie (float) – (Optional) intensity at half-light radius

  • mag (float) – (Optional) galaxy total integrated magnitude used to compute Ie if not given

  • offset (float) – (Optional) magnitude offset in the magnitude system used

  • unit_Ie (str) – (Optional) unit for the surface brightness. If Ie already has a unit, it is converted to this unit.

  • unit_M_L (str) – (Optional) unit of the mass to light ratio

  • unit_Re (str) – (Optional) unit for the scale radius Re. If Re already has a unit, it is converted to this unit.

Raises

astropy.units.core.UnitConversionError – if Vmax could not be broadcast to km/s unit

Rd

Disk scale length \(R_{\rm{d}} = R_{\rm{e}} / b_n\)

Rmax

Position of maximum velocity \(2.15 \times R_{\rm{d}}\)

Vmax

Maximum velocity \(0.8798243 \times \sqrt{\pi G R_{\rm{d}} \Sigma_0 \Upsilon }\) with \(\Sigma_0\) the central surface brightness and \(\Upsilon\) the mass to light ratio

__init__(Re: Union[int, float], M_L: Union[int, float], Ie: Optional[float] = None, mag: Optional[float] = None, offset: Optional[float] = None, unit_Re: str = 'kpc', unit_Ie: str = 'erg/(cm^2.s.A)', unit_M_L: str = 'solMass.s.A.cm^2/(erg.kpc^2)', **kwargs) None[source]

Note

You can either provide:

  • n, Re and Ie

  • n, Re, mag and offset

Parameters
  • n (int or flat) – Sersic index

  • Re (int or float) – half-light radius

  • Ie (float) – (Optional) intensity at half-light radius

  • mag (float) – (Optional) galaxy total integrated magnitude used to compute Ie if not given

  • offset (float) – (Optional) magnitude offset in the magnitude system used

  • unit_Ie (str) – (Optional) unit for the surface brightness. If Ie already has a unit, it is converted to this unit.

  • unit_Re (str) – (Optional) unit for the scale radius Re. If Re already has a unit, it is converted to this unit.

Raises
  • TypeError – if n or Re are neither int, float, np.float16, np.float32 or np.float64

  • ValueError – if Ie and mag and offset are None, if n <= 0, if Re <= 0 or if Ie <= 0

velocity(r: Union[int, float, Type[astropy.units.quantity.Quantity]], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Velocity profile for a self-sustaining 3D inifinitely thin disk against its own gravity through centripedal acceleration

\[V(r) = V_{\rm{max}} \frac{r}{0.8798243 \times R_{\rm{d}}} \sqrt{I_0(y) K_0(y) - I_1 (y) K_1 (y)}\]

where \(I_i, K_i\) are the modified Bessel functions of the first and second kind, respectively, of order i, and \(y = r/(2 R_{\rm{d}})\).

Parameters

r (int, float, astropy Quantity or ndarray[float]) – radius where the velocity profile is computed

Returns

velocity profile at a radius r in \(\rm{km/s}\)

Return type

Astropy Quantity

Raises

TypeError – if r is neither int, float, np.float16, np.float32, np.foat64 or ndarray

class galaxy.massModels.Hernquist(a: Union[int, float], F: Union[int, float], M_L: Union[int, float], unit_a: str = 'kpc', unit_F: str = 'erg/(s.A)', unit_M_L: str = 'solMass.s.A.cm^2/(erg.kpc^2)', **kwargs)[source]

Bases: galaxy.massModels.MassModelBase

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

3D Hernquist model class.

property Ftot: Type[astropy.units.quantity.Quantity]

Total flux of the profile.

__init__(a: Union[int, float], F: Union[int, float], M_L: Union[int, float], unit_a: str = 'kpc', unit_F: str = 'erg/(s.A)', unit_M_L: str = 'solMass.s.A.cm^2/(erg.kpc^2)', **kwargs) None[source]
Parameters
  • a (int or float) – scale factor

  • F (int or float) – amplitude parameter (total flux)

  • M_L (int or float) – mass to light ratio

  • unit_a (str) – unit of the scale parameter a

  • unit_F (str) – unit of the amplitude parameter M

  • unit_M_L (str) – unit used to convert from light to mass profiles

Raises

TypeError – if a or F are neither int, float, np.foat16, np.float32 or np.float64

_alpha_F

Offset parameter to make the conversion Ie (Sersic) <-> F (Hernquist) (see Mercier et al., 2021)

_alpha_a

Offset parameter to make the conversion Re (Sersic) <-> a (Hernquist) (see Mercier et al., 2021)

_beta_F

Slope parameter to make the conversion Ie (Sersic) <-> F (Hernquist) (see Mercier et al., 2021)

_beta_a

Slope parameter to make the conversion Re (Sersic) <-> a (Hernquist) (see Mercier et al., 2021)

flux(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the enclosed flux at radius r.

Parameters

r (int or float) – radius where to compute the luminosity

Returns

flux enclosed in a sphere of radius r

Return type

astropy.units Quantity

gfield(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the gravitational field of a single Hernquist profile at radius r.

Parameters

r (int or float) – radius where the gravitational field is computed

Returns

g(r)

Return type

astropy.units Quantity

profile(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the light density profile at radius r.

Parameters

r (int or float) – radius where to compute the profile

Returns

light profile at radius r

Return type

astropy.units Quantity

property toSersic

Create the best fit Sersic instance from this Hernquist instance.

Returns

Best-fit Sersic instance (see Mercier et al., 2021)

Return type

Sersic

property todeVaucouleur: Type[astropy.units.quantity.Quantity]

Alias of toSersic.

velocity(r: Union[int, float, Type[astropy.units.quantity.Quantity]], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Velocity profile for a self-sustaining Hernquist 3D profile against its own gravity through centripedal acceleration.

\[V(r) = \sqrt{\frac{G M(<r)}{r}},\]

where \(G\) is the gravitational constant and \(M(<r)\) is the enclosed mass.

Parameters

r (int, float, astropy Quantity or ndarray[float]) – radius where the velocity profile is computed

Returns

velocity profile at a radius r in \(\rm{km/s}\)

Return type

Astropy Quantity

Raises

TypeError – if r is neither int, float, np.float16, np.float32, np.foat64 or ndarray

class galaxy.massModels.MassModelBase(dim: int, M_L: float, unit_M_L: str = 'solMass.s.cm^2.A/erg)', **kwargs)[source]

Bases: object

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

Base class for mass models.

Warning

When using a method, make sure the unit of the radial distance is identical to that of the scale parameter of the model.

Note

Units must be given such that they are recognised by astropy.units module.

Parameters
  • dim (int) – number of dimensions of the model

  • M_L (float) – mass to light ratio

  • unit_M_L (str) – unit of the mass to light ratio. Refer to the specific mass model to know which unit to provide.

Raises

ValueError – if

  • dim is not an integer

  • dim < 1

  • M_L <= 0

  • M_L is neither an int or float or np.float16 or np.float32 or np.float64

property Ftot: None

Total flux of the profile.

Raises

NotImplementedError – This property needs be implemented in a subclass first in order to be used

property Mtot: None

Total mass of the profile.

Raises

NotImplementedError – This property needs be implemented in a subclass first in order to be used

__add__(other)[source]

Add this instance with any other object. Only adding 3D models is allowed.

__init__(dim: int, M_L: float, unit_M_L: str = 'solMass.s.cm^2.A/erg)', **kwargs) None[source]
_checkR(r: Union[int, float], against: Type[astropy.units.quantity.Quantity]) Type[astropy.units.quantity.Quantity][source]

Check whether radial distance is positive and has a unit.

Parameters
  • r (int or float or astropy.units Quantity) – radial distance

  • against (astropy.unit Quantity) – parameter to retrieve the unit from

Returns

the radial distance

Return type

astropy.units Quantity

Raises

ValueError – if r < 0

flux(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the enclosed flux at radius r

\[F(<r) = 4\pi \int_0^r dx~x^2 \rho (<x),\]

with \(\rho(r)\) the light density profile.

Parameters

r (int or float) – radius where to compute the luminosity

Returns

flux enclosed in a sphere of radius r

Return type

astropy.units Quantity

Raises

NotImplementedError – This method needs be implemented in a subclass first in order to be used

gfield(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the gravitational field at radius r.

Parameters

r (int or float) – radius where the gravitational field is computed

Returns

g(r)

Return type

astropy.units Quantity

Raises

NotImplementedError – This method needs be implemented in a subclass first in order to be used

mass(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the enclosed (integrated) mass at radius r.

Parameters

r (int or float) – radius where to compute the mass

Returns

mass enclosed in a sphere of radius r

Return type

astropy.units Quantity

Raises

NotImplementedError – This method needs be implemented in a subclass first in order to be used

mass_profile(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the mass density profile at radius r.

Parameters

r (int or float) – radius where to compute the profile

Returns

mass density profile at radius r

Return type

astropy.units Quantity

profile(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the light density profile at radius r.

Parameters

r (int or float) – radius where to compute the profile

Returns

light profile at radius r

Return type

astropy.units Quantity

Raises

NotImplementedError – This method needs be implemented in a subclass first in order to be used

velocity(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Velocity profile for a self-sustaining 3D profile against its own gravity through centripedal acceleration

\[V(r) = \sqrt{\frac{G M(<r)}{r}},\]

where \(G\) is the gravitational constant and \(M(<r)\) is the enclosed mass.

Parameters

r (int or float) – radius where the velocity profile is computed

Returns

V(r)

Return type

astropy.units Quantity

class galaxy.massModels.Multiple3DModels(model1, model2, *args, **kwargs)[source]

Bases: galaxy.massModels.MassModelBase

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

A master class used when combining two 3D models into a single object.

property Ftot: Type[astropy.units.quantity.Quantity]

Total flux of the profiles.

property Mtot: Type[astropy.units.quantity.Quantity]

Total mass of the profiles.

__init__(model1, model2, *args, **kwargs)[source]
Parameters
Raises
  • AttributeError – if model1 or model2 does not have a _dim attribute

  • ValueError – if model1 or model2 do not have _dim = 3

flux(args: List[List] = [[]], kwargs: List[Dict] = [{}]) Type[astropy.units.quantity.Quantity][source]

Compute the enclosed flux at radius r.

Note

Because models can require different arguments (for instance 3D radial distance r for one and 2D R in disk plane for the other), these are separated in lists. Each element will be passed to the corresponding model. The order is the same as in models list variable.

Parameters
  • args (list[list]) – (Optional) arguments to pass to each model. Order is that of models list.

  • kwargs (list[list]) – (Optional) kwargs to pass to each model. Order is that of models list.

Returns

sum of the flux for each model

gfield(args: List[List] = [[]], kwargs: List[Dict] = [{}]) Type[astropy.units.quantity.Quantity][source]

Compute the full gravitational field at radius r.

Note

Because models can require different arguments (for instance 3D radial distance r for one and 2D R in disk plane for the other), these are separated in lists. Each element will be passed to the corresponding model. The order is the same as in models list variable.

Parameters
  • args (list[list]) – (Optional) arguments to pass to each model. Order is that of models list.

  • kwargs (list[list]) – (Optional) kwargs to pass to each model. Order is that of models list.

Returns

sum of the gravitational fields for each model

mass(args: List[List] = [[]], kwargs: List[Dict] = [{}]) Type[astropy.units.quantity.Quantity][source]

Compute the enclosed mass at radius r.

Note

Because models can require different arguments (for instance 3D radial distance r for one and 2D R in disk plane for the other), these are separated in lists. Each element will be passed to the corresponding model. The order is the same as in models list variable.

Parameters
  • args (list[list]) – (Optional) arguments to pass to each model. Order is that of models list.

  • kwargs (list[list]) – (Optional) kwargs to pass to each model. Order is that of models list.

Returns

sum of the mass for each model

mass_profile(args: List[List] = [[]], kwargs: List[Dict] = [{}]) Type[astropy.units.quantity.Quantity][source]

Compute the mass profile at radius r.

Note

Because models can require different arguments (for instance 3D radial distance r for one and 2D R in disk plane for the other), these are separated in lists. Each element will be passed to the corresponding model. The order is the same as in models list variable.

Parameters
  • args (list[list]) – (Optional) arguments to pass to each model. Order is that of models list.

  • kwargs (list[list]) – (Optional) kwargs to pass to each model. Order is that of models list.

Returns

sum of the mass density profile for each model

profile(args: List[List] = [[]], kwargs: List[Dict] = [{}]) Type[astropy.units.quantity.Quantity][source]

Compute the light profile at radius r.

Note

Because models can require different arguments (for instance 3D radial distance r for one and 2D R in disk plane for the other), these are separated in lists. Each element will be passed to the corresponding model. The order is the same as in models list variable.

Parameters
  • args (list[list]) – (Optional) arguments to pass to each model. Order is that of models list.

  • kwargs (list[list]) – (Optional) kwargs to pass to each model. Order is that of models list.

Returns

sum of the light profile for each model

velocity(args: List[List] = [[]], kwargs: List[Dict] = [{}]) Type[astropy.units.quantity.Quantity][source]

Velocity profile for the 3D models against their own gravity through centripedal acceleration.

Note

Because models can require different arguments (for instance 3D radial distance r for one and 2D R in disk plane for the other), these are separated in lists. Each element will be passed to the corresponding model. The order is the same as in models list variable.

Parameters
  • args (list[list]) – (Optional) arguments to pass to each model. Order is that of models list.

  • kwargs (list[list]) – (Optional) kwargs to pass to each model. Order is that of models list.

Returns

sum of the velocity profile for each model

class galaxy.massModels.NFW(Rs: Union[int, float, Type[astropy.units.quantity.Quantity]], c: Optional[Union[int, float]] = None, Vmax: Optional[Union[int, float, Type[astropy.units.quantity.Quantity]]] = None, unit_Rs: str = 'kpc', unit_Vmax: str = 'km/s')[source]

Bases: galaxy.massModels.MassModelBase

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

Navarro Frenk and White profile.

property Ftot: float

Total flux (infinite).

property Mvir: Type[astropy.units.quantity.Quantity]

Virial mass.

property Rvir: Type[astropy.units.quantity.Quantity]

Virial radius.

Raises

ValueError – if c is None

__init__(Rs: Union[int, float, Type[astropy.units.quantity.Quantity]], c: Optional[Union[int, float]] = None, Vmax: Optional[Union[int, float, Type[astropy.units.quantity.Quantity]]] = None, unit_Rs: str = 'kpc', unit_Vmax: str = 'km/s') None[source]

Note

Two pairs of parameters can be passed:

  • Rs and c

  • Rs and Vmax

Parameters
  • Rs (int or float or astropy.units Quantity with distance unit) – scale parameter

  • c (int or float) – (Optional) concentration parameter. If None, Vmax must be given.

  • Vmax (int or float or astropy.units Quantity with velocity unit) – (Optional) maximum circular velocity at 2.15*Rs. If None, c must be given. If not given as an astropy Quantity, provide the correct unit with unit_Vmax.

  • unit_Rs (str) – (Optional) unit of Rs

  • unit_Vmax (str) – (Optional) unit of Vmax

Raises
  • ValueError – if both Vmax and c are None or if both are not None

  • TypeError – if c is not dimensionless

  • astropy.units.core.UnitConversionError – if Vmax could not be broadcast to km/s unit

flux(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the enclosed flux at radius r.

Note

The flux returned is 0 since this is a DM profile.

Parameters

r (int or float) – radius where to compute the luminosity

Returns

flux enclosed in a sphere of radius r

Return type

astropy.units Quantity

gfield(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the gravitational field of a single NFW profile at radius r.

Parameters

r (int or float) – radius where the gravitational field is computed

Returns

g(r)

Return type

astropy.units Quantity

Raises

NotImplementedError – This method needs be implemented

mass(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the enclosed (integrated) mass at radius r.

Parameters

r (int or float) – radius where to compute the mass

Returns

mass enclosed in a sphere of radius r

Return type

astropy.units Quantity

mass_profile(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the mass density profile at radius r.

Parameters

r (int or float) – radius where to compute the profile

Returns

mass density profile at radius r

Return type

astropy.units Quantity

profile(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Compute the light density profile at radius r.

Note

The light density profile returned is 0 since this is a DM profile.

Parameters

r (int or float) – radius where to compute the profile

Returns

light profile at radius r

Return type

astropy.units Quantity

velocity(r: Union[int, float, Type[astropy.units.quantity.Quantity]], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Velocity profile for a self-sustaining 3D profile against its own gravity through centripedal acceleration

\[V(r) = \sqrt{\frac{G M(<r)}{r}},\]

where \(G\) is the gravitational constant and \(M(<r)\) is the enclosed mass.

Parameters

r (int, float, astropy Quantity or ndarray[float]) – radius where the velocity profile is computed

Returns

velocity profile at a radius r in \(\rm{km/s}\)

Return type

Astropy Quantity

Raises

TypeError – if r is neither int, float, np.float16, np.float32, np.foat64 or ndarray

class galaxy.massModels.Sersic(n: Union[int, float], Re: Union[int, float], Ie: Optional[float] = None, mag: Optional[float] = None, offset: Optional[float] = None, unit_Re: str = 'kpc', unit_Ie: str = 'erg/(cm^2.s.A)', **kwargs)[source]

Bases: object

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

2D Sersic profile class.

Warning

When using a method, make sure the unit of the radial distance is identical to that of the scale parameter of the model.

property Ftot: Type[astropy.units.quantity.Quantity]

Total flux of the profile.

I0

Central intensity

Ie

Surface brightness at Re

Re

Effective (half-light) radius

__init__(n: Union[int, float], Re: Union[int, float], Ie: Optional[float] = None, mag: Optional[float] = None, offset: Optional[float] = None, unit_Re: str = 'kpc', unit_Ie: str = 'erg/(cm^2.s.A)', **kwargs) None[source]

Note

You can either provide:

  • n, Re and Ie

  • n, Re, mag and offset

Parameters
  • n (int or flat) – Sersic index

  • Re (int or float) – half-light radius

  • Ie (float) – (Optional) intensity at half-light radius

  • mag (float) – (Optional) galaxy total integrated magnitude used to compute Ie if not given

  • offset (float) – (Optional) magnitude offset in the magnitude system used

  • unit_Ie (str) – (Optional) unit for the surface brightness. If Ie already has a unit, it is converted to this unit.

  • unit_Re (str) – (Optional) unit for the scale radius Re. If Re already has a unit, it is converted to this unit.

Raises
  • TypeError – if n or Re are neither int, float, np.float16, np.float32 or np.float64

  • ValueError – if Ie and mag and offset are None, if n <= 0, if Re <= 0 or if Ie <= 0

_checkR(r: Union[int, float, Type[astropy.units.quantity.Quantity]], against: Type[astropy.units.quantity.Quantity]) Type[astropy.units.quantity.Quantity][source]

Check whether radial distance is positive and has a unit.

Parameters
  • r (int or float or astropy.units Quantity) – radial distance

  • against (astropy.unit Quantity) – parameter to retrieve the unit from

Returns

the radial distance

Return type

astropy.units Quantity

Raises

ValueError – if r < 0

bn

Sersic \(b_n\) factor defined as \(2\gamma(2n, b_n) = \Gamma(2n)\)

flux(r: Union[int, float], *args, **kwargs) Type[astropy.units.quantity.Quantity][source]

Flux at radius r (encompassed within a disk since this is a 2D profile).

Parameters

r (int or float) – radius where the profile is computed

Returns

flux computed within a disk of radius r

Return type

float

n

Sersic index

profile(r: Union[int, float], *args, **kwargs) float[source]

Sersic surface brightness profile at radius r.

Parameters

r (int or float) – radius where the profile is computed

Returns

Sersic profile computed at the radius r

Return type

float

class galaxy.massModels.deVaucouleur(Re: Union[int, float], Ie: Optional[float] = None, mag: Optional[float] = None, offset: Optional[float] = None, unit_Re: str = 'kpc', unit_Ie: str = 'erg/(cm^2.s.A)', **kwargs)[source]

Bases: galaxy.massModels.Sersic

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

2D de Vaucouleur profile.

__init__(Re: Union[int, float], Ie: Optional[float] = None, mag: Optional[float] = None, offset: Optional[float] = None, unit_Re: str = 'kpc', unit_Ie: str = 'erg/(cm^2.s.A)', **kwargs) None[source]

Note

You can either provide:

  • Re and Ie

  • Re, mag and offset

Parameters
  • Re (int or float) – half-light radius

  • Ie (float) – (Optional) intensity at half-light radius

  • mag (float) – (Optional) galaxy total integrated magnitude used to compute Ie if not given

  • offset (float) – (Optional) magnitude offset in the magnitude system used

  • unit_Ie (str) – (Optional) unit for the surface brightness. If Ie already has a unit, it is converted to this unit.

  • unit_Re (str) – (Optional) unit for the scale radius Re. If Re already has a unit, it is converted to this unit.

_alpha_F

Offset parameter to make the conversion Ie (Sersic) <-> F (Hernquist) (see Mercier et al., 2021)

_alpha_a

Offset parameter to make the conversion Re (Sersic) <-> a (Hernquist) (see Mercier et al., 2021)

_beta_F

Slope parameter to make the conversion Ie (Sersic) <-> F (Hernquist) (see Mercier et al., 2021)

_beta_a

Slope parameter to make the conversion Re (Sersic) <-> a (Hernquist) (see Mercier et al., 2021)

toHernquist(M_L: Union[int, float], unit_M_L: str = 'solMass.s.A.cm^2/(erg.kpc^2)', **kwargs) Type[galaxy.massModels.Hernquist][source]

Create the best-fit Hernquist instance from this de Vaucouleur instance (see Mercier et al., 2021).

Parameters
  • M_L (int or float) – mass to light ratio

  • unit_M_L (str) – unit of the mass to light ratio. If M_L already has a unit, it is converted to this unit.

Returns

best-fit Hernquist instance (see Mercier et al., 2021)

Return type

Hernquist

Raises

TypeError – if M_L is neither an int, float, float16, float32, float64 or astropy.units Quantity