Skip to content

Commit 9b45294

Browse files
changed repository and package name
1 parent c7c353b commit 9b45294

File tree

14 files changed

+23
-22
lines changed

14 files changed

+23
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ While the quoted accuracy of `HMcode-2020` relative to simulations is RMS ~2.5%,
2626
- Here the *cold* matter power spectrum is taken directly from `CAMB` whereas in `CAMB-HMcode` the *cold* spectrum is calculated approximately from the total matter power spectrum using approximations for the scale-dependent growth rate from [Eisenstein & Hu (1999)](https://arxiv.org/abs/astro-ph/9710252).
2727
- If I resort to the old approximation for the *cold* matter power spectrum (and therefore the cold $\sigma(R)$) then the level of agreement between the codes for nu-k-w(a)-CDM improves to: Mean error: 0.15%; Std error: 0.11%; Worst error; 1.15%.
2828

29-
Using the actual cold matter spectrum is definitely an improvement from a theoretical perspective (and for speed), so I decided to keep that at the cost of the disagreement between this code at `CAMB-HMcode` for models with very high neutrino mass. If better agreement between this code and `CAMB-HMcode` is important to you then the old approximate cold spectrum can be used by changing the `sigma_cold_approx` flag at the top of `pyhmcode.py`. Note that while ignoring the actual energy-density scaling of massive neutrinos might seem to be a (small) problem, keep in mind the comments below regarding the linear growth factor.
29+
Using the actual cold matter spectrum is definitely an improvement from a theoretical perspective (and for speed), so I decided to keep that at the cost of the disagreement between this code at `CAMB-HMcode` for models with very high neutrino mass. If better agreement between this code and `CAMB-HMcode` is important to you then the old approximate cold spectrum can be used by changing the `sigma_cold_approx` flag at the top of `hmcode.py`. Note that while ignoring the actual energy-density scaling of massive neutrinos might seem to be a (small) problem, keep in mind the comments below regarding the linear growth factor.
3030

3131
I think any residual differences between codes must therefore stem from:
3232
- The BAO de-wiggling process (different `k` grids)

comparisons/CAMB.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import numpy as np
44

55
# Project imports
6-
import pyhmcode.camb_stuff as camb_stuff
7-
import pyhmcode.utility as util
8-
from pyhmcode import hmcode as HMcode
6+
import hmcode
7+
import hmcode.camb_stuff as camb_stuff
8+
import hmcode.utility as util
99

1010
# Vary these parameters
1111
vary_Omega_k = True
@@ -70,7 +70,7 @@
7070
Pk_CAMB[iz, :] = Pk_nonlin_interp(z, k)
7171

7272
# Get the new pyHMcode spectrum
73-
Pk_HMcode = HMcode(k, zs, results, verbose=verbose)
73+
Pk_HMcode = hmcode.power(k, zs, results, verbose=verbose)
7474

7575
# Calculate maximum deviation between pyHMcode and the version in CAMB
7676
max_error = np.max(np.abs(-1.+Pk_HMcode/Pk_CAMB))

hmcode/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .hmcode import power
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
Pk_lin_extrap_kmax = 1e10 # NOTE: This interplays with the sigmaV integration in a disconcerting way
1616
sigma_cold_approx = False # Should the Eisenstein & Hu (1999) approximation be used for the cold transfer function?
1717

18-
def hmcode(k:np.array, zs:np.array, CAMB_results:camb.CAMBdata,
19-
Mmin=1e0, Mmax=1e18, nM=256, verbose=False) -> np.ndarray:
18+
def power(k:np.array, zs:np.array, CAMB_results:camb.CAMBdata,
19+
Mmin=1e0, Mmax=1e18, nM=256, verbose=False) -> np.ndarray:
2020
'''
2121
Calculates the HMcode matter-matter power spectrum
2222
Args:
2323
k: Array of comoving wavenumbers [h/Mpc]
2424
zs: Array of redshifts (ordered from high to low)
2525
CAMB_results: CAMBdata structure
26+
Mmin: Minimum mass for the halo-model calculation [Msun/h]
27+
Mmax: Maximum mass for the halo-model calculation [Msun/h]
28+
nM: Number of mass bins for the halo-model calculation
2629
Returns:
2730
Array of matter power spectra: Pk[z, k]
2831
'''
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Standard imports
22
import numpy as np
33

4-
54
def derivative_from_samples(x:float, xs:np.array, fs:np.array) -> float:
65
'''
76
Calculates the derivative of the function f(x) which is sampled as fs at values xs

notebooks/demo.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"import pyhalomodel as halo\n",
2828
"\n",
2929
"# Project imports\n",
30-
"from pyhmcode import hmcode"
30+
"import hmcode"
3131
]
3232
},
3333
{
@@ -139,7 +139,7 @@
139139
"outputs": [],
140140
"source": [
141141
"# Get the new HMcode spectrum\n",
142-
"Pk_HMcode = hmcode(k, zs, results, verbose=True)"
142+
"Pk_HMcode = hmcode.power(k, zs, results, verbose=True)"
143143
]
144144
},
145145
{
@@ -243,7 +243,7 @@
243243
],
244244
"metadata": {
245245
"kernelspec": {
246-
"display_name": "pyhmcode-b1kLUJ5J-py3.10",
246+
"display_name": "hmcode-S0Z6NeuA-py3.10",
247247
"language": "python",
248248
"name": "python3"
249249
},
@@ -262,7 +262,7 @@
262262
"orig_nbformat": 4,
263263
"vscode": {
264264
"interpreter": {
265-
"hash": "b96bbc5816cd274b1c58d775ba8f893f60624f82ce43b36018f126a8bc6f1f92"
265+
"hash": "e82eed08d8d58f92fc7a23e50eeb23ca4d9777479ef0aea969fd18c18280722f"
266266
}
267267
}
268268
},

0 commit comments

Comments
 (0)