Skip to content

Commit c0e86b9

Browse files
Merge pull request #212 from halomod/docs-for-extrapolate-eh
docs: add FAQ about high-k camb transfer
2 parents 2086395 + 10d4046 commit c0e86b9

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

CHANGELOG.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Releases
44
dev-version
55
----------------------
66

7+
**Changes**
8+
9+
* Changed the ``CAMB`` transfer model to use ``extrapolate_with_eh=True`` by default,
10+
which improves the accuracy of the HMF at low mass.
11+
712
**Fixes**
813

914
* The Behroozi mass function model has been corrected to modify the Tinker08 mass
@@ -18,7 +23,6 @@ v3.4.3 [12 Sep 2022]
1823
----------------------
1924

2025
**Changes**
21-
-----------
2226

2327
- No longer supporting <py38
2428
- Fixes to setup.cfg (#150)

docs/faq.rst

+24
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,27 @@ can specify more accurately what kind of model you want::
4444

4545
Here the kind is the *name* of the class defining this component (see above section
4646
for how to determine what kinds are available).
47+
48+
My mass function looks wrong at small masses, why?
49+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50+
One common reason for this is that the mass function is being calculated at masses
51+
that correspond to scales at higher *k* than the transfer function was calculated at.
52+
You can set your *kmax* to be higher to fix this.
53+
54+
However, note that setting a higher *kmax* for the CAMB transfer function will not
55+
automatically fix this, since the underlying CAMB code only calculates the transfer
56+
function up to an internally-specific *kmax*, and this is extrapolated by HMF.
57+
This can be easily fixed by setting the CAMB-specific parameter
58+
``transfer_params = {"kmax": some_high_number}``. However, note that this will slow down
59+
the calculation of the transfer function quite significantly.
60+
61+
A cheaper way to fix the problem is to leave the default *kmax* for CAMB, and instead
62+
use ``extrapolate_with_eh=True``, which will use Eisenstein & Hu's fitting formula to
63+
extrapolate the transfer function to higher *k* values. This is not as accurate as
64+
calculating the transfer function with CAMB out to higher *k* values, but is much faster.
65+
66+
.. note:: From v3.5.0, the default behaviour is to extrapolate with Eisenstein & Hu
67+
fitting formula. This is because the default *kmax* for CAMB is too low for
68+
the default *kmax* for the mass function, and this was causing problems for
69+
users. If you want to use the old behaviour, you can set
70+
``extrapolate_with_eh=False``.

setup.cfg

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ tests =
7070
pre-commit
7171
mpmath>=1.0.0
7272
colossus>=1.2.1
73-
halomod
73+
halomod>=1.4.6
7474
numba
7575
dev =
7676
hmf[docs,tests]
77+
setuptools_scm
7778
cosmo =
7879
colossus>=1.2.1
7980
fit =

src/hmf/density_field/transfer_models.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class CAMB(FromFile):
164164
_defaults = {
165165
"camb_params": None,
166166
"dark_energy_params": {},
167-
"extrapolate_with_eh": False,
167+
"extrapolate_with_eh": None,
168168
"kmax": None,
169169
}
170170

@@ -229,6 +229,14 @@ def __init__(self, *args, **kwargs):
229229
w=self.cosmo.w0, wa=self.cosmo.wa
230230
)
231231

232+
if self.params["extrapolate_with_eh"] is None:
233+
warnings.warn(
234+
"'extrapolate_with_eh' was not set. Defaulting to True, which is "
235+
"different behaviour than versions <=3.4.4. This warning may be "
236+
"removed in v4.0. Silence it by setting extrapolate_with_eh explicitly."
237+
)
238+
self.params["extrapolate_with_eh"] = True
239+
232240
if self.params["extrapolate_with_eh"]:
233241
# Create an EH transfer to extrapolate to at high k.
234242
self._eh = EH(self.cosmo)

0 commit comments

Comments
 (0)