Bhattacharya

class hmf.core.fits.Bhattacharya(*, A_a=0.333, A_b=0.11, a_a=0.788, a_b=0.01, p=0.807, q=1.795, normed: bool = False)[source]

The Bhattacharya et al. (2011) mass function.

\[f(\sigma) = f_{\rm ST}(\sigma; A, a, p)\,(\sqrt{a}\,\nu)^{q-1},\]

with \(A = A_a(1+z)^{-A_b}\) and \(a = a_a(1+z)^{-a_b}\). With normed=True, A is instead the value that normalises the fit to unit mass (which needs \(q > 0\) and \(2p < q\)). For q = 1 it is Sheth-Tormen.

Parameters:
  • A_a (float, default 0.333) – A(z) = A_a (1+z)^-A_b (unless normed).

  • A_b (float, default 0.11) – A(z) = A_a (1+z)^-A_b (unless normed).

  • a_a (float, default 0.788) – a(z) = a_a (1+z)^-a_b.

  • a_b (float, default 0.01) – a(z) = a_a (1+z)^-a_b.

  • p (float, default 0.807) – The low-mass slope parameter p.

  • q (float, default 1.795) – The exponent q (q = 1 gives Sheth-Tormen).

  • normed (bool, default False) – Whether to normalise A so that all mass is in haloes.

Model metadata

alias: ClassVar[str | None] = 'Bhattacharya'

The short name the model is registered under, if any. Set by the alias class keyword; never inherited.

calibration

Where this model was calibrated, with its source (None if it was not).

The class’s calibration_domain, unless it depends on the instance’s parameters.

calibration_domain: ClassVar[Domain | None] = Domain(bounds=(('m', Interval(lower=430000000000.0, upper=2200000000000000.0, unit=Unit("solMass / littleh"), lower_open=False, upper_open=False)), ('z', Interval(lower=0.0, upper=2.0, unit=None, lower_open=False, upper_open=False))), source='Bhattacharya et al. 2011: 6e11-3e15 Msun (Table 4 title; abstract), i.e. 4.3e11-2.2e15 Msun/h for their h = 0.72, and z = 0-2 (Table 4 title); redshift evolution better than 3% for 0.6 <= 1/sigma <= 2.4 (Sec. 4.2). Omega_m = 0.25, sigma_8 = 0.8 (Table 1).')

Where the fit was calibrated against simulations, with its source; None for a fit that was not calibrated (e.g. an analytic one). Ask an instance for calibration.

measured_mass_definition: ClassVar[MassDefinition] = FOF(linking_length=0.2)

The halo mass definition the fit was measured in (see “Mass definitions” in the module documentation).

measured_mass_definition_note: ClassVar[str] = 'Bhattacharya et al. 2011, Sec. 3, with FoF and finite-volume corrections.'

Where measured_mass_definition comes from in the paper, and anything else worth knowing about it (halo finder, unbinding, …).

modifies_dndm: ClassVar[bool] = False

Whether modify_dndm_kernel() changes the mass function (see “Post-processing the mass function” in the module documentation); if False, it is the identity.

normalized

Whether A normalises the fit (normed).

parameter_source: ClassVar[str] = 'Bhattacharya et al. 2011 (arXiv v6), eq. 12 and Table 4.'

The exact source (paper, version, table or equation) of the parameter defaults, e.g. “Tinker et al. 2008, ApJ 688, 709 (published), Table 2”.

references: ClassVar[tuple[str, ...]] = ('Bhattacharya, S., et al., 2011. ApJ 732, 122. https://doi.org/10.1088/0004-637X/732/2/122',)

References to cite when the model is used, each a formatted citation.

requires: ClassVar[frozenset[str]] = frozenset({'delta_c', 'z'})

The inputs (from INPUTS) that fsigma() needs, besides sigma.

simulations: ClassVar[SimulationDetails | None] = SimulationDetails(box_size=<Quantity [ 720.  , 1249.92, 2000.16,  128.16,  936.  ] Mpc / littleh>, n_particles=(3375000000, 1728000000, 1073741824, 134217728, 1073741824), omega_m=(0.25, 0.25, 0.25, 0.25, 0.25), omega_b=(0.0432, 0.0432, 0.0432, 0.0432, 0.0432), sigma_8=(0.8, 0.8, 0.8, 0.8, 0.8), h=(0.72, 0.72, 0.72, 0.72, 0.72), n_s=(0.97, 0.97, 0.97, 0.97, 0.97), softening=<Quantity [0.01728, 0.03672, 0.06984, 0.01008, 0.036  ] Mpc / littleh>, transfer=('CAMB', 'CAMB', 'CAMB', 'CAMB', 'CAMB'), z_start=(75, 100, 100, 211, 211), initial_conditions=('2LPT', '2LPT', '2LPT', 'ZA', 'ZA'), halo_finder=None, n_min=400, z_range=(0.0, 2.0), names=None, notes='Model 0 (omega_m = 0.1296, omega_b = 0.0224, h = 0.72; Table 1). Box sizes and softenings are given in Mpc and kpc (converted here). Force-resolution, FoF and finite-volume corrections are applied.', source='Bhattacharya et al. 2011 (arXiv v6), Secs. 2-3, Tables 1-2.')

The simulations the fit was calibrated on (None for a fit to no simulations).

valid_domain: ClassVar[Domain] = Domain(bounds=(('delta_c', Interval(lower=0.0, upper=inf, unit=None, lower_open=True, upper_open=True)), ('sigma', Interval(lower=0.0, upper=inf, unit=None, lower_open=True, upper_open=True)), ('z', Interval(lower=0.0, upper=inf, unit=None, lower_open=False, upper_open=True))), source='sigma > 0, z >= 0 and delta_c > 0.')

fsigma() raises outside it.

Type:

Where the formula is defined or sensible

Methods

check_required(x: FitInputs) → None

Raise if an input needed to evaluate the fit is missing from x.

Parameters:

x – The inputs.

Raises:

ValueError – If an input in requires (or needed to check valid_domain) is missing.

check_valid(x: FitInputs) → None

Raise if any input is outside valid_domain.

Parameters:

x – The inputs.

Raises:

DomainError – Always, if any value is outside the valid domain: this does not depend on any policy.

classmethod coerce(value: object) → Self

Convert a value to a model of this kind: the converter of a model field.

Parameters:

value – An instance of cls, which is returned as it is; or a name, import path or class that get() accepts, which is looked up and instantiated with its default parameters.

Returns:

An instance of cls.

Return type:

Model

Raises:
  • ModelNotFoundError – If value is a name that no model of this kind is known by.

  • TypeError – If value is of any other type, or names a class that is not a concrete subclass of cls.

Examples

>>> from hmf.core.filters import Filter, TopHat
>>> Filter.coerce("TopHat") == TopHat()
True
classmethod domain_inputs() → frozenset[str]

The inputs (besides sigma) needed to evaluate the fit and check both domains.

classmethod fields_info() → tuple[FieldInfo, ...]

Describe this class’s fields, without creating an instance.

Returns:

The name, type, default and documentation of each field.

Return type:

tuple of FieldInfo

fsigma(sigma: ArrayLike, *, z: ArrayLike | None = None, omega_m_z: ArrayLike | None = None, delta_halo: ArrayLike | None = None, delta_c: ArrayLike | None = None, n_eff: ArrayLike | None = None, m: ArrayLike | None = None) → ndarray[tuple[Any, ...], dtype[float64]]

The multiplicity function, \(f(\sigma) = \nu f(\nu)\).

m must be a Quantity (see hmf.core.units); every other input is dimensionless. Code that already has plain arrays in canonical units calls fsigma_kernel() or evaluate_fsigma() instead (see “Evaluating a fit” in the module documentation). It applies no calibration policy (see evaluate_fsigma() for that), but always checks valid_domain.

Parameters:
  • sigma – \(\sigma(m, z)\).

  • z – Redshift.

  • omega_m_z – \(\Omega_m(z)\).

  • delta_halo – The halo overdensity relative to the mean density.

  • delta_c – The critical overdensity for collapse.

  • n_eff – The effective spectral index.

  • m – The halo mass, a Quantity (e.g. in Msun_h).

Returns:

\(f(\sigma)\) (dimensionless), broadcast over the inputs.

Return type:

numpy.ndarray

Raises:
  • ValueError – If an input the fit requires is not given.

  • UnitBoundaryError – If m is not a Quantity.

  • DomainError – If any input is outside valid_domain, or makes the fit’s parameters unphysical.

fsigma_kernel(x: FitInputs) → ndarray[tuple[Any, ...], dtype[float64]]

fsigma() at kernel level, from inputs that are plain arrays.

The inputs are in canonical units (the mass in Msun/h); see hmf.core._kernels. It checks the valid domain, as fsigma() does, and applies no calibration policy (see evaluate_fsigma()).

Parameters:

x – The inputs.

Return type:

numpy.ndarray

Raises:
  • ValueError – If an input the fit requires is not in x.

  • DomainError – As for fsigma().

classmethod get(name: str | type[Model]) → type[Self]

Look up a model of this kind.

Parameters:

name – An alias ("Tinker08"), a qualified name ("hmf.core.fits:Tinker08"), an import path to a class not yet imported ("pkg.mod:Cls" or "pkg.mod.Cls"), or a class.

Returns:

The model class (not an instance). It is always a subclass of cls.

Return type:

type

Raises:
  • ModelNotFoundError – If no model of this kind is known by name, even after loading the hmf.models entry points and trying name as an import path.

  • TypeError – If name resolves to something that is not a concrete subclass of cls.

classmethod get_aliases() → Mapping[str, str]

Return a read-only mapping from alias to qualified name, for this kind.

classmethod get_models() → Mapping[str, type[Self]]

Return the registered models of this kind, by qualified name.

Plugins advertised in the hmf.models entry-point group are loaded first.

Returns:

A read-only mapping from qualified name to class. Called on a kind, it is a live view of the registry. Called on a non-kind subclass, it holds only the models that subclass it.

Return type:

Mapping

in_calibration_domain_kernel(x: FitInputs) → bool | ndarray[tuple[Any, ...], dtype[bool]]

Whether each input is inside calibration, at kernel level.

It checks x against valid_domain, as fsigma_kernel() does.

Parameters:

x – The inputs, from inputs().

Returns:

A bool if every input is a scalar, else the broadcast array. True if the fit has no calibration domain (it is None).

Return type:

bool or numpy.ndarray of bool

Raises:
  • ValueError – If an input needed to check the domain was not given.

  • DomainError – If any input is outside valid_domain.

inputs(sigma: ArrayLike, *, z: ArrayLike | None = None, omega_m_z: ArrayLike | None = None, delta_halo: ArrayLike | None = None, delta_c: ArrayLike | None = None, n_eff: ArrayLike | None = None, m: ArrayLike | None = None) → FitInputs

Collect the inputs, checking that the required ones are given.

Parameters are as for fsigma() (m is a Quantity). Code that already has plain arrays in canonical units calls inputs_from_arrays() instead (see “Evaluating a fit” in the module documentation).

Parameters:
  • sigma – \(\sigma(m, z)\).

  • z – As for fsigma().

  • omega_m_z – As for fsigma().

  • delta_halo – As for fsigma().

  • delta_c – As for fsigma().

  • n_eff – As for fsigma().

  • m – The halo mass, a Quantity (e.g. in Msun_h).

Returns:

The inputs as plain arrays, in canonical units.

Return type:

FitInputs

Raises:
inputs_from_arrays(sigma: ArrayLike, *, z: ArrayLike | None = None, omega_m_z: ArrayLike | None = None, delta_halo: ArrayLike | None = None, delta_c: ArrayLike | None = None, n_eff: ArrayLike | None = None, m: ArrayLike | None = None) → FitInputs

Collect inputs that are plain arrays, checking that the required ones are given.

The one place where a FitInputs is filled in: inputs(), fsigma() and library code (e.g. a mass-function Stage) all build theirs here. It does not check the values against valid_domain: fsigma_kernel() and evaluate_fsigma() do.

Parameters:
  • sigma – \(\sigma(m, z)\) (dimensionless).

  • z – As for fsigma() (dimensionless); None if not given.

  • omega_m_z – As for fsigma() (dimensionless); None if not given.

  • delta_halo – As for fsigma() (dimensionless); None if not given.

  • delta_c – As for fsigma() (dimensionless); None if not given.

  • n_eff – As for fsigma() (dimensionless); None if not given.

  • m – The halo mass in Msun/h, a plain array; None if not given.

Returns:

The inputs as float arrays.

Return type:

FitInputs

Raises:

ValueError – If an input in requires (or needed to check valid_domain) is missing.

modify_dndm(m: Any, dndm: Any, *, z: ArrayLike, ngtm: Any, H0: Any, omega_m0: ArrayLike) → Any

Map the mass function computed from fsigma() to the fit’s.

The identity unless modifies_dndm (see “Post-processing the mass function” in the module documentation). Every fit takes the same arguments, whether it uses them or not. This method converts them and calls modify_dndm_kernel(), which a mass-function Stage calls directly.

Parameters:
  • m – Halo masses, a Quantity: in h-units, or physical units (converted with H0).

  • dndm – The mass function from fsigma(), a Quantity (number density per mass).

  • z – Redshift.

  • ngtm – The cumulative mass function n(>m) from fsigma(), a Quantity.

  • H0 – The Hubble constant, a scalar Quantity (e.g. 70 * H0_unit). It converts physical units, and gives h to fits whose formula is in physical units.

  • omega_m0 – The density parameter of CDM + baryons today.

Returns:

The fit’s mass function, in dndm_unit.

Return type:

Quantity

modify_dndm_kernel(m: ArrayLike, dndm: ArrayLike, *, z: ArrayLike, ngtm: ArrayLike, h: ArrayLike, omega_m0: ArrayLike) → ndarray[tuple[Any, ...], dtype[float64]]

modify_dndm() at kernel level, on plain arrays.

A pure kernel in canonical units (see hmf.core._kernels): the identity, unless the fit sets modifies_dndm (its class documentation describes the correction). All arguments broadcast. It checks the arguments that say where the mass function is evaluated (m, z, h, omega_m0), from their extent; dndm and ngtm are values it maps, and may be NaN (e.g. masked by a domain policy).

Parameters:
  • m – Halo masses, in Msun/h.

  • dndm – The mass function from fsigma(), in h^4 / (Msun Mpc^3).

  • z – Redshift.

  • ngtm – The cumulative mass function n(>m) from fsigma(), in h^3 / Mpc^3.

  • h – The dimensionless Hubble parameter, H0 / (100 km/s/Mpc).

  • omega_m0 – The density parameter of CDM + baryons today.

Returns:

The fit’s mass function, in h^4 / (Msun Mpc^3).

Return type:

numpy.ndarray

Raises:

DomainError – If an m, h or omega_m0 is not finite and > 0, or a z is not finite and >= 0.

classmethod qualified_name() → str

Return this class’s qualified name, package.module:Class.