SmoothK

class hmf.core.filters.SmoothK(*, beta=4.8, c=3.3)[source]

The smooth-k filter of Leo et al. (2018), their eq. 4.1.

\[W(x) = \frac{1}{1 + x^\beta}, \qquad m = \frac{4\pi}{3} \bar\rho\, (cR)^3.\]

It interpolates between the top-hat and the sharp-k filter (the limit \(\beta \to \infty\)), for power spectra truncated at small scales. The variance of a power law \(P \propto k^n\) converges for \(n < 2\beta - 3\).

Parameters:
  • beta (float, default 4.8) – The steepness of the cut-off, beta > 0.

  • c (float, default 3.3) – The mass-assignment constant c, in m = (4 pi / 3) rho_mean (c R)^3.

Attributes

beta: float
c: float
alias: ClassVar[str | None] = 'SmoothK'

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] = None

Filters are not calibrated against simulations.

mass_assignment

the parameter c.

Type:

See Filter.mass_assignment

parameter_source: ClassVar[str] = 'Leo et al. 2018, JCAP 04, 010, Section 5 (best fit)'

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, ...]] = ('Leo, M., Baugh, C. M., Li, B., Pascoli, S., 2018. JCAP 04, 010. https://doi.org/10.1088/1475-7516/2018/04/010',)

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

sharp_cutoff: ClassVar[bool] = False

Whether the window is the sharp cut-off \(\Theta(1 - x)\).

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

\(x = kR \ge 0\). window() and dwindow_dlnx() raise a DomainError outside it.

Type:

Where the window can be evaluated

Methods

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
dwindow_dlnx(x: ArrayLike) → ndarray[tuple[Any, ...], dtype[float64]]

The derivative \(dW/d\ln x\), with \(x = kR\).

Parameters:

x – \(kR\), dimensionless, >= 0.

Returns:

The derivative, of the shape of x (a scalar for a scalar x).

Return type:

numpy.float64 or ndarray

Raises:
  • DomainError – If an x is outside valid_domain (negative or NaN).

  • ValueError – For a filter whose derivative can’t be evaluated pointwise (SharpK).

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

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

classmethod qualified_name() → str

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

tail_bounds() → TailBounds[source]

See Filter.tail_bounds().

\(W \le x^{-\beta}\), \(|W'| = \beta W(1-W) \le \beta x^{-\beta}\) and \(|W'^2 + W W''| = \beta^2 W^2 (1-W) |2 - 3W| \le 2\beta^2 W^2\) for large x; \(W \le 1\), \(|W'| \le \beta x^\beta\) and \(|W'^2 + W W''| \le 2\beta^2 x^\beta\) for small x.

Returns:

The bounds on \(W^2\) and \(|W W'|\) at both ends.

Return type:

TailBounds

window(x: ArrayLike) → ndarray[tuple[Any, ...], dtype[float64]]

The window \(W(x)\), with \(x = kR\).

Parameters:

x – \(kR\), dimensionless, >= 0.

Returns:

The window, of the shape of x (a scalar for a scalar x).

Return type:

numpy.float64 or ndarray

Raises:

DomainError – If an x is outside valid_domain (negative or NaN).

window_derivatives_kernel(x: ArrayLike, order: int = 2) → tuple[ndarray[tuple[Any, ...], dtype[float64]], ...]

The window and its logarithmic derivatives at \(x = kR\).

This is the kernel-level method, which library code (e.g. MassVariance) calls: it returns plain arrays, 0-d for a scalar x. window() and dwindow_dlnx() are the public methods, which follow the scalar rule of unit_boundary().

Parameters:
  • x – \(kR\), dimensionless, >= 0.

  • order – The highest derivative to return: 0, 1 or 2.

Returns:

\((W,)\), \((W, W')\) or \((W, W', W'')\).

Return type:

tuple of ndarray

Raises:
  • DomainError – If an x is outside valid_domain (negative or not finite).

  • ValueError – If the filter has no pointwise derivative of that order (SharpK, for order > 0).