hmf.mass_function.integrate_hmf.hmf_integral_gtm

hmf.mass_function.integrate_hmf.hmf_integral_gtm(m, dndm, mass_density=False)[source]

Cumulatively integrate dn/dm.

Parameters:
  • M (array_like) – Array of masses.

  • dndm (array_like) – Array of dn/dm (corresponding to M)

  • mass_density (bool, False) – Whether to calculate mass density (or number density).

Returns:

ngtm – Cumulative integral of dndm.

Return type:

array_like

Examples

Using a simple power-law mass function:

>>> import numpy as np
>>> m = np.logspace(10,18,500)
>>> dndm = m**-2
>>> ngtm = hmf_integral_gtm(m,dndm)
>>> np.allclose(ngtm,1/m) #1/m is the analytic integral to infinity.
True

The function always integrates to m=1e18, and extrapolates if data are not provided (here emitting a HMFExtrapolationWarning):

>>> m = np.logspace(10,12,500)
>>> dndm = m**-2
>>> ngtm = hmf_integral_gtm(m,dndm)
>>> np.allclose(ngtm,1/m) #1/m is the analytic integral to infinity.
True

Notes

m is assumed to be log-uniformly spaced. The integral above the largest mass, m[-1], up to \(10^{18}\), is only included if m[-1] is more than three grid steps below \(10^{18}\) (i.e. m[-1] < 1e18 * m[0] / m[3]); otherwise it is taken to be zero. When it is included, dndm is extrapolated from m[-1] to \(10^{18}\) as a power law, by linearly extending the last segment of \(\ln(m\,dn/dm)\) against \(\ln m\). Since a real mass function is exponentially suppressed at high mass, this power-law tail overestimates the true contribution. A HMFExtrapolationWarning is emitted when the extrapolated tail is more than 0.1% of the full integral above m[0]; supply m extending to \(\sim 10^{18}\) to avoid it. Note that the cumulative values within the last few grid points below m[-1] are always dominated by the tail, even when it is negligible for the total.