cmbstack 0.0.2__tar.gz → 0.0.4__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.
- cmbstack-0.0.4/PKG-INFO +63 -0
- cmbstack-0.0.4/README.md +47 -0
- cmbstack-0.0.4/cmbstack.egg-info/PKG-INFO +63 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/pyproject.toml +1 -1
- cmbstack-0.0.2/PKG-INFO +0 -174
- cmbstack-0.0.2/README.md +0 -158
- cmbstack-0.0.2/cmbstack.egg-info/PKG-INFO +0 -174
- {cmbstack-0.0.2 → cmbstack-0.0.4}/cmbstack/__init__.py +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/cmbstack/main.py +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/cmbstack/maps.py +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/cmbstack/stacking.py +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/cmbstack.egg-info/SOURCES.txt +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/cmbstack.egg-info/dependency_links.txt +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/cmbstack.egg-info/requires.txt +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/cmbstack.egg-info/top_level.txt +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/setup.cfg +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/tests/test_find_peaks.py +0 -0
- {cmbstack-0.0.2 → cmbstack-0.0.4}/tests/test_round.py +0 -0
cmbstack-0.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cmbstack
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: Stack patches of the CMB temperature sky around local maxima
|
|
5
|
+
Author-email: Isaac Alexis López Paredes <isaacalexis.lopezparedes@students.uniroma2.eu>, Anushka Sanjay Tilekar <anushka.tilekar.23@alumni.ucl.ac.uk>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/IsaacLP/cmbstack
|
|
8
|
+
Project-URL: Repository, https://github.com/IsaacLP/cmbstack.git
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: healpy
|
|
15
|
+
Requires-Dist: matplotlib
|
|
16
|
+
|
|
17
|
+
[](https://semaphorep.github.io/codeastro/)
|
|
18
|
+
[](https://pypi.org/project/cmbstack/)
|
|
19
|
+
[](https://pypi.org/project/cmbstack/)
|
|
20
|
+
[](https://opensource.org/licenses/MIT)
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
# cmbstack
|
|
24
|
+
|
|
25
|
+
Stack patches of the Cosmic Microwave Background (CMB) temperature sky. Go [here](https://cmbstack-docs.readthedocs.io/en/latest/index.html) to see the full documentation and a worked example.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
Install the latest release from PyPI:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install cmbstack
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or install the development version from GitHub:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
git clone https://github.com/IsaacLP/cmbstack.git
|
|
39
|
+
cd cmbstack
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
**From a power spectrum file:**
|
|
46
|
+
```python
|
|
47
|
+
from cmbstack.main import StackingPipeline
|
|
48
|
+
|
|
49
|
+
pipeline = StackingPipeline.from_cl("path/to/spectrum.cl", nside=1024, seed=42)
|
|
50
|
+
StackedResult = pipeline.run()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**From an existing FITS map:**
|
|
54
|
+
```python
|
|
55
|
+
pipeline = StackingPipeline.from_fits("path/to/map.fits", field=0)
|
|
56
|
+
StackedResult = pipeline.run()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**From a map array already in memory:**
|
|
60
|
+
```python
|
|
61
|
+
pipeline = StackingPipeline.from_map(sky_map)
|
|
62
|
+
StackedResult = pipeline.run()
|
|
63
|
+
```
|
cmbstack-0.0.4/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[](https://semaphorep.github.io/codeastro/)
|
|
2
|
+
[](https://pypi.org/project/cmbstack/)
|
|
3
|
+
[](https://pypi.org/project/cmbstack/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
# cmbstack
|
|
8
|
+
|
|
9
|
+
Stack patches of the Cosmic Microwave Background (CMB) temperature sky. Go [here](https://cmbstack-docs.readthedocs.io/en/latest/index.html) to see the full documentation and a worked example.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the latest release from PyPI:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install cmbstack
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or install the development version from GitHub:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
git clone https://github.com/IsaacLP/cmbstack.git
|
|
23
|
+
cd cmbstack
|
|
24
|
+
pip install -e .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
**From a power spectrum file:**
|
|
30
|
+
```python
|
|
31
|
+
from cmbstack.main import StackingPipeline
|
|
32
|
+
|
|
33
|
+
pipeline = StackingPipeline.from_cl("path/to/spectrum.cl", nside=1024, seed=42)
|
|
34
|
+
StackedResult = pipeline.run()
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**From an existing FITS map:**
|
|
38
|
+
```python
|
|
39
|
+
pipeline = StackingPipeline.from_fits("path/to/map.fits", field=0)
|
|
40
|
+
StackedResult = pipeline.run()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**From a map array already in memory:**
|
|
44
|
+
```python
|
|
45
|
+
pipeline = StackingPipeline.from_map(sky_map)
|
|
46
|
+
StackedResult = pipeline.run()
|
|
47
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cmbstack
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: Stack patches of the CMB temperature sky around local maxima
|
|
5
|
+
Author-email: Isaac Alexis López Paredes <isaacalexis.lopezparedes@students.uniroma2.eu>, Anushka Sanjay Tilekar <anushka.tilekar.23@alumni.ucl.ac.uk>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/IsaacLP/cmbstack
|
|
8
|
+
Project-URL: Repository, https://github.com/IsaacLP/cmbstack.git
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: healpy
|
|
15
|
+
Requires-Dist: matplotlib
|
|
16
|
+
|
|
17
|
+
[](https://semaphorep.github.io/codeastro/)
|
|
18
|
+
[](https://pypi.org/project/cmbstack/)
|
|
19
|
+
[](https://pypi.org/project/cmbstack/)
|
|
20
|
+
[](https://opensource.org/licenses/MIT)
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
# cmbstack
|
|
24
|
+
|
|
25
|
+
Stack patches of the Cosmic Microwave Background (CMB) temperature sky. Go [here](https://cmbstack-docs.readthedocs.io/en/latest/index.html) to see the full documentation and a worked example.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
Install the latest release from PyPI:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install cmbstack
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or install the development version from GitHub:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
git clone https://github.com/IsaacLP/cmbstack.git
|
|
39
|
+
cd cmbstack
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
**From a power spectrum file:**
|
|
46
|
+
```python
|
|
47
|
+
from cmbstack.main import StackingPipeline
|
|
48
|
+
|
|
49
|
+
pipeline = StackingPipeline.from_cl("path/to/spectrum.cl", nside=1024, seed=42)
|
|
50
|
+
StackedResult = pipeline.run()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**From an existing FITS map:**
|
|
54
|
+
```python
|
|
55
|
+
pipeline = StackingPipeline.from_fits("path/to/map.fits", field=0)
|
|
56
|
+
StackedResult = pipeline.run()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**From a map array already in memory:**
|
|
60
|
+
```python
|
|
61
|
+
pipeline = StackingPipeline.from_map(sky_map)
|
|
62
|
+
StackedResult = pipeline.run()
|
|
63
|
+
```
|
cmbstack-0.0.2/PKG-INFO
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: cmbstack
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: Stack patches of the CMB temperature sky around local maxima
|
|
5
|
-
Author-email: Isaac Alexis López Paredes <isaacalexis.lopezparedes@students.uniroma2.eu>, Anushka Sanjay Tilekar <anushka.tilekar.23@alumni.ucl.ac.uk>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/IsaacLP/cmbstack
|
|
8
|
-
Project-URL: Repository, https://github.com/IsaacLP/cmbstack.git
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
Requires-Dist: numpy
|
|
14
|
-
Requires-Dist: healpy
|
|
15
|
-
Requires-Dist: matplotlib
|
|
16
|
-
|
|
17
|
-
[](https://semaphorep.github.io/codeastro/)
|
|
18
|
-
|
|
19
|
-
[](https://semaphorep.github.io/codeastro/)
|
|
20
|
-
[](https://pypi.org/project/cmbstack/)
|
|
21
|
-
[](https://pypi.org/project/cmbstack/)
|
|
22
|
-
[](https://opensource.org/licenses/MIT)
|
|
23
|
-
|
|
24
|
-
# cmbstack
|
|
25
|
-
|
|
26
|
-
`cmbstack` is a Python package for stacking patches of the Cosmic Microwave Background (CMB) temperature sky. It accepts input as a theoretical power spectrum, a [HEALPix](https://healpy.readthedocs.io/en/latest/index.html) FITS file, or a map array already in memory. From there it detects local maxima, extracts gnomonic (flat-sky) patches around each peak, and averages them. This stacking procedure enhances the coherent peak profile while suppressing uncorrelated noise.
|
|
27
|
-
|
|
28
|
-
## Installation
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
pip install cmbstack
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Quick Start
|
|
35
|
-
|
|
36
|
-
**From a power spectrum file:**
|
|
37
|
-
```python
|
|
38
|
-
from cmbstack.main import StackingPipeline
|
|
39
|
-
|
|
40
|
-
pipeline = StackingPipeline.from_cl("path/to/spectrum.dat", nside=1024, seed=42)
|
|
41
|
-
pipeline.run()
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**From an existing FITS map:**
|
|
45
|
-
```python
|
|
46
|
-
pipeline = StackingPipeline.from_fits("path/to/map.fits", field=0)
|
|
47
|
-
pipeline.run()
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**From a map array already in memory:**
|
|
51
|
-
```python
|
|
52
|
-
pipeline = StackingPipeline.from_map(sky_map)
|
|
53
|
-
pipeline.run()
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
See `examples/from_theoretical_cl.ipynb` for a full worked example.
|
|
57
|
-
|
|
58
|
-
## Package Structure
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
cmbstack/
|
|
62
|
-
├── maps.py — power-spectrum loading, map simulation, normalisation
|
|
63
|
-
├── stacking.py — peak finding, patch extraction, stacking, radial profile
|
|
64
|
-
└── main.py — StackingPipeline high-level class
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Workflow
|
|
68
|
-
|
|
69
|
-
> **Note:** Steps 1–2 apply when starting from a power spectrum. Use `StackingPipeline.from_fits` or `from_map` to skip them when working with a real or pre-simulated map.
|
|
70
|
-
|
|
71
|
-
### 1. Load the Power Spectrum — `maps.load_cl`
|
|
72
|
-
|
|
73
|
-
The input file contains the power spectrum as $D_\ell^{TT}$:
|
|
74
|
-
|
|
75
|
-
$$D_\ell \equiv \frac{\ell(\ell+1)}{2\pi} C_\ell$$
|
|
76
|
-
|
|
77
|
-
`load_cl` reads columns $(\ell, D_\ell)$ and converts to $C_\ell$:
|
|
78
|
-
|
|
79
|
-
$$C_\ell = \frac{2\pi}{\ell(\ell+1)} D_\ell, \qquad C_0 = C_1 = 0$$
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
### 2. Simulate a Sky Map — `maps.simulate_map`
|
|
84
|
-
|
|
85
|
-
A Gaussian random realization is drawn by sampling spherical harmonic coefficients $a_{\ell m}$ with variance $C_\ell$:
|
|
86
|
-
|
|
87
|
-
$$T(\hat{n}) = \sum_{\ell,m} a_{\ell m} \, Y_{\ell m}(\hat{n}), \qquad \langle |a_{\ell m}|^2 \rangle = C_\ell$$
|
|
88
|
-
|
|
89
|
-
This calls `healpy.synfast` internally. An optional `seed` makes runs reproducible.
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
### 3. Normalise the Map — `maps.normalize_map`
|
|
94
|
-
|
|
95
|
-
Before peak detection, the map is standardised so that thresholds have a clear statistical meaning:
|
|
96
|
-
|
|
97
|
-
$$T_{\text{norm}}(\hat{n}) = \frac{T(\hat{n}) - \langle T \rangle}{\sigma}$$
|
|
98
|
-
|
|
99
|
-
After this step the map has mean $\approx 0$ and standard deviation $= 1$, so peaks are measured in units of $\sigma$.
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
### 4. Detect Peaks — `stacking.find_peaks`
|
|
104
|
-
|
|
105
|
-
Local maxima are identified with `healpy.hotspots`: a pixel is a maximum if its value exceeds every immediate HEALPix neighbour. Peaks are filtered by a significance threshold $\nu$ (default $\nu = 3\sigma$) and optionally capped at the $N$ highest:
|
|
106
|
-
|
|
107
|
-
$$\text{Peaks} = \{\hat{n}_p \in \text{Maxima} \mid T_{\text{norm}}(\hat{n}_p) > \nu\}$$
|
|
108
|
-
|
|
109
|
-
Returns sky positions as $(θ, φ)$ pairs in radians.
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
### 5. Extract Patches — `stacking.extract_patches`
|
|
114
|
-
|
|
115
|
-
For each peak a square patch is cut using a gnomonic (tangent-plane) projection centred on $\hat{n}_p$. Every patch shares the same fixed pixel grid (side length `size_deg`, pixel scale `reso_arcmin`), so the centre pixel always corresponds to the peak itself and patches can be co-added directly.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
### 6. Stack — `stacking.stack_patches`
|
|
120
|
-
|
|
121
|
-
Patches are averaged pixel-by-pixel:
|
|
122
|
-
|
|
123
|
-
$$S = \frac{1}{N} \sum_{i=1}^{N} P_i$$
|
|
124
|
-
|
|
125
|
-
Incoherent noise averages towards zero; the coherent central profile survives.
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
### 7. Radial Profile — `stacking.radial_profile`
|
|
130
|
-
|
|
131
|
-
The 2D stacked image is collapsed to a 1D profile by azimuthal averaging in concentric annuli about the centre. Returns bin-centre radii in arcminutes and the mean temperature in each annulus.
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## Pipeline Constructors
|
|
136
|
-
|
|
137
|
-
`StackingPipeline` provides three entry points depending on where your data comes from:
|
|
138
|
-
|
|
139
|
-
| Constructor | Input | Notes |
|
|
140
|
-
|---|---|---|
|
|
141
|
-
| `from_cl(path, nside, seed)` | Power-spectrum file | Simulates a Gaussian random map via `healpy.synfast` |
|
|
142
|
-
| `from_fits(path, field=0)` | HEALPix FITS file | Loads the map with `maps.load_map`; `nside` is inferred automatically |
|
|
143
|
-
| `from_map(sky_map)` | NumPy array | Accepts any in-memory HEALPix map; `nside` is inferred automatically |
|
|
144
|
-
|
|
145
|
-
All three store the map in `pipeline.map` and share the same `run()` interface.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## Map I/O Utilities
|
|
150
|
-
|
|
151
|
-
`maps.load_map` and `maps.save_map` wrap the healpy FITS readers for convenience:
|
|
152
|
-
|
|
153
|
-
```python
|
|
154
|
-
from cmbstack import maps
|
|
155
|
-
|
|
156
|
-
m = maps.load_map("map.fits", field=0) # wraps hp.read_map
|
|
157
|
-
maps.save_map("out.fits", m) # wraps hp.write_map (overwrite=True by default)
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Pipeline Object
|
|
163
|
-
|
|
164
|
-
`StackingPipeline` stores every intermediate product as an attribute:
|
|
165
|
-
|
|
166
|
-
| Attribute | Content |
|
|
167
|
-
|---|---|
|
|
168
|
-
| `pipeline.map` | Raw simulated map |
|
|
169
|
-
| `pipeline.normalized` | Normalised map (units of $\sigma$) |
|
|
170
|
-
| `pipeline.positions` | Peak positions $(θ, φ)$ in radians |
|
|
171
|
-
| `pipeline.patches` | List of 2D gnomonic patches |
|
|
172
|
-
| `pipeline.stacked` | Mean stacked 2D image |
|
|
173
|
-
| `pipeline.radius` | Radial bin centres (arcmin) |
|
|
174
|
-
| `pipeline.profile` | Mean temperature per radial bin |
|
cmbstack-0.0.2/README.md
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
[](https://semaphorep.github.io/codeastro/)
|
|
2
|
-
|
|
3
|
-
[](https://semaphorep.github.io/codeastro/)
|
|
4
|
-
[](https://pypi.org/project/cmbstack/)
|
|
5
|
-
[](https://pypi.org/project/cmbstack/)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
|
|
8
|
-
# cmbstack
|
|
9
|
-
|
|
10
|
-
`cmbstack` is a Python package for stacking patches of the Cosmic Microwave Background (CMB) temperature sky. It accepts input as a theoretical power spectrum, a [HEALPix](https://healpy.readthedocs.io/en/latest/index.html) FITS file, or a map array already in memory. From there it detects local maxima, extracts gnomonic (flat-sky) patches around each peak, and averages them. This stacking procedure enhances the coherent peak profile while suppressing uncorrelated noise.
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
pip install cmbstack
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
19
|
-
|
|
20
|
-
**From a power spectrum file:**
|
|
21
|
-
```python
|
|
22
|
-
from cmbstack.main import StackingPipeline
|
|
23
|
-
|
|
24
|
-
pipeline = StackingPipeline.from_cl("path/to/spectrum.dat", nside=1024, seed=42)
|
|
25
|
-
pipeline.run()
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**From an existing FITS map:**
|
|
29
|
-
```python
|
|
30
|
-
pipeline = StackingPipeline.from_fits("path/to/map.fits", field=0)
|
|
31
|
-
pipeline.run()
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**From a map array already in memory:**
|
|
35
|
-
```python
|
|
36
|
-
pipeline = StackingPipeline.from_map(sky_map)
|
|
37
|
-
pipeline.run()
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
See `examples/from_theoretical_cl.ipynb` for a full worked example.
|
|
41
|
-
|
|
42
|
-
## Package Structure
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
cmbstack/
|
|
46
|
-
├── maps.py — power-spectrum loading, map simulation, normalisation
|
|
47
|
-
├── stacking.py — peak finding, patch extraction, stacking, radial profile
|
|
48
|
-
└── main.py — StackingPipeline high-level class
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Workflow
|
|
52
|
-
|
|
53
|
-
> **Note:** Steps 1–2 apply when starting from a power spectrum. Use `StackingPipeline.from_fits` or `from_map` to skip them when working with a real or pre-simulated map.
|
|
54
|
-
|
|
55
|
-
### 1. Load the Power Spectrum — `maps.load_cl`
|
|
56
|
-
|
|
57
|
-
The input file contains the power spectrum as $D_\ell^{TT}$:
|
|
58
|
-
|
|
59
|
-
$$D_\ell \equiv \frac{\ell(\ell+1)}{2\pi} C_\ell$$
|
|
60
|
-
|
|
61
|
-
`load_cl` reads columns $(\ell, D_\ell)$ and converts to $C_\ell$:
|
|
62
|
-
|
|
63
|
-
$$C_\ell = \frac{2\pi}{\ell(\ell+1)} D_\ell, \qquad C_0 = C_1 = 0$$
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
### 2. Simulate a Sky Map — `maps.simulate_map`
|
|
68
|
-
|
|
69
|
-
A Gaussian random realization is drawn by sampling spherical harmonic coefficients $a_{\ell m}$ with variance $C_\ell$:
|
|
70
|
-
|
|
71
|
-
$$T(\hat{n}) = \sum_{\ell,m} a_{\ell m} \, Y_{\ell m}(\hat{n}), \qquad \langle |a_{\ell m}|^2 \rangle = C_\ell$$
|
|
72
|
-
|
|
73
|
-
This calls `healpy.synfast` internally. An optional `seed` makes runs reproducible.
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
### 3. Normalise the Map — `maps.normalize_map`
|
|
78
|
-
|
|
79
|
-
Before peak detection, the map is standardised so that thresholds have a clear statistical meaning:
|
|
80
|
-
|
|
81
|
-
$$T_{\text{norm}}(\hat{n}) = \frac{T(\hat{n}) - \langle T \rangle}{\sigma}$$
|
|
82
|
-
|
|
83
|
-
After this step the map has mean $\approx 0$ and standard deviation $= 1$, so peaks are measured in units of $\sigma$.
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
### 4. Detect Peaks — `stacking.find_peaks`
|
|
88
|
-
|
|
89
|
-
Local maxima are identified with `healpy.hotspots`: a pixel is a maximum if its value exceeds every immediate HEALPix neighbour. Peaks are filtered by a significance threshold $\nu$ (default $\nu = 3\sigma$) and optionally capped at the $N$ highest:
|
|
90
|
-
|
|
91
|
-
$$\text{Peaks} = \{\hat{n}_p \in \text{Maxima} \mid T_{\text{norm}}(\hat{n}_p) > \nu\}$$
|
|
92
|
-
|
|
93
|
-
Returns sky positions as $(θ, φ)$ pairs in radians.
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
### 5. Extract Patches — `stacking.extract_patches`
|
|
98
|
-
|
|
99
|
-
For each peak a square patch is cut using a gnomonic (tangent-plane) projection centred on $\hat{n}_p$. Every patch shares the same fixed pixel grid (side length `size_deg`, pixel scale `reso_arcmin`), so the centre pixel always corresponds to the peak itself and patches can be co-added directly.
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
### 6. Stack — `stacking.stack_patches`
|
|
104
|
-
|
|
105
|
-
Patches are averaged pixel-by-pixel:
|
|
106
|
-
|
|
107
|
-
$$S = \frac{1}{N} \sum_{i=1}^{N} P_i$$
|
|
108
|
-
|
|
109
|
-
Incoherent noise averages towards zero; the coherent central profile survives.
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
### 7. Radial Profile — `stacking.radial_profile`
|
|
114
|
-
|
|
115
|
-
The 2D stacked image is collapsed to a 1D profile by azimuthal averaging in concentric annuli about the centre. Returns bin-centre radii in arcminutes and the mean temperature in each annulus.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Pipeline Constructors
|
|
120
|
-
|
|
121
|
-
`StackingPipeline` provides three entry points depending on where your data comes from:
|
|
122
|
-
|
|
123
|
-
| Constructor | Input | Notes |
|
|
124
|
-
|---|---|---|
|
|
125
|
-
| `from_cl(path, nside, seed)` | Power-spectrum file | Simulates a Gaussian random map via `healpy.synfast` |
|
|
126
|
-
| `from_fits(path, field=0)` | HEALPix FITS file | Loads the map with `maps.load_map`; `nside` is inferred automatically |
|
|
127
|
-
| `from_map(sky_map)` | NumPy array | Accepts any in-memory HEALPix map; `nside` is inferred automatically |
|
|
128
|
-
|
|
129
|
-
All three store the map in `pipeline.map` and share the same `run()` interface.
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Map I/O Utilities
|
|
134
|
-
|
|
135
|
-
`maps.load_map` and `maps.save_map` wrap the healpy FITS readers for convenience:
|
|
136
|
-
|
|
137
|
-
```python
|
|
138
|
-
from cmbstack import maps
|
|
139
|
-
|
|
140
|
-
m = maps.load_map("map.fits", field=0) # wraps hp.read_map
|
|
141
|
-
maps.save_map("out.fits", m) # wraps hp.write_map (overwrite=True by default)
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## Pipeline Object
|
|
147
|
-
|
|
148
|
-
`StackingPipeline` stores every intermediate product as an attribute:
|
|
149
|
-
|
|
150
|
-
| Attribute | Content |
|
|
151
|
-
|---|---|
|
|
152
|
-
| `pipeline.map` | Raw simulated map |
|
|
153
|
-
| `pipeline.normalized` | Normalised map (units of $\sigma$) |
|
|
154
|
-
| `pipeline.positions` | Peak positions $(θ, φ)$ in radians |
|
|
155
|
-
| `pipeline.patches` | List of 2D gnomonic patches |
|
|
156
|
-
| `pipeline.stacked` | Mean stacked 2D image |
|
|
157
|
-
| `pipeline.radius` | Radial bin centres (arcmin) |
|
|
158
|
-
| `pipeline.profile` | Mean temperature per radial bin |
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: cmbstack
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: Stack patches of the CMB temperature sky around local maxima
|
|
5
|
-
Author-email: Isaac Alexis López Paredes <isaacalexis.lopezparedes@students.uniroma2.eu>, Anushka Sanjay Tilekar <anushka.tilekar.23@alumni.ucl.ac.uk>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/IsaacLP/cmbstack
|
|
8
|
-
Project-URL: Repository, https://github.com/IsaacLP/cmbstack.git
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
Requires-Dist: numpy
|
|
14
|
-
Requires-Dist: healpy
|
|
15
|
-
Requires-Dist: matplotlib
|
|
16
|
-
|
|
17
|
-
[](https://semaphorep.github.io/codeastro/)
|
|
18
|
-
|
|
19
|
-
[](https://semaphorep.github.io/codeastro/)
|
|
20
|
-
[](https://pypi.org/project/cmbstack/)
|
|
21
|
-
[](https://pypi.org/project/cmbstack/)
|
|
22
|
-
[](https://opensource.org/licenses/MIT)
|
|
23
|
-
|
|
24
|
-
# cmbstack
|
|
25
|
-
|
|
26
|
-
`cmbstack` is a Python package for stacking patches of the Cosmic Microwave Background (CMB) temperature sky. It accepts input as a theoretical power spectrum, a [HEALPix](https://healpy.readthedocs.io/en/latest/index.html) FITS file, or a map array already in memory. From there it detects local maxima, extracts gnomonic (flat-sky) patches around each peak, and averages them. This stacking procedure enhances the coherent peak profile while suppressing uncorrelated noise.
|
|
27
|
-
|
|
28
|
-
## Installation
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
pip install cmbstack
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Quick Start
|
|
35
|
-
|
|
36
|
-
**From a power spectrum file:**
|
|
37
|
-
```python
|
|
38
|
-
from cmbstack.main import StackingPipeline
|
|
39
|
-
|
|
40
|
-
pipeline = StackingPipeline.from_cl("path/to/spectrum.dat", nside=1024, seed=42)
|
|
41
|
-
pipeline.run()
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**From an existing FITS map:**
|
|
45
|
-
```python
|
|
46
|
-
pipeline = StackingPipeline.from_fits("path/to/map.fits", field=0)
|
|
47
|
-
pipeline.run()
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**From a map array already in memory:**
|
|
51
|
-
```python
|
|
52
|
-
pipeline = StackingPipeline.from_map(sky_map)
|
|
53
|
-
pipeline.run()
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
See `examples/from_theoretical_cl.ipynb` for a full worked example.
|
|
57
|
-
|
|
58
|
-
## Package Structure
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
cmbstack/
|
|
62
|
-
├── maps.py — power-spectrum loading, map simulation, normalisation
|
|
63
|
-
├── stacking.py — peak finding, patch extraction, stacking, radial profile
|
|
64
|
-
└── main.py — StackingPipeline high-level class
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Workflow
|
|
68
|
-
|
|
69
|
-
> **Note:** Steps 1–2 apply when starting from a power spectrum. Use `StackingPipeline.from_fits` or `from_map` to skip them when working with a real or pre-simulated map.
|
|
70
|
-
|
|
71
|
-
### 1. Load the Power Spectrum — `maps.load_cl`
|
|
72
|
-
|
|
73
|
-
The input file contains the power spectrum as $D_\ell^{TT}$:
|
|
74
|
-
|
|
75
|
-
$$D_\ell \equiv \frac{\ell(\ell+1)}{2\pi} C_\ell$$
|
|
76
|
-
|
|
77
|
-
`load_cl` reads columns $(\ell, D_\ell)$ and converts to $C_\ell$:
|
|
78
|
-
|
|
79
|
-
$$C_\ell = \frac{2\pi}{\ell(\ell+1)} D_\ell, \qquad C_0 = C_1 = 0$$
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
### 2. Simulate a Sky Map — `maps.simulate_map`
|
|
84
|
-
|
|
85
|
-
A Gaussian random realization is drawn by sampling spherical harmonic coefficients $a_{\ell m}$ with variance $C_\ell$:
|
|
86
|
-
|
|
87
|
-
$$T(\hat{n}) = \sum_{\ell,m} a_{\ell m} \, Y_{\ell m}(\hat{n}), \qquad \langle |a_{\ell m}|^2 \rangle = C_\ell$$
|
|
88
|
-
|
|
89
|
-
This calls `healpy.synfast` internally. An optional `seed` makes runs reproducible.
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
### 3. Normalise the Map — `maps.normalize_map`
|
|
94
|
-
|
|
95
|
-
Before peak detection, the map is standardised so that thresholds have a clear statistical meaning:
|
|
96
|
-
|
|
97
|
-
$$T_{\text{norm}}(\hat{n}) = \frac{T(\hat{n}) - \langle T \rangle}{\sigma}$$
|
|
98
|
-
|
|
99
|
-
After this step the map has mean $\approx 0$ and standard deviation $= 1$, so peaks are measured in units of $\sigma$.
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
### 4. Detect Peaks — `stacking.find_peaks`
|
|
104
|
-
|
|
105
|
-
Local maxima are identified with `healpy.hotspots`: a pixel is a maximum if its value exceeds every immediate HEALPix neighbour. Peaks are filtered by a significance threshold $\nu$ (default $\nu = 3\sigma$) and optionally capped at the $N$ highest:
|
|
106
|
-
|
|
107
|
-
$$\text{Peaks} = \{\hat{n}_p \in \text{Maxima} \mid T_{\text{norm}}(\hat{n}_p) > \nu\}$$
|
|
108
|
-
|
|
109
|
-
Returns sky positions as $(θ, φ)$ pairs in radians.
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
### 5. Extract Patches — `stacking.extract_patches`
|
|
114
|
-
|
|
115
|
-
For each peak a square patch is cut using a gnomonic (tangent-plane) projection centred on $\hat{n}_p$. Every patch shares the same fixed pixel grid (side length `size_deg`, pixel scale `reso_arcmin`), so the centre pixel always corresponds to the peak itself and patches can be co-added directly.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
### 6. Stack — `stacking.stack_patches`
|
|
120
|
-
|
|
121
|
-
Patches are averaged pixel-by-pixel:
|
|
122
|
-
|
|
123
|
-
$$S = \frac{1}{N} \sum_{i=1}^{N} P_i$$
|
|
124
|
-
|
|
125
|
-
Incoherent noise averages towards zero; the coherent central profile survives.
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
### 7. Radial Profile — `stacking.radial_profile`
|
|
130
|
-
|
|
131
|
-
The 2D stacked image is collapsed to a 1D profile by azimuthal averaging in concentric annuli about the centre. Returns bin-centre radii in arcminutes and the mean temperature in each annulus.
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## Pipeline Constructors
|
|
136
|
-
|
|
137
|
-
`StackingPipeline` provides three entry points depending on where your data comes from:
|
|
138
|
-
|
|
139
|
-
| Constructor | Input | Notes |
|
|
140
|
-
|---|---|---|
|
|
141
|
-
| `from_cl(path, nside, seed)` | Power-spectrum file | Simulates a Gaussian random map via `healpy.synfast` |
|
|
142
|
-
| `from_fits(path, field=0)` | HEALPix FITS file | Loads the map with `maps.load_map`; `nside` is inferred automatically |
|
|
143
|
-
| `from_map(sky_map)` | NumPy array | Accepts any in-memory HEALPix map; `nside` is inferred automatically |
|
|
144
|
-
|
|
145
|
-
All three store the map in `pipeline.map` and share the same `run()` interface.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## Map I/O Utilities
|
|
150
|
-
|
|
151
|
-
`maps.load_map` and `maps.save_map` wrap the healpy FITS readers for convenience:
|
|
152
|
-
|
|
153
|
-
```python
|
|
154
|
-
from cmbstack import maps
|
|
155
|
-
|
|
156
|
-
m = maps.load_map("map.fits", field=0) # wraps hp.read_map
|
|
157
|
-
maps.save_map("out.fits", m) # wraps hp.write_map (overwrite=True by default)
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Pipeline Object
|
|
163
|
-
|
|
164
|
-
`StackingPipeline` stores every intermediate product as an attribute:
|
|
165
|
-
|
|
166
|
-
| Attribute | Content |
|
|
167
|
-
|---|---|
|
|
168
|
-
| `pipeline.map` | Raw simulated map |
|
|
169
|
-
| `pipeline.normalized` | Normalised map (units of $\sigma$) |
|
|
170
|
-
| `pipeline.positions` | Peak positions $(θ, φ)$ in radians |
|
|
171
|
-
| `pipeline.patches` | List of 2D gnomonic patches |
|
|
172
|
-
| `pipeline.stacked` | Mean stacked 2D image |
|
|
173
|
-
| `pipeline.radius` | Radial bin centres (arcmin) |
|
|
174
|
-
| `pipeline.profile` | Mean temperature per radial bin |
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|