cmbstack
cmbstack is a Python package for stacking patches of HEALPix maps, such as the Cosmic Microwave Background (CMB) temperature, CMB lensing convergence or galaxy density. It accepts as input a theoretical power spectrum, a HEALPix FITS file, or a map array already in memory, which can be masked. It stacks either on the local maxima of the map or on the positions of an external catalogue, with an optional rotation for each patch. It extracts gnomonic (flat-sky) patches around each position and averages them. This stacking procedure enhances the coherent profile while suppressing uncorrelated noise.
The tutorials below are worked examples. The notebooks and the files required to run them can be downloaded here:
Simulated map: every step of the pipeline on a simulated CMB temperature map.
Planck peak stacking: peak stacking on the masked Planck SMICA map.
Oriented stacking on filaments: stacking an SDSS galaxy overdensity map on a cosmic filament catalogue, with each patch rotated along its filament.
User guide
Changelog
v0.2.0
Breaking changes
Sky positions are now
(lon, lat)in degrees everywhere (find_peaks,extract_patches,StackingPipeline.run), instead of(theta, phi)in radians.
New features
StackingPipeline.runaccepts externalpositions(previously only possible by callingextract_patchesdirectly) and per-patch rotation anglespsi, for oriented stacking.Rectangular patches:
size_deg_yinextract_patchesandrun(), withsize_degas the side along x.size_mpc_to_degconverts a physical size in Mpc to an angle at redshift z, for an astropy cosmology.Masked maps:
from_mapkeeps the mask of anhp.maarray.normalize_mapcomputes the mean and std on unmasked pixels only, including for float32 maps.Masked pixels become NaN in the patches.
Per-pixel hit counts:
stack_patchesdivides each pixel by the number of patches with a valid value there, takesmin_count, and can return the count map (return_counts=True,pipeline.counts).find_peaksdrops peaks next to the mask, andmask_distance_degwidens the cut.return_n_rejected=True,run(verbose=True)andpipeline.n_rejectedreport how many were dropped.Streaming:
iter_patchesyields one patch at a time,stack_patchesaccepts any iterable, andrun(keep_patches=False)stacks any number of positions in constant memory.
Other changes
extract_patchesusesGnomonicProjdirectly, which is faster because it no longer creates a matplotlib figure per patch.run()raises a clearValueErrorwhen no peaks are found.New tutorials: peak stacking on the Planck SMICA map, and oriented stacking of an SDSS galaxy overdensity map on a cosmic filament catalogue.
v0.1.1
load_clreads the chosen column with pandas.Runtime test placeholder moved to
tests/test_runtime.py.