BaseFilter¶
- class hmf.density_field.filters.BaseFilter(k, power, **model_parameters)[source]¶
Base class for Filter components.
Filters handle the calculation of the mass variance from the power spectrum, via a window function. Subclasses of
BaseFilterimplement specific window functions.The general design is to specify all quantities in terms of length scales, rather than equivalent masses, but conversion methods are provided.
Any explicit subclass need only specify k_space, mass_to_radius, radius_to_mass and dw_dlnkr, with dlnr_dlnm optional if the mass assignment is unconventional.
- Parameters:
k (array_like) – Wavenumbers at which the power spectrum is defined.
power (array_like) – The power spectrum at k.
**model_parameters (unpacked-dict) – As for any
hmf._framework.Componentsubclass, any particular parameters of the model may be passed to the constructor. Allowed parameters are found in the_defaultsattribute.
Notes
Besides the raw filter function itself, two quantities are of primary interest: firstly the mass variance (see
sigma()), which appears in many cosmological applications, and secondly its logarithmic derivative with mass, which appears in the Press-Schechter formalism for the halo mass function.To remain extensible and general, the methodology in this class is to calculate the latter quantity as
\[\frac{d\ln\sigma}{d\ln m} = \frac{1}{2} \frac{d \ln \sigma^2}{d\ln R} \frac{d\ln R}{d\ln m}.\]Each of the quantities on the right can be separately calculated, improving extensibility.
The factor \(\frac{d\ln R}{d\ln m}\) is typically 1/3, but this is not necessarily the case for window functions of arbitrary shape.
Methods
- __init__(k, power, **model_parameters)[source]
- dlnr_dlnm(r)[source]
Compute the derivative of log radius with log mass.
For the usual \(m\propto r^3\) mass assignment, this is just 1/3.
- Parameters:
r (array_like) – Radii.
- dlnss_dlnm(r)[source]
Compute the logarithmic slope of mass variance with mass.
This is an important quantity, and is used directly to calculate \(\frac{dn}{dm}\).
- Parameters:
r (array_like) – Radii.
- dlnss_dlnr(r)[source]
Compute the derivative of the mass variance with radius.
- Parameters:
r (array_like) – Radii
- Returns:
dlnss_dlnr – The derivative of the the mass variance with radius.
- Return type:
array_like
Notes
Given a prescription for how radius grows with mass (typically with a log-slope of 1/3, and set in
dlnr_dlnm()), this specifies the quantity \(\frac{d \ln \sigma^2}{d\ln m}\).The general formula is
\[\frac{d\ln \sigma^2}{d\ln R} = \frac{1}{\pi^2\sigma^2} \int_0^\infty W(kR) \frac{dW(kR)}{d\ln(kR)} P(k)k^2 dk\]
- dw_dlnkr(kr)[source]
Compute the derivative of the (fourier-transformed) filter with \(\ln(kr)\).
- Parameters:
kr (array_like) – Scale(s) at which the derivative is evaluated.
Notes
In terms of \(\frac{dw^2}{dm}\), which is a commonly used quantity, this has the relationship
\[w\frac{dw}{d\ln r} = \frac{2}{r}\frac{dw^2}{dm}\frac{dm}{dr}.\]
- classmethod get_models() dict[str, type]
Get a dictionary of all implemented models for this component.
- k_space(kr)[source]
Fourier-transform of the real-space filter.
- Parameters:
kr (array_like) – The scales at which to return the filter function
- Returns:
w – The filter in fourier space,
len(kr)- Return type:
array_like
- mass_to_radius(m, rho_mean)[source]
Return radius of a region of space given its mass.
- Parameters:
m (array_like) – Masses
rho_mean (float) – Mean density of the Universe.
- Returns:
r – The corresponding radii to m
- Return type:
array_like
Notes
The units of m don’t matter as long as they are consistent with rho_mean.
- nu(r, delta_c=1.68647)[source]
Peak height, \(\frac{\delta_c^2}{\sigma^2(r)}\).
- Parameters:
r (array_like) – Radii
delta_c (float, optional) – Critical overdensity for collapse.
- radius_to_mass(r, rho_mean)[source]
Return mass of a region of space given its radius.
- Parameters:
r (array_like) – Radii
rho_mean (float) – Mean density of the Universe.
- Returns:
m – The corresponding masses to r
- Return type:
float or array of floats
Notes
The units of r don’t matter as long as they are consistent with rho_mean.
- real_space(R, r)[source]
Filter definition in real space.
- Parameters:
R (float) – The smoothing scale
r (array_like) – The radial co-ordinate
- sigma(r, order=0, rk=None)[source]
Calculate the nth-moment of the smoothed density field, \(\sigma_n(r)\).
Note
This is not \(\sigma_n^2(r)\)!
- Parameters:
- Returns:
sigma – The square root of the moment at r.
- Return type:
array_like
Notes
The general definition for the nth-moment of the smoothed density field is (see Bardeen et al. 1986, Eq 4.6c)
\[\sigma^2_n(R) = \frac{1}{2\pi^2} \int_0^\infty dk\ k^{2(1+n)} P(k) W^2(kR)\]