disco-cmb 0.1.0__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.
- disco_cmb-0.1.0/LICENSE +21 -0
- disco_cmb-0.1.0/PKG-INFO +178 -0
- disco_cmb-0.1.0/README.md +147 -0
- disco_cmb-0.1.0/pyproject.toml +139 -0
- disco_cmb-0.1.0/setup.cfg +4 -0
- disco_cmb-0.1.0/src/disco_cmb.egg-info/PKG-INFO +178 -0
- disco_cmb-0.1.0/src/disco_cmb.egg-info/SOURCES.txt +19 -0
- disco_cmb-0.1.0/src/disco_cmb.egg-info/dependency_links.txt +1 -0
- disco_cmb-0.1.0/src/disco_cmb.egg-info/requires.txt +9 -0
- disco_cmb-0.1.0/src/disco_cmb.egg-info/top_level.txt +1 -0
- disco_cmb-0.1.0/src/discocmb/__init__.py +37 -0
- disco_cmb-0.1.0/src/discocmb/grids.py +346 -0
- disco_cmb-0.1.0/src/discocmb/lensing.py +477 -0
- disco_cmb-0.1.0/src/discocmb/main.py +288 -0
- disco_cmb-0.1.0/src/discocmb/sources.py +323 -0
- disco_cmb-0.1.0/src/discocmb/spectra.py +96 -0
- disco_cmb-0.1.0/src/discocmb/transfer.py +415 -0
- disco_cmb-0.1.0/tests/test_boundary.py +56 -0
- disco_cmb-0.1.0/tests/test_cmb.py +693 -0
- disco_cmb-0.1.0/tests/test_lensing.py +251 -0
- disco_cmb-0.1.0/tests/test_reionization.py +94 -0
disco_cmb-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lawrence Berry and Oliver Hahn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
disco_cmb-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: disco-cmb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CMB angular power spectra on the GPU from DISCO-EB's Einstein-Boltzmann solve
|
|
5
|
+
Author-email: Lawrence Berry <lawrenceberry@outlook.com>, Oliver Hahn <oliver.hahn@univie.ac.at>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Documentation, https://cosmo-sims.github.io/DISCO-CMB/
|
|
8
|
+
Project-URL: Source, https://github.com/cosmo-sims/DISCO-CMB
|
|
9
|
+
Project-URL: Issues, https://github.com/cosmo-sims/DISCO-CMB/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: GPU :: NVIDIA CUDA
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: disco-eb>=2.0.0
|
|
24
|
+
Requires-Dist: numpy
|
|
25
|
+
Requires-Dist: scipy
|
|
26
|
+
Provides-Extra: cuda12
|
|
27
|
+
Requires-Dist: disco-eb[cuda12]>=2.0.0; extra == "cuda12"
|
|
28
|
+
Provides-Extra: cuda13
|
|
29
|
+
Requires-Dist: disco-eb[cuda13]>=2.0.0; extra == "cuda13"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
<h1 align="center">DISCO-CMB</h1>
|
|
33
|
+
|
|
34
|
+
<!--
|
|
35
|
+
The coverage badge reads a gist that the `tests` workflow rewrites on every
|
|
36
|
+
push to main; the id below is the repository variable COVERAGE_GIST_ID.
|
|
37
|
+
These badges sit above the `overview` snippet marker, so the documentation
|
|
38
|
+
site does not repeat them.
|
|
39
|
+
-->
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml"><img alt="tests" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml/badge.svg?branch=main"></a>
|
|
42
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml"><img alt="coverage" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Flawrenceberry%2Fb451e14a9620fabb0d49c345f13b5414%2Fraw%2Fdiscocmb-coverage.json"></a>
|
|
43
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/lint.yml"><img alt="lint" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/lint.yml/badge.svg?branch=main"></a>
|
|
44
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/types.yml"><img alt="types" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/types.yml/badge.svg?branch=main"></a>
|
|
45
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="PyPI" src="https://img.shields.io/pypi/v/disco-cmb"></a>
|
|
46
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="Downloads" src="https://img.shields.io/pypi/dm/disco-cmb"></a>
|
|
47
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/disco-cmb"></a>
|
|
48
|
+
<a href="https://docs.jax.dev/"><img alt="JAX" src="https://img.shields.io/badge/JAX-compatible-3f51b5"></a>
|
|
49
|
+
<a href="https://arxiv.org/abs/2311.03291"><img alt="arXiv" src="https://img.shields.io/badge/arXiv-2311.03291-b31b1b.svg"></a>
|
|
50
|
+
<a href="https://www.conventionalcommits.org/en/v1.0.0/"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
|
|
51
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<p align="center">
|
|
55
|
+
<a href="#installation">Installation</a> •
|
|
56
|
+
<a href="#quickstart">Quickstart</a> •
|
|
57
|
+
<a href="https://cosmo-sims.github.io/DISCO-CMB/">Documentation</a> •
|
|
58
|
+
<a href="https://arxiv.org/abs/2311.03291">DISCO-EB paper</a> •
|
|
59
|
+
<a href="#citation">Citation</a>
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
<!-- start:overview -->
|
|
63
|
+
|
|
64
|
+
DISCO-CMB computes CMB angular power spectra for **batches of cosmologies on the GPU**. It builds on the Einstein-Boltzmann solver of [DISCO-EB](https://github.com/cosmo-sims/DISCO-EB) and adds line-of-sight integration, the unlensed TT, TE and EE spectra, the lensing potential and the lensed TT, TE, EE and BB spectra.
|
|
65
|
+
|
|
66
|
+
A single GPU launch evolves every wave mode of every cosmology in a batch, with the line-of-sight sources evaluated inside the solver's kernel. The unlensed TT spectrum agrees with CLASS to 0.25 percent for multipoles 2 to 1200, and JAX can differentiate the spectra with respect to the cosmological parameters.
|
|
67
|
+
|
|
68
|
+
<!-- end:overview -->
|
|
69
|
+
|
|
70
|
+
The [documentation](https://cosmo-sims.github.io/DISCO-CMB/) covers the API
|
|
71
|
+
and explains how the pipeline fits together.
|
|
72
|
+
|
|
73
|
+
## Installation
|
|
74
|
+
|
|
75
|
+
<!-- start:install -->
|
|
76
|
+
|
|
77
|
+
DISCO-CMB needs an NVIDIA GPU. Install it from PyPI, which brings DISCO-EB with it:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install "disco-cmb[cuda13]" # or [cuda12], which Python 3.10 needs
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
<!-- end:install -->
|
|
84
|
+
|
|
85
|
+
## Quickstart
|
|
86
|
+
|
|
87
|
+
<!-- start:quickstart -->
|
|
88
|
+
|
|
89
|
+
This example computes the unlensed spectra of three cosmologies that differ in their spectral index. The grids come from a fiducial cosmology once, and every later batch reuses them:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from discocmb import cmb_grids, compute_cl_power_spectrum_batch
|
|
93
|
+
|
|
94
|
+
planck = {
|
|
95
|
+
"Omegam": 0.3144,
|
|
96
|
+
"Omegab": 0.04939,
|
|
97
|
+
"H0": 67.32,
|
|
98
|
+
"Omegak": 0.0,
|
|
99
|
+
"A_s": 2.1e-9,
|
|
100
|
+
"n_s": 0.966,
|
|
101
|
+
"k_p": 0.05,
|
|
102
|
+
"Tcmb": 2.7255,
|
|
103
|
+
"YHe": 0.2454,
|
|
104
|
+
"Neff": 3.046,
|
|
105
|
+
"Nmnu": 0.0,
|
|
106
|
+
"mnu": 0.0,
|
|
107
|
+
"w_DE_0": -1.0,
|
|
108
|
+
"w_DE_a": 0.0,
|
|
109
|
+
"cs2_DE": 1.0,
|
|
110
|
+
}
|
|
111
|
+
batch = [planck | {"n_s": n_s} for n_s in (0.95, 0.966, 0.98)]
|
|
112
|
+
|
|
113
|
+
grids = cmb_grids(planck)
|
|
114
|
+
ells, cl, dl = compute_cl_power_spectrum_batch(batch, grids=grids)
|
|
115
|
+
dl.tt # (3, n_ell) in muK^2
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
<!-- end:quickstart -->
|
|
119
|
+
|
|
120
|
+
## Development
|
|
121
|
+
|
|
122
|
+
<!-- start:development -->
|
|
123
|
+
|
|
124
|
+
The repository uses [uv](https://docs.astral.sh/uv/):
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git clone https://github.com/cosmo-sims/DISCO-CMB.git
|
|
128
|
+
cd DISCO-CMB && uv sync --extra cuda13 # or --extra cuda12
|
|
129
|
+
uv run pytest tests # needs a CUDA GPU
|
|
130
|
+
uv run ruff format && uv run ruff check --fix
|
|
131
|
+
uv run ty check
|
|
132
|
+
uv run pre-commit install # the checks above, and a commit-message check
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The documentation (Sphinx with MyST and autodoc) builds in an environment of its own, the package plus the docs group:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
export UV_PROJECT_ENVIRONMENT=.venv-docs
|
|
139
|
+
uv sync --no-default-groups --group docs
|
|
140
|
+
uv run --no-sync sphinx-autobuild docs docs/_build/html # live preview
|
|
141
|
+
uv run --no-sync sphinx-build -W docs docs/_build/html # what CI runs
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
<!-- end:development -->
|
|
145
|
+
|
|
146
|
+
## Citation
|
|
147
|
+
|
|
148
|
+
<!-- start:citation -->
|
|
149
|
+
|
|
150
|
+
If you use DISCO-CMB in your research, please cite this repository (see
|
|
151
|
+
[CITATION.cff](https://github.com/cosmo-sims/DISCO-CMB/blob/main/CITATION.cff))
|
|
152
|
+
and the DISCO-EB article it builds on:
|
|
153
|
+
|
|
154
|
+
```bibtex
|
|
155
|
+
@article{DISCO-EB:2024,
|
|
156
|
+
author = "Hahn, Oliver and List, Florian and Porqueres, Natalia",
|
|
157
|
+
title = "{DISCO-DJ I: a differentiable Einstein-Boltzmann solver for cosmology}",
|
|
158
|
+
eprint = "2311.03291",
|
|
159
|
+
archivePrefix = "arXiv",
|
|
160
|
+
primaryClass = "astro-ph.CO",
|
|
161
|
+
doi = "10.1088/1475-7516/2024/06/063",
|
|
162
|
+
journal = "JCAP",
|
|
163
|
+
volume = "06",
|
|
164
|
+
pages = "063",
|
|
165
|
+
year = "2024"
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
<!-- end:citation -->
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
<!-- start:license -->
|
|
174
|
+
|
|
175
|
+
DISCO-CMB is released under the
|
|
176
|
+
[MIT License](https://github.com/cosmo-sims/DISCO-CMB/blob/main/LICENSE).
|
|
177
|
+
|
|
178
|
+
<!-- end:license -->
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<h1 align="center">DISCO-CMB</h1>
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
The coverage badge reads a gist that the `tests` workflow rewrites on every
|
|
5
|
+
push to main; the id below is the repository variable COVERAGE_GIST_ID.
|
|
6
|
+
These badges sit above the `overview` snippet marker, so the documentation
|
|
7
|
+
site does not repeat them.
|
|
8
|
+
-->
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml"><img alt="tests" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml/badge.svg?branch=main"></a>
|
|
11
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml"><img alt="coverage" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Flawrenceberry%2Fb451e14a9620fabb0d49c345f13b5414%2Fraw%2Fdiscocmb-coverage.json"></a>
|
|
12
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/lint.yml"><img alt="lint" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/lint.yml/badge.svg?branch=main"></a>
|
|
13
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/types.yml"><img alt="types" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/types.yml/badge.svg?branch=main"></a>
|
|
14
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="PyPI" src="https://img.shields.io/pypi/v/disco-cmb"></a>
|
|
15
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="Downloads" src="https://img.shields.io/pypi/dm/disco-cmb"></a>
|
|
16
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/disco-cmb"></a>
|
|
17
|
+
<a href="https://docs.jax.dev/"><img alt="JAX" src="https://img.shields.io/badge/JAX-compatible-3f51b5"></a>
|
|
18
|
+
<a href="https://arxiv.org/abs/2311.03291"><img alt="arXiv" src="https://img.shields.io/badge/arXiv-2311.03291-b31b1b.svg"></a>
|
|
19
|
+
<a href="https://www.conventionalcommits.org/en/v1.0.0/"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
|
|
20
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<a href="#installation">Installation</a> •
|
|
25
|
+
<a href="#quickstart">Quickstart</a> •
|
|
26
|
+
<a href="https://cosmo-sims.github.io/DISCO-CMB/">Documentation</a> •
|
|
27
|
+
<a href="https://arxiv.org/abs/2311.03291">DISCO-EB paper</a> •
|
|
28
|
+
<a href="#citation">Citation</a>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<!-- start:overview -->
|
|
32
|
+
|
|
33
|
+
DISCO-CMB computes CMB angular power spectra for **batches of cosmologies on the GPU**. It builds on the Einstein-Boltzmann solver of [DISCO-EB](https://github.com/cosmo-sims/DISCO-EB) and adds line-of-sight integration, the unlensed TT, TE and EE spectra, the lensing potential and the lensed TT, TE, EE and BB spectra.
|
|
34
|
+
|
|
35
|
+
A single GPU launch evolves every wave mode of every cosmology in a batch, with the line-of-sight sources evaluated inside the solver's kernel. The unlensed TT spectrum agrees with CLASS to 0.25 percent for multipoles 2 to 1200, and JAX can differentiate the spectra with respect to the cosmological parameters.
|
|
36
|
+
|
|
37
|
+
<!-- end:overview -->
|
|
38
|
+
|
|
39
|
+
The [documentation](https://cosmo-sims.github.io/DISCO-CMB/) covers the API
|
|
40
|
+
and explains how the pipeline fits together.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
<!-- start:install -->
|
|
45
|
+
|
|
46
|
+
DISCO-CMB needs an NVIDIA GPU. Install it from PyPI, which brings DISCO-EB with it:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install "disco-cmb[cuda13]" # or [cuda12], which Python 3.10 needs
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
<!-- end:install -->
|
|
53
|
+
|
|
54
|
+
## Quickstart
|
|
55
|
+
|
|
56
|
+
<!-- start:quickstart -->
|
|
57
|
+
|
|
58
|
+
This example computes the unlensed spectra of three cosmologies that differ in their spectral index. The grids come from a fiducial cosmology once, and every later batch reuses them:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from discocmb import cmb_grids, compute_cl_power_spectrum_batch
|
|
62
|
+
|
|
63
|
+
planck = {
|
|
64
|
+
"Omegam": 0.3144,
|
|
65
|
+
"Omegab": 0.04939,
|
|
66
|
+
"H0": 67.32,
|
|
67
|
+
"Omegak": 0.0,
|
|
68
|
+
"A_s": 2.1e-9,
|
|
69
|
+
"n_s": 0.966,
|
|
70
|
+
"k_p": 0.05,
|
|
71
|
+
"Tcmb": 2.7255,
|
|
72
|
+
"YHe": 0.2454,
|
|
73
|
+
"Neff": 3.046,
|
|
74
|
+
"Nmnu": 0.0,
|
|
75
|
+
"mnu": 0.0,
|
|
76
|
+
"w_DE_0": -1.0,
|
|
77
|
+
"w_DE_a": 0.0,
|
|
78
|
+
"cs2_DE": 1.0,
|
|
79
|
+
}
|
|
80
|
+
batch = [planck | {"n_s": n_s} for n_s in (0.95, 0.966, 0.98)]
|
|
81
|
+
|
|
82
|
+
grids = cmb_grids(planck)
|
|
83
|
+
ells, cl, dl = compute_cl_power_spectrum_batch(batch, grids=grids)
|
|
84
|
+
dl.tt # (3, n_ell) in muK^2
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
<!-- end:quickstart -->
|
|
88
|
+
|
|
89
|
+
## Development
|
|
90
|
+
|
|
91
|
+
<!-- start:development -->
|
|
92
|
+
|
|
93
|
+
The repository uses [uv](https://docs.astral.sh/uv/):
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
git clone https://github.com/cosmo-sims/DISCO-CMB.git
|
|
97
|
+
cd DISCO-CMB && uv sync --extra cuda13 # or --extra cuda12
|
|
98
|
+
uv run pytest tests # needs a CUDA GPU
|
|
99
|
+
uv run ruff format && uv run ruff check --fix
|
|
100
|
+
uv run ty check
|
|
101
|
+
uv run pre-commit install # the checks above, and a commit-message check
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The documentation (Sphinx with MyST and autodoc) builds in an environment of its own, the package plus the docs group:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
export UV_PROJECT_ENVIRONMENT=.venv-docs
|
|
108
|
+
uv sync --no-default-groups --group docs
|
|
109
|
+
uv run --no-sync sphinx-autobuild docs docs/_build/html # live preview
|
|
110
|
+
uv run --no-sync sphinx-build -W docs docs/_build/html # what CI runs
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
<!-- end:development -->
|
|
114
|
+
|
|
115
|
+
## Citation
|
|
116
|
+
|
|
117
|
+
<!-- start:citation -->
|
|
118
|
+
|
|
119
|
+
If you use DISCO-CMB in your research, please cite this repository (see
|
|
120
|
+
[CITATION.cff](https://github.com/cosmo-sims/DISCO-CMB/blob/main/CITATION.cff))
|
|
121
|
+
and the DISCO-EB article it builds on:
|
|
122
|
+
|
|
123
|
+
```bibtex
|
|
124
|
+
@article{DISCO-EB:2024,
|
|
125
|
+
author = "Hahn, Oliver and List, Florian and Porqueres, Natalia",
|
|
126
|
+
title = "{DISCO-DJ I: a differentiable Einstein-Boltzmann solver for cosmology}",
|
|
127
|
+
eprint = "2311.03291",
|
|
128
|
+
archivePrefix = "arXiv",
|
|
129
|
+
primaryClass = "astro-ph.CO",
|
|
130
|
+
doi = "10.1088/1475-7516/2024/06/063",
|
|
131
|
+
journal = "JCAP",
|
|
132
|
+
volume = "06",
|
|
133
|
+
pages = "063",
|
|
134
|
+
year = "2024"
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
<!-- end:citation -->
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
<!-- start:license -->
|
|
143
|
+
|
|
144
|
+
DISCO-CMB is released under the
|
|
145
|
+
[MIT License](https://github.com/cosmo-sims/DISCO-CMB/blob/main/LICENSE).
|
|
146
|
+
|
|
147
|
+
<!-- end:license -->
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "disco-cmb"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "CMB angular power spectra on the GPU from DISCO-EB's Einstein-Boltzmann solve"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Lawrence Berry", email = "lawrenceberry@outlook.com" },
|
|
9
|
+
{ name = "Oliver Hahn", email = "oliver.hahn@univie.ac.at" },
|
|
10
|
+
]
|
|
11
|
+
# PEP 639: an SPDX expression and the files themselves. Needs the setuptools
|
|
12
|
+
# pinned below.
|
|
13
|
+
license = "MIT"
|
|
14
|
+
license-files = ["LICENSE"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Environment :: GPU :: NVIDIA CUDA",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"Operating System :: POSIX :: Linux",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Astronomy",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
# The Einstein-Boltzmann solve, through its interface, the discoeb
|
|
29
|
+
# package; DISCO-EB brings JAX, modax and the CUDA stack.
|
|
30
|
+
"disco-eb>=2.0.0",
|
|
31
|
+
"numpy",
|
|
32
|
+
"scipy",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
# DISCO-EB's extras, which pick JAX's CUDA build. Without one, JAX runs on
|
|
37
|
+
# the CPU and the solver's GPU kernel fails to launch.
|
|
38
|
+
cuda12 = ["disco-eb[cuda12]>=2.0.0"]
|
|
39
|
+
# JAX's CUDA 13 build needs Python 3.11 or newer, so 3.10 needs `cuda12`.
|
|
40
|
+
cuda13 = ["disco-eb[cuda13]>=2.0.0"]
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Documentation = "https://cosmo-sims.github.io/DISCO-CMB/"
|
|
44
|
+
Source = "https://github.com/cosmo-sims/DISCO-CMB"
|
|
45
|
+
Issues = "https://github.com/cosmo-sims/DISCO-CMB/issues"
|
|
46
|
+
|
|
47
|
+
[dependency-groups]
|
|
48
|
+
# The docs build (Sphinx, MyST and autodoc) imports the package, so its
|
|
49
|
+
# environment is the project plus this group:
|
|
50
|
+
# `uv sync --no-default-groups --group docs`. Importing needs no GPU.
|
|
51
|
+
docs = [
|
|
52
|
+
"sphinx>=8.1",
|
|
53
|
+
"myst-parser>=4.0",
|
|
54
|
+
"sphinx-book-theme>=1.1",
|
|
55
|
+
# Grids and dropdowns in MyST pages.
|
|
56
|
+
"sphinx-design>=0.6",
|
|
57
|
+
# `sphinx-autobuild docs docs/_build/html` serves the site and rebuilds on save.
|
|
58
|
+
"sphinx-autobuild>=2024.10",
|
|
59
|
+
]
|
|
60
|
+
dev = [
|
|
61
|
+
# The CLASS references the tests compare against.
|
|
62
|
+
"classy>=3.3.4.0",
|
|
63
|
+
"pre-commit>=4.4.0",
|
|
64
|
+
"pytest>=9.0.2",
|
|
65
|
+
"pytest-benchmark>=5.2.3",
|
|
66
|
+
"pytest-cov>=7.0.0",
|
|
67
|
+
"ruff>=0.15.5",
|
|
68
|
+
# The same type checker CI and the pre-commit hook run.
|
|
69
|
+
"ty>=0.0.83",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[build-system]
|
|
73
|
+
requires = ["setuptools>=77"]
|
|
74
|
+
build-backend = "setuptools.build_meta"
|
|
75
|
+
|
|
76
|
+
# DISCO-EB's pins of the GPU stack; uv applies these from the root project only.
|
|
77
|
+
[tool.uv]
|
|
78
|
+
constraint-dependencies = [
|
|
79
|
+
"numba-cuda-mlir==0.5.1",
|
|
80
|
+
"cuda-toolkit==13.2.1; python_version >= '3.11'",
|
|
81
|
+
]
|
|
82
|
+
override-dependencies = ["numba>=0.61", "llvmlite>=0.44"]
|
|
83
|
+
|
|
84
|
+
[tool.semantic_release]
|
|
85
|
+
# python-semantic-release (the `publish` workflow) reads the Conventional
|
|
86
|
+
# Commits since the last `v*` tag, picks the next version, writes it here,
|
|
87
|
+
# updates CHANGELOG.md, commits, tags and builds. Below 1.0.0 a `feat` bumps
|
|
88
|
+
# the minor version and a `fix` or `perf` the patch; with `major_on_zero`
|
|
89
|
+
# false, a breaking change bumps the minor too.
|
|
90
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
91
|
+
tag_format = "v{version}"
|
|
92
|
+
commit_parser = "conventional"
|
|
93
|
+
commit_message = "chore(release): v{version}"
|
|
94
|
+
allow_zero_version = true
|
|
95
|
+
major_on_zero = false
|
|
96
|
+
# uv.lock records the project's own version, so the build refreshes that one
|
|
97
|
+
# entry and stages it with the release commit. `set -e`: the command is one
|
|
98
|
+
# shell script, and without it a failed step is ignored.
|
|
99
|
+
build_command = """
|
|
100
|
+
set -e
|
|
101
|
+
python -m pip install "uv==0.13.7"
|
|
102
|
+
uv lock --upgrade-package "$PACKAGE_NAME"
|
|
103
|
+
git add uv.lock
|
|
104
|
+
uv build
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
[tool.semantic_release.branches.main]
|
|
108
|
+
match = "main"
|
|
109
|
+
prerelease = false
|
|
110
|
+
|
|
111
|
+
[tool.semantic_release.changelog]
|
|
112
|
+
mode = "update"
|
|
113
|
+
insertion_flag = "<!-- version list -->"
|
|
114
|
+
exclude_commit_patterns = ['^chore\(release\):']
|
|
115
|
+
|
|
116
|
+
[tool.semantic_release.changelog.default_templates]
|
|
117
|
+
changelog_file = "CHANGELOG.md"
|
|
118
|
+
|
|
119
|
+
[tool.ruff.lint]
|
|
120
|
+
# On top of the default `select`, enable import sorting.
|
|
121
|
+
extend-select = ["I"]
|
|
122
|
+
|
|
123
|
+
[tool.ruff.lint.isort]
|
|
124
|
+
known-first-party = ["discocmb"]
|
|
125
|
+
|
|
126
|
+
[tool.coverage.run]
|
|
127
|
+
source = ["discocmb"]
|
|
128
|
+
branch = true
|
|
129
|
+
|
|
130
|
+
[tool.coverage.report]
|
|
131
|
+
exclude_also = [
|
|
132
|
+
"if TYPE_CHECKING:",
|
|
133
|
+
"raise NotImplementedError",
|
|
134
|
+
"if __name__ == .__main__.:",
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
[tool.ty.src]
|
|
138
|
+
# The shipped package is what the type check gates.
|
|
139
|
+
include = ["src/discocmb"]
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: disco-cmb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CMB angular power spectra on the GPU from DISCO-EB's Einstein-Boltzmann solve
|
|
5
|
+
Author-email: Lawrence Berry <lawrenceberry@outlook.com>, Oliver Hahn <oliver.hahn@univie.ac.at>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Documentation, https://cosmo-sims.github.io/DISCO-CMB/
|
|
8
|
+
Project-URL: Source, https://github.com/cosmo-sims/DISCO-CMB
|
|
9
|
+
Project-URL: Issues, https://github.com/cosmo-sims/DISCO-CMB/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: GPU :: NVIDIA CUDA
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: disco-eb>=2.0.0
|
|
24
|
+
Requires-Dist: numpy
|
|
25
|
+
Requires-Dist: scipy
|
|
26
|
+
Provides-Extra: cuda12
|
|
27
|
+
Requires-Dist: disco-eb[cuda12]>=2.0.0; extra == "cuda12"
|
|
28
|
+
Provides-Extra: cuda13
|
|
29
|
+
Requires-Dist: disco-eb[cuda13]>=2.0.0; extra == "cuda13"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
<h1 align="center">DISCO-CMB</h1>
|
|
33
|
+
|
|
34
|
+
<!--
|
|
35
|
+
The coverage badge reads a gist that the `tests` workflow rewrites on every
|
|
36
|
+
push to main; the id below is the repository variable COVERAGE_GIST_ID.
|
|
37
|
+
These badges sit above the `overview` snippet marker, so the documentation
|
|
38
|
+
site does not repeat them.
|
|
39
|
+
-->
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml"><img alt="tests" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml/badge.svg?branch=main"></a>
|
|
42
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/tests.yml"><img alt="coverage" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2Flawrenceberry%2Fb451e14a9620fabb0d49c345f13b5414%2Fraw%2Fdiscocmb-coverage.json"></a>
|
|
43
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/lint.yml"><img alt="lint" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/lint.yml/badge.svg?branch=main"></a>
|
|
44
|
+
<a href="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/types.yml"><img alt="types" src="https://github.com/cosmo-sims/DISCO-CMB/actions/workflows/types.yml/badge.svg?branch=main"></a>
|
|
45
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="PyPI" src="https://img.shields.io/pypi/v/disco-cmb"></a>
|
|
46
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="Downloads" src="https://img.shields.io/pypi/dm/disco-cmb"></a>
|
|
47
|
+
<a href="https://pypi.org/project/disco-cmb/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/disco-cmb"></a>
|
|
48
|
+
<a href="https://docs.jax.dev/"><img alt="JAX" src="https://img.shields.io/badge/JAX-compatible-3f51b5"></a>
|
|
49
|
+
<a href="https://arxiv.org/abs/2311.03291"><img alt="arXiv" src="https://img.shields.io/badge/arXiv-2311.03291-b31b1b.svg"></a>
|
|
50
|
+
<a href="https://www.conventionalcommits.org/en/v1.0.0/"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
|
|
51
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<p align="center">
|
|
55
|
+
<a href="#installation">Installation</a> •
|
|
56
|
+
<a href="#quickstart">Quickstart</a> •
|
|
57
|
+
<a href="https://cosmo-sims.github.io/DISCO-CMB/">Documentation</a> •
|
|
58
|
+
<a href="https://arxiv.org/abs/2311.03291">DISCO-EB paper</a> •
|
|
59
|
+
<a href="#citation">Citation</a>
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
<!-- start:overview -->
|
|
63
|
+
|
|
64
|
+
DISCO-CMB computes CMB angular power spectra for **batches of cosmologies on the GPU**. It builds on the Einstein-Boltzmann solver of [DISCO-EB](https://github.com/cosmo-sims/DISCO-EB) and adds line-of-sight integration, the unlensed TT, TE and EE spectra, the lensing potential and the lensed TT, TE, EE and BB spectra.
|
|
65
|
+
|
|
66
|
+
A single GPU launch evolves every wave mode of every cosmology in a batch, with the line-of-sight sources evaluated inside the solver's kernel. The unlensed TT spectrum agrees with CLASS to 0.25 percent for multipoles 2 to 1200, and JAX can differentiate the spectra with respect to the cosmological parameters.
|
|
67
|
+
|
|
68
|
+
<!-- end:overview -->
|
|
69
|
+
|
|
70
|
+
The [documentation](https://cosmo-sims.github.io/DISCO-CMB/) covers the API
|
|
71
|
+
and explains how the pipeline fits together.
|
|
72
|
+
|
|
73
|
+
## Installation
|
|
74
|
+
|
|
75
|
+
<!-- start:install -->
|
|
76
|
+
|
|
77
|
+
DISCO-CMB needs an NVIDIA GPU. Install it from PyPI, which brings DISCO-EB with it:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install "disco-cmb[cuda13]" # or [cuda12], which Python 3.10 needs
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
<!-- end:install -->
|
|
84
|
+
|
|
85
|
+
## Quickstart
|
|
86
|
+
|
|
87
|
+
<!-- start:quickstart -->
|
|
88
|
+
|
|
89
|
+
This example computes the unlensed spectra of three cosmologies that differ in their spectral index. The grids come from a fiducial cosmology once, and every later batch reuses them:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from discocmb import cmb_grids, compute_cl_power_spectrum_batch
|
|
93
|
+
|
|
94
|
+
planck = {
|
|
95
|
+
"Omegam": 0.3144,
|
|
96
|
+
"Omegab": 0.04939,
|
|
97
|
+
"H0": 67.32,
|
|
98
|
+
"Omegak": 0.0,
|
|
99
|
+
"A_s": 2.1e-9,
|
|
100
|
+
"n_s": 0.966,
|
|
101
|
+
"k_p": 0.05,
|
|
102
|
+
"Tcmb": 2.7255,
|
|
103
|
+
"YHe": 0.2454,
|
|
104
|
+
"Neff": 3.046,
|
|
105
|
+
"Nmnu": 0.0,
|
|
106
|
+
"mnu": 0.0,
|
|
107
|
+
"w_DE_0": -1.0,
|
|
108
|
+
"w_DE_a": 0.0,
|
|
109
|
+
"cs2_DE": 1.0,
|
|
110
|
+
}
|
|
111
|
+
batch = [planck | {"n_s": n_s} for n_s in (0.95, 0.966, 0.98)]
|
|
112
|
+
|
|
113
|
+
grids = cmb_grids(planck)
|
|
114
|
+
ells, cl, dl = compute_cl_power_spectrum_batch(batch, grids=grids)
|
|
115
|
+
dl.tt # (3, n_ell) in muK^2
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
<!-- end:quickstart -->
|
|
119
|
+
|
|
120
|
+
## Development
|
|
121
|
+
|
|
122
|
+
<!-- start:development -->
|
|
123
|
+
|
|
124
|
+
The repository uses [uv](https://docs.astral.sh/uv/):
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git clone https://github.com/cosmo-sims/DISCO-CMB.git
|
|
128
|
+
cd DISCO-CMB && uv sync --extra cuda13 # or --extra cuda12
|
|
129
|
+
uv run pytest tests # needs a CUDA GPU
|
|
130
|
+
uv run ruff format && uv run ruff check --fix
|
|
131
|
+
uv run ty check
|
|
132
|
+
uv run pre-commit install # the checks above, and a commit-message check
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The documentation (Sphinx with MyST and autodoc) builds in an environment of its own, the package plus the docs group:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
export UV_PROJECT_ENVIRONMENT=.venv-docs
|
|
139
|
+
uv sync --no-default-groups --group docs
|
|
140
|
+
uv run --no-sync sphinx-autobuild docs docs/_build/html # live preview
|
|
141
|
+
uv run --no-sync sphinx-build -W docs docs/_build/html # what CI runs
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
<!-- end:development -->
|
|
145
|
+
|
|
146
|
+
## Citation
|
|
147
|
+
|
|
148
|
+
<!-- start:citation -->
|
|
149
|
+
|
|
150
|
+
If you use DISCO-CMB in your research, please cite this repository (see
|
|
151
|
+
[CITATION.cff](https://github.com/cosmo-sims/DISCO-CMB/blob/main/CITATION.cff))
|
|
152
|
+
and the DISCO-EB article it builds on:
|
|
153
|
+
|
|
154
|
+
```bibtex
|
|
155
|
+
@article{DISCO-EB:2024,
|
|
156
|
+
author = "Hahn, Oliver and List, Florian and Porqueres, Natalia",
|
|
157
|
+
title = "{DISCO-DJ I: a differentiable Einstein-Boltzmann solver for cosmology}",
|
|
158
|
+
eprint = "2311.03291",
|
|
159
|
+
archivePrefix = "arXiv",
|
|
160
|
+
primaryClass = "astro-ph.CO",
|
|
161
|
+
doi = "10.1088/1475-7516/2024/06/063",
|
|
162
|
+
journal = "JCAP",
|
|
163
|
+
volume = "06",
|
|
164
|
+
pages = "063",
|
|
165
|
+
year = "2024"
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
<!-- end:citation -->
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
<!-- start:license -->
|
|
174
|
+
|
|
175
|
+
DISCO-CMB is released under the
|
|
176
|
+
[MIT License](https://github.com/cosmo-sims/DISCO-CMB/blob/main/LICENSE).
|
|
177
|
+
|
|
178
|
+
<!-- end:license -->
|