CosmoWAP 0.6.2__tar.gz → 0.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cosmowap-0.7.1/PKG-INFO +122 -0
- cosmowap-0.7.1/README.md +95 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/pyproject.toml +2 -2
- cosmowap-0.7.1/src/cosmo_wap/HOD/AbacusSummit_base_c000_ph000_best_params.txt +17 -0
- cosmowap-0.7.1/src/cosmo_wap/HOD/__init__.py +3 -0
- cosmowap-0.7.1/src/cosmo_wap/HOD/hmf.py +224 -0
- cosmowap-0.7.1/src/cosmo_wap/HOD/hods.py +179 -0
- cosmowap-0.7.1/src/cosmo_wap/HOD/peak_background_bias.py +226 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/__init__.py +3 -3
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/GR0.py +2 -2
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/GR1.py +1 -1
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/GR2.py +1 -1
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/PNG.py +1 -1
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/WSGR.py +3 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/bk_int.py +1 -1
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/combined.py +7 -1
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/cov.py +1 -1
- cosmowap-0.7.1/src/cosmo_wap/bk_mt/combined.py +59 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/forecast/base_posterior.py +48 -16
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/forecast/core.py +125 -93
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/forecast/covariances.py +167 -79
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/forecast/fisher.py +122 -4
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/forecast/fisher_list.py +5 -0
- cosmowap-0.7.1/src/cosmo_wap/forecast/forecast.py +1044 -0
- cosmowap-0.7.1/src/cosmo_wap/forecast/sampler.py +845 -0
- cosmowap-0.7.1/src/cosmo_wap/lib/__init__.py +12 -0
- cosmowap-0.7.1/src/cosmo_wap/lib/lf_priors.py +223 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/lib/luminosity_funcs.py +98 -44
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/lib/utils.py +41 -6
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/main.py +85 -27
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/numeric_mu/bk_int.py +1 -1
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/numeric_mu/kernels.py +1 -1
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/numeric_mu/pk.py +37 -19
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/IxS_components.py +6 -5
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/Pk_0.py +5 -5
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/Pk_WS.py +3 -3
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/combined.py +37 -3
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/cov.py +2 -2
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/covRR.py +29 -29
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/covWS.py +22 -22
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/covWSGR.py +29 -29
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/int.py +5 -4
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/int_components.py +1 -1
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/survey_params.py +79 -59
- cosmowap-0.7.1/src/cosmowap.egg-info/PKG-INFO +122 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmowap.egg-info/SOURCES.txt +10 -3
- cosmowap-0.7.1/tests/test_compute_bias.py +96 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/tests/test_fisher.py +47 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/tests/test_pk_multipoles.py +1 -1
- cosmowap-0.6.2/PKG-INFO +0 -117
- cosmowap-0.6.2/README.md +0 -90
- cosmowap-0.6.2/src/cosmo_wap/forecast/forecast.py +0 -649
- cosmowap-0.6.2/src/cosmo_wap/forecast/sampler.py +0 -512
- cosmowap-0.6.2/src/cosmo_wap/lib/__init__.py +0 -3
- cosmowap-0.6.2/src/cosmo_wap/peak_background_bias.py +0 -454
- cosmowap-0.6.2/src/cosmowap.egg-info/PKG-INFO +0 -117
- {cosmowap-0.6.2 → cosmowap-0.7.1}/LICENSE.txt +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/setup.cfg +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/GR_0.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/GR_1.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/GR_2.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/PNG_.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/RR1.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/RR2.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/RR_1.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/WA1.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/WA2.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/WARR.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/WA_1.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/WA_2.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk/__init__.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk_mt/GR0.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk_mt/GR1.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk_mt/GR2.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk_mt/PNG.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/bk_mt/__init__.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/data_library/SKAO1Data.txt +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/data_library/SKAO2Data.txt +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/data_library/k_modes.txt +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/data_library/snr_surveyparams.txt +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/forecast/__init__.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/forecast/mpi_mcmc.py +0 -0
- /cosmowap-0.6.2/src/cosmo_wap/lib/integrate.py → /cosmowap-0.7.1/src/cosmo_wap/lib/angular_integrate.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/lib/betas.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/lib/bk_plots.py +0 -0
- {cosmowap-0.6.2/src/cosmo_wap → cosmowap-0.7.1/src/cosmo_wap/lib}/integrated.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/lib/unpack.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/numeric_mu/__init__.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/numeric_mu/integration.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/numeric_mu/utils.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/PNG.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/Pk_WSGR.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmo_wap/pk/__init__.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmowap.egg-info/dependency_links.txt +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmowap.egg-info/requires.txt +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/src/cosmowap.egg-info/top_level.txt +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/tests/test_bk_multipoles.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/tests/test_forecast.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/tests/test_luminosity_funcs.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/tests/test_survey_params.py +0 -0
- {cosmowap-0.6.2 → cosmowap-0.7.1}/tests/test_utils.py +0 -0
cosmowap-0.7.1/PKG-INFO
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cosmowap
|
|
3
|
+
Version: 0.7.1
|
|
4
|
+
Summary: A package for forecasting with the galaxy clustering power spectra and bispectra
|
|
5
|
+
Author-email: Chris Addis <c.l.j.addis@qmul.ac.uk>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: homepage, https://github.com/craddis1/CosmoWAP
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE.txt
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: scipy>=1.15.0
|
|
16
|
+
Requires-Dist: matplotlib
|
|
17
|
+
Requires-Dist: tqdm
|
|
18
|
+
Requires-Dist: cython
|
|
19
|
+
Requires-Dist: classy
|
|
20
|
+
Requires-Dist: chainconsumer
|
|
21
|
+
Requires-Dist: cobaya
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: ruff; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# CosmoWAP
|
|
29
|
+
```
|
|
30
|
+
______ _ _____ ____
|
|
31
|
+
/ ____/___ _________ ___ ____| | / / | / __ \
|
|
32
|
+
/ / / __ \/ ___/ __ `__ \/ __ \ | /| / / /| | / /_/ /
|
|
33
|
+
/ /___/ /_/ (__ ) / / / / / /_/ / |/ |/ / ___ |/ ____/
|
|
34
|
+
\____/\____/____/_/ /_/ /_/\____/|__/|__/_/ |_/_/
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
[](https://pypi.org/project/cosmowap/)
|
|
39
|
+
[](https://github.com/craddis1/CosmoWAP/blob/main/LICENCE)
|
|
40
|
+
[](https://readthedocs.org/projects/cosmowap/builds/)
|
|
41
|
+
[](https://app.codacy.com/gh/craddis1/CosmoWAP/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
42
|
+
[](https://ascl.net/2507.020)
|
|
43
|
+
[](https://pepy.tech/projects/cosmowap)
|
|
44
|
+
[](https://github.com/astral-sh/ruff)
|
|
45
|
+
|
|
46
|
+
**Cosmo**logy with **W**ide-separation, rel**A**tivistic and **P**rimordial non-Gaussian contributions.
|
|
47
|
+
|
|
48
|
+
CosmoWAP is a project that has grown organically alongside several research works, taking an increasingly central role in their development. It is designed to be a flexible and user-friendly Python framework to enable quick and easy forecasts of large-scale galaxy clustering using 3D power spectrum and/or bispectrum multipoles.
|
|
49
|
+
|
|
50
|
+
The modelling covers several key areas: relativistic effects, wide-separation corrections, and Primordial non-Gaussianity (PNG) in standard perturbation theory. The core analytical expressions are derived in Mathematica (see [MathWAP](https://github.com/craddis1/MathWAP)) and stored as exported .py files for efficiency. These expressions ingest a cosmology (via CLASS) and a flexible set of bias models, and have been thoroughly validated with sanity checks and against existing literature results.
|
|
51
|
+
|
|
52
|
+
To enable realistic forecasts, the associated machinery has been built around the core: thorough bias modelling with HOD/luminosity functions, theoretical covariances, Fisher matrices, and MCMC modules. These tools are easily accessible and can be used flexibly for a wide range of survey scenarios.
|
|
53
|
+
|
|
54
|
+
## [Documentation](https://cosmowap.readthedocs.io/en/latest/)
|
|
55
|
+
|
|
56
|
+
> [!NOTE]
|
|
57
|
+
> Note this is still in progress as this is an evolving repo!
|
|
58
|
+
> Occasionally parts will be outdated and will contain deprecated methods.
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
> [!NOTE]
|
|
63
|
+
> Requires at least Python >=3.10 for full functionality.
|
|
64
|
+
> For use of CosmoPower emulators we recommend using Python 3.10 or 3.11 - See Docs for full details.
|
|
65
|
+
|
|
66
|
+
``` sh
|
|
67
|
+
pip install cosmowap
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
For Development mode...
|
|
71
|
+
|
|
72
|
+
Clone repository:
|
|
73
|
+
|
|
74
|
+
``` sh
|
|
75
|
+
git clone https://github.com/craddis1/CosmoWAP.git
|
|
76
|
+
```
|
|
77
|
+
and then make editable install:
|
|
78
|
+
``` sh
|
|
79
|
+
cd CosmoWAP
|
|
80
|
+
pip install -e .
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
See requirements.txt for full list of dependencies (most are common python libraries). classy (CLASS python wrapper) is necessary to fully use CosmoWAP.
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
**Core Observables**
|
|
88
|
+
|
|
89
|
+
3D redshift space Fourier statistics: Multipoles and full line-of-sight (LOS) dependent expressions (fully multi-tracer compatible).
|
|
90
|
+
|
|
91
|
+
* **$P_{\ell}(k)$:** Legendre Power spectrum multipoles.
|
|
92
|
+
* **$B_{\ell,m}(k_1,k_2,k_3)$:** Scoccimarro Bispectrum multipoles (TriPosH extension to come).
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
**Physical Contributions**
|
|
97
|
+
* **Wide-separation (WS) corrections:** Wide-angle and radial redshift contributions up to second order in the WS expansion.
|
|
98
|
+
* **Local Relativistic (GR) effects:** Projection and dynamical effects up to $(\mathcal{H}/k)^2$.
|
|
99
|
+
* **Integrated effects:** Lensing, ISW, and time delay contributions (currently implemented for the power spectrum only).
|
|
100
|
+
* **Primordial non-Gaussianity (PNG):** Contributions for local, equilateral, and orthogonal types — uses peak background split approach for biases.
|
|
101
|
+
* **Non-linearities:** Finger-of-God damping and non-linear `HaloFit`/`HMcode` $P(k)$.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
**Forecasting and Analysis**
|
|
106
|
+
* **Bias modelling:** Uses a range literature Luminosity Functions, HOD/HMF and peak-background split approach for different surveys.
|
|
107
|
+
* **Multi-tracer covariances:** Multipole covariances assuming Gaussianity for power spectrum (including wide-separation corrections) and bispectrum.
|
|
108
|
+
* **Forecasting modules:** Fisher matrices and MCMC capabilities through [`Cobaya`](https://github.com/CobayaSampler/cobaya) and emulated $P(k)$ with [`CosmoPower`](https://github.com/alessiospuriomancini/cosmopower).
|
|
109
|
+
* **Built-in plotting library:** Designed for exploring theoretical expressions, covariances and forecasts — plots of parameter posteriors implemented with [`ChainConsumer`](https://github.com/Samreay/ChainConsumer).
|
|
110
|
+
|
|
111
|
+
## Usage
|
|
112
|
+
|
|
113
|
+
If you use CosmoWAP in your research, please cite the relevant papers:
|
|
114
|
+
|
|
115
|
+
* Original code: [arXiv:2407.00168](https://arxiv.org/abs/2407.00168)
|
|
116
|
+
* Integrated effects in the power spectrum and forecasting routines: [arXiv:2511.09466](https://arxiv.org/abs/2511.09466)
|
|
117
|
+
* PNG, HODs and forecasting routines : arXiv:26xx.xxxx
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## Contact
|
|
121
|
+
|
|
122
|
+
If you find any bugs or errors or have any questions and suggestions feel free to get in touch :) - c.l.j.addis@qmul.ac.uk
|
cosmowap-0.7.1/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# CosmoWAP
|
|
2
|
+
```
|
|
3
|
+
______ _ _____ ____
|
|
4
|
+
/ ____/___ _________ ___ ____| | / / | / __ \
|
|
5
|
+
/ / / __ \/ ___/ __ `__ \/ __ \ | /| / / /| | / /_/ /
|
|
6
|
+
/ /___/ /_/ (__ ) / / / / / /_/ / |/ |/ / ___ |/ ____/
|
|
7
|
+
\____/\____/____/_/ /_/ /_/\____/|__/|__/_/ |_/_/
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
[](https://pypi.org/project/cosmowap/)
|
|
12
|
+
[](https://github.com/craddis1/CosmoWAP/blob/main/LICENCE)
|
|
13
|
+
[](https://readthedocs.org/projects/cosmowap/builds/)
|
|
14
|
+
[](https://app.codacy.com/gh/craddis1/CosmoWAP/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
15
|
+
[](https://ascl.net/2507.020)
|
|
16
|
+
[](https://pepy.tech/projects/cosmowap)
|
|
17
|
+
[](https://github.com/astral-sh/ruff)
|
|
18
|
+
|
|
19
|
+
**Cosmo**logy with **W**ide-separation, rel**A**tivistic and **P**rimordial non-Gaussian contributions.
|
|
20
|
+
|
|
21
|
+
CosmoWAP is a project that has grown organically alongside several research works, taking an increasingly central role in their development. It is designed to be a flexible and user-friendly Python framework to enable quick and easy forecasts of large-scale galaxy clustering using 3D power spectrum and/or bispectrum multipoles.
|
|
22
|
+
|
|
23
|
+
The modelling covers several key areas: relativistic effects, wide-separation corrections, and Primordial non-Gaussianity (PNG) in standard perturbation theory. The core analytical expressions are derived in Mathematica (see [MathWAP](https://github.com/craddis1/MathWAP)) and stored as exported .py files for efficiency. These expressions ingest a cosmology (via CLASS) and a flexible set of bias models, and have been thoroughly validated with sanity checks and against existing literature results.
|
|
24
|
+
|
|
25
|
+
To enable realistic forecasts, the associated machinery has been built around the core: thorough bias modelling with HOD/luminosity functions, theoretical covariances, Fisher matrices, and MCMC modules. These tools are easily accessible and can be used flexibly for a wide range of survey scenarios.
|
|
26
|
+
|
|
27
|
+
## [Documentation](https://cosmowap.readthedocs.io/en/latest/)
|
|
28
|
+
|
|
29
|
+
> [!NOTE]
|
|
30
|
+
> Note this is still in progress as this is an evolving repo!
|
|
31
|
+
> Occasionally parts will be outdated and will contain deprecated methods.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
> [!NOTE]
|
|
36
|
+
> Requires at least Python >=3.10 for full functionality.
|
|
37
|
+
> For use of CosmoPower emulators we recommend using Python 3.10 or 3.11 - See Docs for full details.
|
|
38
|
+
|
|
39
|
+
``` sh
|
|
40
|
+
pip install cosmowap
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
For Development mode...
|
|
44
|
+
|
|
45
|
+
Clone repository:
|
|
46
|
+
|
|
47
|
+
``` sh
|
|
48
|
+
git clone https://github.com/craddis1/CosmoWAP.git
|
|
49
|
+
```
|
|
50
|
+
and then make editable install:
|
|
51
|
+
``` sh
|
|
52
|
+
cd CosmoWAP
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
See requirements.txt for full list of dependencies (most are common python libraries). classy (CLASS python wrapper) is necessary to fully use CosmoWAP.
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
**Core Observables**
|
|
61
|
+
|
|
62
|
+
3D redshift space Fourier statistics: Multipoles and full line-of-sight (LOS) dependent expressions (fully multi-tracer compatible).
|
|
63
|
+
|
|
64
|
+
* **$P_{\ell}(k)$:** Legendre Power spectrum multipoles.
|
|
65
|
+
* **$B_{\ell,m}(k_1,k_2,k_3)$:** Scoccimarro Bispectrum multipoles (TriPosH extension to come).
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
**Physical Contributions**
|
|
70
|
+
* **Wide-separation (WS) corrections:** Wide-angle and radial redshift contributions up to second order in the WS expansion.
|
|
71
|
+
* **Local Relativistic (GR) effects:** Projection and dynamical effects up to $(\mathcal{H}/k)^2$.
|
|
72
|
+
* **Integrated effects:** Lensing, ISW, and time delay contributions (currently implemented for the power spectrum only).
|
|
73
|
+
* **Primordial non-Gaussianity (PNG):** Contributions for local, equilateral, and orthogonal types — uses peak background split approach for biases.
|
|
74
|
+
* **Non-linearities:** Finger-of-God damping and non-linear `HaloFit`/`HMcode` $P(k)$.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
**Forecasting and Analysis**
|
|
79
|
+
* **Bias modelling:** Uses a range literature Luminosity Functions, HOD/HMF and peak-background split approach for different surveys.
|
|
80
|
+
* **Multi-tracer covariances:** Multipole covariances assuming Gaussianity for power spectrum (including wide-separation corrections) and bispectrum.
|
|
81
|
+
* **Forecasting modules:** Fisher matrices and MCMC capabilities through [`Cobaya`](https://github.com/CobayaSampler/cobaya) and emulated $P(k)$ with [`CosmoPower`](https://github.com/alessiospuriomancini/cosmopower).
|
|
82
|
+
* **Built-in plotting library:** Designed for exploring theoretical expressions, covariances and forecasts — plots of parameter posteriors implemented with [`ChainConsumer`](https://github.com/Samreay/ChainConsumer).
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
If you use CosmoWAP in your research, please cite the relevant papers:
|
|
87
|
+
|
|
88
|
+
* Original code: [arXiv:2407.00168](https://arxiv.org/abs/2407.00168)
|
|
89
|
+
* Integrated effects in the power spectrum and forecasting routines: [arXiv:2511.09466](https://arxiv.org/abs/2511.09466)
|
|
90
|
+
* PNG, HODs and forecasting routines : arXiv:26xx.xxxx
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Contact
|
|
94
|
+
|
|
95
|
+
If you find any bugs or errors or have any questions and suggestions feel free to get in touch :) - c.l.j.addis@qmul.ac.uk
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cosmowap"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.7.1"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Chris Addis", email="c.l.j.addis@qmul.ac.uk" },
|
|
10
10
|
]
|
|
@@ -44,7 +44,7 @@ package-dir = {"" = "src"}
|
|
|
44
44
|
include-package-data = true
|
|
45
45
|
|
|
46
46
|
[tool.setuptools.package-data]
|
|
47
|
-
"cosmo_wap" = ["data_library/*.txt"]
|
|
47
|
+
"cosmo_wap" = ["data_library/*.txt", "HOD/*.txt"]
|
|
48
48
|
|
|
49
49
|
[tool.setuptools.packages.find]
|
|
50
50
|
where = ["src"]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-1.163295942035853792e-01
|
|
2
|
+
-5.759066407274642252e-01
|
|
3
|
+
1.437085418067726994e-01
|
|
4
|
+
-1.908335449679073731e-02
|
|
5
|
+
1.832666435246161490e-02
|
|
6
|
+
7.584865035087475782e-01
|
|
7
|
+
1.103103765754579246e+00
|
|
8
|
+
3.277787214124110449e-01
|
|
9
|
+
-5.468895455660652827e-01
|
|
10
|
+
-1.673562380257160864e+00
|
|
11
|
+
1.121497360473139082e+00
|
|
12
|
+
-4.725625165007949491e-01
|
|
13
|
+
9.200038944813740405e-02
|
|
14
|
+
-1.141762462160326314e-02
|
|
15
|
+
1.111866664500087198e+00
|
|
16
|
+
4.473949866395862784e+00
|
|
17
|
+
-4.353309870091147893e+00
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Halo Mass Function (HMF) multiplicity functions and halo bias models.
|
|
3
|
+
|
|
4
|
+
Multiplicity functions:
|
|
5
|
+
- Tinker et al. 2010 (arXiv:1001.3162)
|
|
6
|
+
- Sheth-Tormen (arXiv:astro-ph/9901122)
|
|
7
|
+
|
|
8
|
+
Halo Mass Function:
|
|
9
|
+
- n_h(zz) - R, M, sigma_R are all defined/computed as arrays in HMF
|
|
10
|
+
|
|
11
|
+
Bias models:
|
|
12
|
+
- Lagrangian bias from Numeric or analytic derivatives of multiplicity functions
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
import scipy.special as sp
|
|
19
|
+
from scipy.integrate import simpson
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def sigma_R_n(cosmo_funcs, R: np.ndarray, n: int, K_MIN: float = 5e-5, N_k: int = 200) -> np.ndarray:
|
|
23
|
+
"""
|
|
24
|
+
Compute sigma^2 for a given radius and n, i.e. does integral over k.
|
|
25
|
+
Vectorised over R using Simpson's rule on a log-spaced k-grid.
|
|
26
|
+
"""
|
|
27
|
+
k = np.logspace(np.log10(K_MIN), np.log10(cosmo_funcs.K_MAX), N_k)
|
|
28
|
+
pk_arr = np.array([cosmo_funcs.pk(ki) for ki in k])
|
|
29
|
+
kR = k[:, None] * R[None, :] # (Nk, NR)
|
|
30
|
+
W = 3.0 * (np.sin(kR) - kR * np.cos(kR)) / kR**3
|
|
31
|
+
integrand = k[:, None] ** (2 + n) * pk_arr[:, None] * W**2
|
|
32
|
+
return simpson(integrand, x=k, axis=0) / (2.0 * np.pi**2)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class HMF:
|
|
36
|
+
def __init__(self, cosmo_funcs, hmf="Tinker10"):
|
|
37
|
+
self.cosmo_funcs = cosmo_funcs
|
|
38
|
+
|
|
39
|
+
# setup HMF prerequisites if not already computed
|
|
40
|
+
if not hasattr(cosmo_funcs, "delta_c"):
|
|
41
|
+
self._setup_hmf()
|
|
42
|
+
|
|
43
|
+
self.delta_c = cosmo_funcs.delta_c
|
|
44
|
+
|
|
45
|
+
# peak height (z,R)
|
|
46
|
+
self.nu_func = lambda xx: self.delta_c / np.sqrt(self.cosmo_funcs.sig_R["0"](xx)) # interpolate along z
|
|
47
|
+
|
|
48
|
+
if hmf == "Tinker10":
|
|
49
|
+
self.multiplicity = self.multiplicity_Tinker10
|
|
50
|
+
self.lagbias = self.LagBias_Tinker10(self)
|
|
51
|
+
elif hmf == "ST":
|
|
52
|
+
self.multiplicity = self.multiplicity_ST
|
|
53
|
+
self.lagbias = self.LagBias_ST(self)
|
|
54
|
+
else: # we could easily integrate HMcode for literature HMFs
|
|
55
|
+
self.multiplicity = self.multiplicity_Tinker10
|
|
56
|
+
self.lagbias = self.LagBias(
|
|
57
|
+
self
|
|
58
|
+
) # do numerics derivs of multiplicity - default is tinker2010 mass function
|
|
59
|
+
|
|
60
|
+
def _setup_hmf(self, R=None):
|
|
61
|
+
"""
|
|
62
|
+
Setup for HMF stuff and store some computation - cosmology stuff
|
|
63
|
+
"""
|
|
64
|
+
cf = self.cosmo_funcs
|
|
65
|
+
if R is None:
|
|
66
|
+
R = np.logspace(-1.5, 1.5, 100, dtype=np.float32) # radius [Mpc/h]
|
|
67
|
+
cf.R = R
|
|
68
|
+
|
|
69
|
+
# precompute sigma^2 - for HMF
|
|
70
|
+
cf.sigmaR0 = sigma_R_n(cf, R, 0)
|
|
71
|
+
cf.sigmaR1 = sigma_R_n(cf, R, -1)
|
|
72
|
+
cf.sigmaR2 = sigma_R_n(cf, R, -2)
|
|
73
|
+
|
|
74
|
+
# store sigmas as functions of (R,) for scalar z or (R,z) for array z
|
|
75
|
+
cf.sig_R = {}
|
|
76
|
+
cf.sig_R["0"] = lambda xx: cf.sigmaR0[:, None] * np.atleast_1d(cf.D(xx))[None, :] ** 2
|
|
77
|
+
cf.sig_R["1"] = lambda xx: cf.sigmaR1[:, None] * np.atleast_1d(cf.D(xx))[None, :] ** 2
|
|
78
|
+
cf.sig_R["2"] = lambda xx: cf.sigmaR2[:, None] * np.atleast_1d(cf.D(xx))[None, :] ** 2
|
|
79
|
+
|
|
80
|
+
cf.delta_c = 1.686 # from spherical collapse model
|
|
81
|
+
|
|
82
|
+
# for critical density
|
|
83
|
+
GG = 4.300917e-3 # [pc M_sun^-1 (km/s)^2]
|
|
84
|
+
G = GG / (1e6 * cf.c**2) # gravitational constant # [Mpc M_sun^-1]
|
|
85
|
+
cf.rho_crit = lambda xx: (
|
|
86
|
+
3 * (cf.H_c(xx) * (1 + xx)) ** 2 / (8 * np.pi * G)
|
|
87
|
+
) # in units of h^2 Mo/ Mpc^3 where Mo is solar mass
|
|
88
|
+
cf.rho_m = lambda xx: cf.rho_crit(xx) * cf.Om_m(xx) # in units of h^2 Mo/ Mpc^3
|
|
89
|
+
|
|
90
|
+
# M_halo - mass enclosed within the radius
|
|
91
|
+
cf.M_halo = (4 * np.pi * cf.rho_m(0) * R**3) / 3 # [M_sun/h] - array in R
|
|
92
|
+
|
|
93
|
+
####################################### Which HMF: f(nu)
|
|
94
|
+
def halo_bias_params(self, zz: float) -> tuple[float, float, float, float, float]:
|
|
95
|
+
"""
|
|
96
|
+
Define initial free parameters from Tinker 2010 table 4, Delta=200
|
|
97
|
+
"""
|
|
98
|
+
# alpha0 = 0.368
|
|
99
|
+
beta0 = 0.589
|
|
100
|
+
gamma0 = 0.864
|
|
101
|
+
eta0 = -0.243
|
|
102
|
+
phi0 = -0.729
|
|
103
|
+
|
|
104
|
+
# alpha,beta,gamma,eta,psi
|
|
105
|
+
beta = beta0 * (1 + zz) ** (0.2)
|
|
106
|
+
gamma = gamma0 * (1 + zz) ** (-0.01)
|
|
107
|
+
eta = eta0 * (1 + zz) ** (0.27)
|
|
108
|
+
phi = phi0 * (1 + zz) ** (-0.08)
|
|
109
|
+
|
|
110
|
+
alpha = 1 / (
|
|
111
|
+
2 ** (eta - phi - 0.5)
|
|
112
|
+
* beta ** (-2 * phi)
|
|
113
|
+
* gamma ** (-0.5 - eta)
|
|
114
|
+
* (2**phi * beta ** (2 * phi) * sp.gamma(eta + 0.5) + gamma**phi * sp.gamma(0.5 + eta - phi))
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
return alpha, beta, gamma, eta, phi
|
|
118
|
+
|
|
119
|
+
def multiplicity_Tinker10(self, zz: float) -> np.ndarray:
|
|
120
|
+
alpha, beta, gamma, eta, psi = self.halo_bias_params(zz)
|
|
121
|
+
nu = self.nu_func(zz)
|
|
122
|
+
|
|
123
|
+
return nu * alpha * (1 + (beta * nu) ** (-2 * psi)) * nu ** (2 * eta) * np.exp(-gamma * nu**2 / 2)
|
|
124
|
+
|
|
125
|
+
def multiplicity_ST(self, zz: float) -> np.ndarray:
|
|
126
|
+
A = 0.3221
|
|
127
|
+
p = 0.3
|
|
128
|
+
a = 0.707 # 1
|
|
129
|
+
|
|
130
|
+
nu = self.nu_func(zz)
|
|
131
|
+
|
|
132
|
+
part1 = A * (1 + (a * nu**2) ** (-p))
|
|
133
|
+
part2 = nu * (2 * a / (np.pi)) ** (1 / 2) * (np.exp(-a * nu**2 / 2))
|
|
134
|
+
return part1 * part2
|
|
135
|
+
|
|
136
|
+
#############################################################################################
|
|
137
|
+
def n_h(self, zz: float | np.ndarray) -> np.ndarray:
|
|
138
|
+
"""
|
|
139
|
+
define halo mass function - number density of halos per unit mass - Tinker10
|
|
140
|
+
Return array in (R,z)
|
|
141
|
+
"""
|
|
142
|
+
sig_R = self.cosmo_funcs.sig_R["0"](zz) # array in R,z
|
|
143
|
+
M = self.cosmo_funcs.M_halo[:, None] # (R,1) for broadcasting
|
|
144
|
+
# derivative of sigma wrt to M
|
|
145
|
+
dSdM = np.gradient(np.sqrt(sig_R), self.cosmo_funcs.M_halo, axis=0) # 2D array R,z
|
|
146
|
+
|
|
147
|
+
return (self.cosmo_funcs.rho_m(0) / M) * self.multiplicity(zz) * np.abs(dSdM) / np.sqrt(sig_R)
|
|
148
|
+
|
|
149
|
+
###############################################################################################
|
|
150
|
+
# get langrangian and then eulerian biases
|
|
151
|
+
class LagBias:
|
|
152
|
+
"""
|
|
153
|
+
Get numeric local-in-matter bias expansion - from derivatives of the multiplicity function - e.g. see Appendix C arXiv:1911.03964v3
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
def __init__(self, parent_class):
|
|
157
|
+
self.pc = parent_class
|
|
158
|
+
|
|
159
|
+
def get_bn(self, zz, N):
|
|
160
|
+
coef = (-self.pc.nu_func(zz)) ** N / (self.pc.delta_c**N * self.pc.multiplicity(zz))
|
|
161
|
+
# computes derivatives of the multiplicity function
|
|
162
|
+
deriv = self.pc.multiplicity(zz)
|
|
163
|
+
for _ in range(N):
|
|
164
|
+
deriv = np.gradient(deriv, self.pc.nu_func(zz), axis=0)
|
|
165
|
+
|
|
166
|
+
return coef * deriv
|
|
167
|
+
|
|
168
|
+
def b1(self, zz):
|
|
169
|
+
return self.get_bn(zz, 1)
|
|
170
|
+
|
|
171
|
+
def b2(self, zz):
|
|
172
|
+
return self.get_bn(zz, 2)
|
|
173
|
+
|
|
174
|
+
# get langrangian biases from either numerical or analytic derivatives of the multiplicity function
|
|
175
|
+
# e.g. see Appendix C arXiv:1911.03964v3
|
|
176
|
+
class LagBias_Tinker10:
|
|
177
|
+
"""
|
|
178
|
+
define lagrangian biases in terms of z, M and the halo bias params - these are all arrays in (z,R)
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
def __init__(self, parent_class):
|
|
182
|
+
self.pc = parent_class
|
|
183
|
+
|
|
184
|
+
def b1(self, zz):
|
|
185
|
+
_, beta, gamma, eta, psi = self.pc.halo_bias_params(zz)
|
|
186
|
+
nu = self.pc.nu_func(zz)
|
|
187
|
+
delta_c = self.pc.delta_c
|
|
188
|
+
return (2 * psi) / (delta_c * ((beta * nu) ** (2 * psi) + 1)) + (gamma * nu**2 - 2 * eta - 1) / delta_c
|
|
189
|
+
|
|
190
|
+
def b2(self, zz):
|
|
191
|
+
_, beta, gamma, eta, psi = self.pc.halo_bias_params(zz)
|
|
192
|
+
nu = self.pc.nu_func(zz)
|
|
193
|
+
delta_c = self.pc.delta_c
|
|
194
|
+
return (2 * psi * (2 * gamma * nu**2 - 4 * eta + 2 * psi - 1)) / (
|
|
195
|
+
delta_c**2 * ((beta * nu) ** (2 * psi) + 1)
|
|
196
|
+
) + (gamma**2 * nu**4 - 4 * gamma * eta * nu**2 - 3 * gamma * nu**2 + 4 * eta**2 + 2 * eta) / delta_c**2
|
|
197
|
+
|
|
198
|
+
class LagBias_ST: # Sheth-Tormen mass functions biases
|
|
199
|
+
"""
|
|
200
|
+
define lagrangian biases in terms of z,M and the halo bias params - these are all arrays in (z,M)
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
def __init__(self, parent_class):
|
|
204
|
+
self.pc = parent_class
|
|
205
|
+
|
|
206
|
+
def b1(self, zz):
|
|
207
|
+
# A = 0.322
|
|
208
|
+
p = 0.3
|
|
209
|
+
q = 0.707
|
|
210
|
+
nu = self.pc.nu_func(zz)
|
|
211
|
+
delta_c = self.pc.delta_c
|
|
212
|
+
|
|
213
|
+
return (q * nu**2 - 1) / delta_c + 2 * p / (delta_c * (1 + (q * nu**2) ** p))
|
|
214
|
+
|
|
215
|
+
def b2(self, zz):
|
|
216
|
+
# A = 0.322
|
|
217
|
+
p = 0.3
|
|
218
|
+
q = 0.707
|
|
219
|
+
nu = self.pc.nu_func(zz)
|
|
220
|
+
delta_c = self.pc.delta_c
|
|
221
|
+
|
|
222
|
+
part1 = q * nu**2 * (q * nu**2 - 3) / delta_c**2
|
|
223
|
+
part2 = (1 + 2 * p + 2 * (q * nu**2 - 1)) * (2 * p) / (delta_c**2 * (1 + q * nu**2) ** p)
|
|
224
|
+
return part1 + part2
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# from matplotlib.pylab import ArrayLike
|
|
2
|
+
import os
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
from scipy.interpolate import CubicSpline
|
|
7
|
+
from scipy.optimize import newton
|
|
8
|
+
from scipy.special import erf
|
|
9
|
+
|
|
10
|
+
from cosmo_wap.lib.luminosity_funcs import BGSLuminosityFunction
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BaseHOD(ABC):
|
|
14
|
+
"""Abstract base class for Halo Occupation Distribution models."""
|
|
15
|
+
|
|
16
|
+
@abstractmethod
|
|
17
|
+
def get_hod_params(self, zz: np.ndarray, m_c: float | None = None) -> tuple:
|
|
18
|
+
"""Return HOD parameters as a tuple for the given redshift(s)."""
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
@abstractmethod
|
|
22
|
+
def HOD(self, zz: float, *args, **kwargs) -> np.ndarray:
|
|
23
|
+
"""Return the mean number of galaxies per halo N(M) at redshift zz."""
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class YP(BaseHOD):
|
|
28
|
+
"""Halo occupation distribution (HOD) model from Yankelevich and Porciani 2018"""
|
|
29
|
+
|
|
30
|
+
def __init__(self, PBBias, cosmo_funcs, survey_params, M0_func=None, NO_func=None):
|
|
31
|
+
self.PBBias = PBBias
|
|
32
|
+
self.survey_params = survey_params
|
|
33
|
+
self.cosmo_funcs = cosmo_funcs
|
|
34
|
+
self.M0_func = M0_func
|
|
35
|
+
self.NO_func = NO_func
|
|
36
|
+
|
|
37
|
+
def fit_params(self):
|
|
38
|
+
"""get fitted values of NO and M0 - speed up by using less points"""
|
|
39
|
+
z_arr = np.linspace(self.cosmo_funcs.z_min, self.cosmo_funcs.z_max, 10)
|
|
40
|
+
self.M0_func = self.fit_M0(z_arr)
|
|
41
|
+
self.NO_func = self.fit_NO(z_arr)
|
|
42
|
+
|
|
43
|
+
def get_hod_params(self, zz, m_c=None):
|
|
44
|
+
"""
|
|
45
|
+
get HOD params for given redshift from fits to survey specifications
|
|
46
|
+
"""
|
|
47
|
+
M0 = self.M0_func(zz)
|
|
48
|
+
NO = self.NO_func(zz)
|
|
49
|
+
return (M0, NO)
|
|
50
|
+
|
|
51
|
+
def HOD(self, zz, M0, NHO) -> np.ndarray:
|
|
52
|
+
"""
|
|
53
|
+
Define the HOD - N(M, z) mean number of galaxies per halo - from Yankelevich and porciani 2018: arXiv:1807.07076
|
|
54
|
+
"""
|
|
55
|
+
M = self.cosmo_funcs.M_halo[:, None] # (R,1) for broadcasting
|
|
56
|
+
|
|
57
|
+
theta_HoD = 1 + erf(2 * np.log10(M / M0))
|
|
58
|
+
N_c = np.exp(-10 * (np.log10(M / M0)) ** 2) + 0.05 * theta_HoD # central galaxies
|
|
59
|
+
N_s = 0.003 * (M / M0) * theta_HoD
|
|
60
|
+
|
|
61
|
+
return NHO * (N_c + N_s) # (R,z)
|
|
62
|
+
|
|
63
|
+
########################### fit M0 and NO to given n_g and b_1
|
|
64
|
+
def fit_M0(self, z_arr: np.ndarray) -> CubicSpline:
|
|
65
|
+
"""
|
|
66
|
+
fit M0 from linear bias (b_1 is independent of NO)
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def objective(M0, zz, NO=1):
|
|
70
|
+
"""
|
|
71
|
+
diff between linear bias from PBS and survey specifications
|
|
72
|
+
"""
|
|
73
|
+
return self.PBBias.general_galaxy_bias(self.PBBias.eulbias.b1, zz, M0, NO) / self.PBBias.number_density(
|
|
74
|
+
zz, M0, NO
|
|
75
|
+
) - self.survey_params.b_1(zz)
|
|
76
|
+
|
|
77
|
+
M0_arr = np.array([newton(objective, x0=1e12, args=(z,), rtol=1e-5) for z in z_arr])
|
|
78
|
+
|
|
79
|
+
return CubicSpline(z_arr, M0_arr) # now returns M0 as function of redshift
|
|
80
|
+
|
|
81
|
+
# now can find NO from n_g
|
|
82
|
+
def fit_NO(self, z_arr: np.ndarray) -> CubicSpline:
|
|
83
|
+
"""
|
|
84
|
+
fit NO from number density
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def objective(NO, zz, M0):
|
|
88
|
+
"""
|
|
89
|
+
diff between number density from PBS and survey specifications
|
|
90
|
+
"""
|
|
91
|
+
return self.PBBias.number_density(zz, M0, NO) - self.survey_params.n_g(zz)
|
|
92
|
+
|
|
93
|
+
# Use the secant method by not providing a derivative
|
|
94
|
+
NO_arr = np.array([newton(objective, x0=2.0, args=(z, self.M0_func(z)), rtol=1e-5) for z in z_arr])
|
|
95
|
+
|
|
96
|
+
return CubicSpline(z_arr, NO_arr) # now returns M0 as function of redshift
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class Smith_BGS(BaseHOD):
|
|
100
|
+
def __init__(self, cosmo_funcs):
|
|
101
|
+
self.cosmo_funcs = cosmo_funcs
|
|
102
|
+
cosmo = cosmo_funcs.cosmo
|
|
103
|
+
self.lf = BGSLuminosityFunction(cosmo)
|
|
104
|
+
self.lf.get_Q = self.lf.get_Q2 # use number density based Q method
|
|
105
|
+
|
|
106
|
+
# read the best-fitting HOD parameters
|
|
107
|
+
# The parameters in the file are in the order:
|
|
108
|
+
# Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
|
109
|
+
# Parameter: A_min, B_min, C_min, D_min, A_sigma, B_sigma, C_sigma, D_sigma, A_0, B_0, A_1, B_1, C_1, D_1, A_alpha, B_alpha, C_alpha
|
|
110
|
+
_dir = os.path.dirname(__file__)
|
|
111
|
+
self.params = np.loadtxt(os.path.join(_dir, "AbacusSummit_base_c000_ph000_best_params.txt"))
|
|
112
|
+
|
|
113
|
+
def get_M_c(self, m_c, zz):
|
|
114
|
+
"""convert to absolute magnitude with K-correction to z=0.1, since the parameters are fitted to z=0.1
|
|
115
|
+
Smith et al. use d_L in Mpc/h so absolute magnitudes include implicit h factor: M_h = M_phys - 5*log10(h)"""
|
|
116
|
+
return (
|
|
117
|
+
self.lf.M_UV(m_c, zz, ref_z=0.1)
|
|
118
|
+
- self.evolutionary_correction(zz, z_ref=0.1)
|
|
119
|
+
- 5 * np.log10(self.cosmo_funcs.h)
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# so define the HOD parameters as a function of magnitude, using the fits from Smith et al. 2024
|
|
123
|
+
# Original code taken from example notebooks in Smith et al. 2024.
|
|
124
|
+
|
|
125
|
+
# NOTE: these functions are defined with repsect to a threshold magnitude - not magnitude
|
|
126
|
+
def M_function(self, magnitude, A, B, C, D):
|
|
127
|
+
# Function for Mmin and M1
|
|
128
|
+
return (A + 12) + B * (magnitude + 20) + C * (magnitude + 20) ** 2 + D * (magnitude + 20) ** 3
|
|
129
|
+
|
|
130
|
+
def M0_function(self, magnitude, A, B): # logM0
|
|
131
|
+
M0s = (A + 11) + B * (magnitude + 20)
|
|
132
|
+
# M0s[M0s <=1.0] = 1.0
|
|
133
|
+
return M0s
|
|
134
|
+
|
|
135
|
+
def sigma_function(self, magnitude, A, B, C, D):
|
|
136
|
+
return A + (B - A) / (1.0 + np.exp((C * (magnitude + 20 + D))))
|
|
137
|
+
|
|
138
|
+
def alpha_function(self, magnitude, A, B, C):
|
|
139
|
+
return A + B ** (-magnitude - 20 + C)
|
|
140
|
+
|
|
141
|
+
def get_params(self, zz, m_c=20):
|
|
142
|
+
M_c = self.get_M_c(m_c, zz) # get cut in absolute magnitude
|
|
143
|
+
# ok so all of these are functions of m_c and z
|
|
144
|
+
Mmin = self.M_function(M_c, *self.params[:4])
|
|
145
|
+
sigma = self.sigma_function(M_c, *self.params[4:8])
|
|
146
|
+
M0 = self.M0_function(M_c, *self.params[8:10])
|
|
147
|
+
M1 = self.M_function(M_c, *self.params[10:14])
|
|
148
|
+
alpha = self.alpha_function(M_c, *self.params[14:])
|
|
149
|
+
|
|
150
|
+
return Mmin, sigma, M0, M1, alpha
|
|
151
|
+
|
|
152
|
+
#####################################################################################################
|
|
153
|
+
|
|
154
|
+
def get_hod_params(self, zz, m_c=20):
|
|
155
|
+
return (m_c,)
|
|
156
|
+
|
|
157
|
+
def evolutionary_correction(self, zz, z_ref=0.1):
|
|
158
|
+
"""
|
|
159
|
+
luminosity evolution correction E(z)=Q(z−z0) (Q from McNaught-Roberts et al. 2014 (GAMA))
|
|
160
|
+
So only applies to make sure the we have right units for the HOD parameters, since they are fitted to absolute magnitude at z=0.1
|
|
161
|
+
"""
|
|
162
|
+
return 0.97 * (zz - z_ref)
|
|
163
|
+
|
|
164
|
+
# HODs
|
|
165
|
+
def number_centrals(self, logM, logMmin, sigma): # Smith 2017/Zheng 2005
|
|
166
|
+
return 0.5 * (1 + erf((logM - logMmin) / sigma))
|
|
167
|
+
|
|
168
|
+
def number_satellites(self, logM, logM0, logM1, alpha): # e.g. Smith 2017/Zehavi 2011
|
|
169
|
+
N = (np.maximum(0, 10**logM - 10**logM0) / 10**logM1) ** alpha
|
|
170
|
+
return N
|
|
171
|
+
|
|
172
|
+
def HOD(self, zz, m_c=20): # Smith 2017
|
|
173
|
+
# use best fits from AbacusSummit_base_c000_ph000_best_params.txt with m_c =20
|
|
174
|
+
logMmin, sigma, logM0, logM1, alpha = self.get_params(zz, m_c)
|
|
175
|
+
|
|
176
|
+
logM = np.log10(self.cosmo_funcs.M_halo[:, None]) # (R,1) for broadcasting with z
|
|
177
|
+
Ncen = self.number_centrals(logM, logMmin, sigma)
|
|
178
|
+
Nsat = self.number_satellites(logM, logM0, logM1, alpha)
|
|
179
|
+
return Ncen + Nsat * Ncen
|