Filter¶
- class hmf.core.filters.Filter[source]¶
The kind of smoothing filters.
A filter defines:
the window \(W(x)\) of \(x = kR\) (
window()), with \(W(0) = 1\);its derivatives \(W' = dW/d\ln x\) and \(W'' = d^2W/d(\ln x)^2\) (
window_derivatives_kernel());the mass-assignment constant \(c\) (
mass_assignment), in \(m = \frac{4\pi}{3} \bar\rho\, (cR)^3\);envelopes bounding \(W^2\) and \(|W W'|\) far beyond the ends of the k grid (
tail_bounds()), for the truncation estimator ofMassVariance.
A filter whose window is a sharp cut-off sets
sharp_cutoff; its variance is then integrated up to the cut-off exactly, not through the window.Attributes
- alias: ClassVar[str | None] = None¶
The short name the model is registered under, if any. Set by the
aliasclass keyword; never inherited.
- calibration¶
Where this model was calibrated, with its source (
Noneif it was not).The class’s
calibration_domain, unless it depends on the instance’s parameters.
- mass_assignment¶
The constant \(c\) of the mass assignment \(m \propto (cR)^3\).
- parameter_source: ClassVar[str] = ''¶
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, ...]] = ()¶
References to cite when the model is used, each a formatted citation.
- 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()anddwindow_dlnx()raise aDomainErroroutside 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 thatget()accepts, which is looked up and instantiated with its default parameters.- Returns:
An instance of
cls.- Return type:
- Raises:
ModelNotFoundError – If
valueis a name that no model of this kind is known by.TypeError – If
valueis of any other type, or names a class that is not a concrete subclass ofcls.
Examples
>>> from hmf.core.filters import Filter, TopHat >>> Filter.coerce("TopHat") == TopHat() True
- dwindow_dlnx(x: ArrayLike) ndarray[tuple[Any, ...], dtype[float64]][source]¶
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 scalarx).- Return type:
numpy.float64 or ndarray
- Raises:
DomainError – If an
xis outsidevalid_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:
- Raises:
ModelNotFoundError – If no model of this kind is known by
name, even after loading thehmf.modelsentry points and tryingnameas an import path.TypeError – If
nameresolves to something that is not a concrete subclass ofcls.
- 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.modelsentry-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
- abstractmethod tail_bounds() TailBounds[source]¶
Bounds on the window beyond the ends of the k grid.
- Returns:
The bounds on \(W^2\) and \(|W W'|\) at both ends.
- Return type:
- window(x: ArrayLike) ndarray[tuple[Any, ...], dtype[float64]][source]¶
The window \(W(x)\), with \(x = kR\).
- Parameters:
x – \(kR\), dimensionless,
>= 0.- Returns:
The window, of the shape of
x(a scalar for a scalarx).- Return type:
numpy.float64 or ndarray
- Raises:
DomainError – If an
xis outsidevalid_domain(negative or NaN).
- window_derivatives_kernel(x: ArrayLike, order: int = 2) tuple[ndarray[tuple[Any, ...], dtype[float64]], ...][source]¶
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 scalarx.window()anddwindow_dlnx()are the public methods, which follow the scalar rule ofunit_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
xis outsidevalid_domain(negative or not finite).ValueError – If the filter has no pointwise derivative of that order (
SharpK, fororder > 0).