SmoothK¶
- class hmf.density_field.filters.SmoothK(k, power, **model_parameters)[source]¶
Smooth-k window function of Leo et al. (2018).
This class is based on
Filter, which can be consulted for details of how to instantiate it.- Parameters:
k (array_like) – Wavenumbers at which the power spectrum is defined.
power (array_like) – The power spectrum at k.
**model_parameters (unpacked-dict) – Model parameters
beta(\(\hat{\beta}\), the steepness of the cut-off, must be positive) andc(\(\hat{c}\), the mass-assignment constant). Defaults are the best-fit values of Leo et al. (2018), section 5:beta=4.8andc=3.3.
Notes
This filter was introduced by [1] (their eq. 4.1) as a smooth interpolation between the real-space top-hat and the sharp-k filter, for use with models whose linear power spectrum is truncated at small scales (e.g. warm dark matter). The fourier-space filter is
\[W(x=kR) = \frac{1}{1 + x^{\hat{\beta}}},\]with \(\hat{\beta} > 0\). As \(\hat{\beta}\rightarrow\infty\) it tends to the sharp-k filter (
SharpK). The mass-assignment has the same form as forSharpK:\[m(R) = \frac{4\pi}{3}[\hat{c}R]^3\bar{\rho}.\]The derivative of the window function is
\[\frac{dW}{d\ln x} = -\hat{\beta}\frac{x^{\hat{\beta}}} {(1+x^{\hat{\beta}})^2} = -\hat{\beta}W(1-W).\]There is no closed form for the real-space filter, so
real_space()evaluates the inverse Fourier transform numerically withscipy.integrate.quad()(it converges for \(\hat{\beta} > 1\)).Leo et al. (2018) pair this filter with the Sheth-Tormen mass function using \(q=1\) rather than the usual \(q=0.707\). That value is not set automatically: pass
hmf_params={"q": 1.0}(withhmf_model="ST") toMassFunctionto reproduce their setup.References
[1]Leo M., Baugh C. M., Li B., Pascoli S., 2018, JCAP, 04, 010, arXiv:1801.02547.
Attributes
References to cite when this model is used, each a formatted citation string.
Methods
- dlnr_dlnm(r)¶
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)¶
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)¶
Compute the derivative of the mass variance with radius.
- Parameters:
r (array_like) – Radii
- Returns:
dlnss_dlnr – The derivative of 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() Mapping[str, type]¶
Get a read-only mapping of all implemented models for this component.
The mapping is a live view of the registry, so it shows models registered later, but it can not be used to add or remove models.
- 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)¶
Deprecated: the squared peak height, \(\frac{\delta_c^2}{\sigma^2(r)}\).
Deprecated since version 3.7:
nuis \(\nu^2\), not the peak height \(\nu\). It will be removed in v4. Usenu2()instead.- Parameters:
r (array_like) – Radii
delta_c (float, optional) – Critical overdensity for collapse.
- nu2(r: ndarray, delta_c: float = 1.68647) ndarray¶
Squared peak height, \(\nu^2 = \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, computed numerically.
- Parameters:
R (float) – The smoothing scale.
r (array_like) – The radial co-ordinate. Must be positive.
- Returns:
f – The real-space filter at r.
- Return type:
array_like
Notes
Evaluates
\[F(r) = \frac{1}{2\pi^2 R^3 y}\int_0^\infty \frac{x\sin(xy)}{1+x^{\hat{\beta}}} dx,\qquad y = r/R,\]with a Fourier-weighted
scipy.integrate.quad(). This requires \(\hat{\beta} > 1\).
- sigma(r, order=0, rk=None)¶
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)\]
- sigma_and_dlnss_dlnm(r)¶
Compute
sigma()anddlnss_dlnm()together.The result is identical to calling the two methods separately, but shares work between them where possible (see
sigma_and_dlnss_dlnr()).- Parameters:
r (array_like) – Radii.
- Returns:
sigma (array_like) – The mass variance, \(\sigma(r)\) (see
sigma()).dlnss_dlnm (array_like) – The log-derivative of the mass variance with mass.
- sigma_and_dlnss_dlnr(r)¶
Compute
sigma()anddlnss_dlnr()together.The result is identical to calling the two methods separately, but the window function and its derivative are evaluated only once on the \((R, k)\) grid (when neither method is overridden by a subclass).
- Parameters:
r (array_like) – Radii.
- Returns:
sigma (array_like) – The mass variance, \(\sigma(r)\) (see
sigma()).dlnss_dlnr (array_like) – The log-derivative of the mass variance with radius.