Pycorr
2-pt correlation function estimation
Install / Use
/learn @cosmodesi/PycorrREADME
pycorr
pycorr is a wrapper for correlation function estimation, designed to handle different two-point counter engines (currently only Corrfunc). It currently supports:
- theta (angular), s, s-mu, rp-pi binning schemes
- analytical two-point counts with periodic boundary conditions
- inverse bitwise weights (in any integer format) and (angular) upweighting
- MPI parallelization (further requires mpi4py and pmesh)
- jackknife estimate of the correlation function covariance matrix
A typical auto-correlation function estimation is as simple as:
import numpy as np
from pycorr import TwoPointCorrelationFunction
edges = (np.linspace(1, 101, 51), np.linspace(0, 50, 51))
# pass e.g. mpicomm = MPI.COMM_WORLD if input positions and weights are MPI-scattered
result = TwoPointCorrelationFunction('rppi', edges, data_positions1=data_positions1, data_weights1=data_weights1,
randoms_positions1=randoms_positions1, randoms_weights1=randoms_weights1,
engine='corrfunc', nthreads=4)
# separation array in result.sep
# correlation function in result.corr
Example notebooks presenting most use cases are provided in directory nb/.
Documentation
Documentation is hosted on Read the Docs, pycorr docs. As mentioned above, you may find more practical guidance in the example notebooks directory.
Requirements
Strict requirements are:
- numpy
- scipy
To use Corrfunc as two-point-counting engine (only engine linked so far):
- https://github.com/cosmodesi/Corrfunc (desi branch, which is the default)
To run with MPI:
- mpi4py
- pmesh
Installation
See pycorr docs.
License
pycorr is free software distributed under a BSD3 license. For details see the LICENSE.
Acknowledgments
- Lehman Garrison and Manodeep Sinha for advice when implementing linear binning, and PIP and angular weights into Corrfunc
- Davide Bianchi for cross-checks of two-point counts with PIP weights
- Svyatoslav Trusov for script to compute jackknife covariance estimates based on https://arxiv.org/pdf/2109.07071.pdf: https://github.com/theonefromnowhere/JK_pycorr/blob/main/CF_JK_ST_conf.py
- Enrique Paillas and Seshadri Nadathur for suggestions about reconstructed 2pcf measurements
- Craig Warner for GPU-izing Corrfunc 'smu' counts
- Misha Rashkovetskyi for rp-cut analytical pair counts
- Craig Warner, James Lasker, Misha Rashkovetskyi and Edmond Chaussidon for spotting typos / bug reports
Citations
If you use pycorr with the Corrfunc engine (default one) for research, please cite the MNRAS Corrfunc code papers with the following
bibtex entries:
@ARTICLE{2020MNRAS.491.3022S,
author = {{Sinha}, Manodeep and {Garrison}, Lehman H.},
title = "{CORRFUNC - a suite of blazing fast correlation functions on
the CPU}",
journal = {\mnras},
keywords = {methods: numerical, galaxies: general, galaxies:
haloes, dark matter, large-scale structure of Universe, cosmology:
theory},
year = "2020",
month = "Jan",
volume = {491},
number = {2},
pages = {3022-3041},
doi = {10.1093/mnras/stz3157},
adsurl =
{https://ui.adsabs.harvard.edu/abs/2020MNRAS.491.3022S},
adsnote = {Provided by the SAO/NASA
Astrophysics Data System}
}
@InProceedings{10.1007/978-981-13-7729-7_1,
author="Sinha, Manodeep and Garrison, Lehman",
editor="Majumdar, Amit and Arora, Ritu",
title="CORRFUNC: Blazing Fast Correlation Functions with AVX512F SIMD Intrinsics",
booktitle="Software Challenges to Exascale Computing",
year="2019",
publisher="Springer Singapore",
address="Singapore",
pages="3--20",
isbn="978-981-13-7729-7",
url={https://doi.org/10.1007/978-981-13-7729-7_1}
}
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
