# Measure a correlation function from a DESI DR1 patch

Put every file of this folder in one new folder and run, inside it:

```sh
python3 -m venv bao-env
bao-env/bin/pip install -r requirements.txt
bao-env/bin/python -I measure_desi_patch_correlation.py --output my-result.json
```

The expected output `desi-patch-expected-output.json` was produced with Python 3.9.6, NumPy 2.0.2 and SciPy 1.13.1 in about 1.5 minutes. Add `--skip-failures` to run only the main measurement. Separations are in h^-1 Mpc in the DESI DR1 fiducial flat LCDM cosmology (Omega_m = 0.31519). The step-by-step guide is at https://sandboxphysics.com/stories/baryon-acoustic-oscillations/measure-a-desi-patch-correlation-function/.

## Files and what kind of data they are

| File | Kind |
| --- | --- |
| `desi-dr1-bgs-sgc-patch-galaxies.csv` | real DESI DR1 data, modified subset (15,699 galaxies) |
| `desi-dr1-bgs-sgc-patch-randoms.csv` | DESI DR1 random catalogue, modified subset (47,097 points) |
| `desi-patch-provenance.json` | source files, SHA-256 hashes and the list of changes |
| `bao-template-desi-fiducial.csv` | offline CLASS v3.4.2 calculation; an ideal reference, not data |
| `measure_desi_patch_correlation.py` | the analysis script |
| `desi-patch-expected-output.json` | the script's saved output |

The patch cannot detect the BAO feature: the fit does not bound the dilation and the naive peak significance is 0.44. That is the expected result for 15,699 galaxies.

## Data source, licence and changes

The galaxy and random catalogues are derived from the DESI Data Release 1 large-scale structure catalogues v1.5 (iron), sample BGS_BRIGHT-21.5, South Galactic Cap: https://data.desi.lbl.gov/public/dr1/survey/catalogs/dr1/LSS/iron/LSScats/v1.5/. DESI data are released under the Creative Commons Attribution 4.0 International licence (CC BY 4.0, https://creativecommons.org/licenses/by/4.0/).

Please cite: DESI Collaboration et al. (2026), "Data Release 1 of the Dark Energy Spectroscopic Instrument", arXiv:2503.14745.

Changes made to the DESI files: kept only the columns RA, DEC, Z, WEIGHT and WEIGHT_FKP; kept only rows with -20 <= RA < 20 deg, -10 <= Dec < 10 deg and 0.1 <= z < 0.4; subsampled the randoms from random file 0 to three times the galaxy count with numpy default_rng(6502); rounded RA, Dec and z to 6 decimals and weights to 6 significant digits. `desi-patch-provenance.json` records the hashes of the inputs and outputs.

The patch was cut from the two DESI FITS files by `scripts/astronomy/ac65/freeze_desi_patch.py` in the Sandbox Physics source repository; it needs NumPy only.

Acknowledgment, as requested by DESI:

This research used data obtained with the Dark Energy Spectroscopic Instrument (DESI). DESI construction and operations is managed by the Lawrence Berkeley National Laboratory. This material is based upon work supported by the U.S. Department of Energy, Office of Science, Office of High-Energy Physics, under Contract No. DE–AC02–05CH11231, and by the National Energy Research Scientific Computing Center, a DOE Office of Science User Facility under the same contract. Additional support for DESI was provided by the U.S. National Science Foundation (NSF), Division of Astronomical Sciences under Contract No. AST-0950945 to the NSF’s National Optical-Infrared Astronomy Research Laboratory; the Science and Technology Facilities Council of the United Kingdom; the Gordon and Betty Moore Foundation; the Heising-Simons Foundation; the French Alternative Energies and Atomic Energy Commission (CEA); the National Council of Humanities, Science and Technology of Mexico (CONAHCYT); the Ministry of Science and Innovation of Spain (MICINN), and by the DESI Member Institutions: www.desi.lbl.gov/collaborating-institutions. The DESI collaboration is honored to be permitted to conduct scientific research on I’oligam Du’ag (Kitt Peak), a mountain with particular significance to the Tohono O’odham Nation. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the U.S. National Science Foundation, the U.S. Department of Energy, or any of the listed funding agencies.

## 中文

把本文件夹的全部文件放进一个新文件夹，在其中运行上面三行命令。预期输出用 Python 3.9.6、NumPy 2.0.2 和 SciPy 1.13.1 生成，约需一分半钟；加 `--skip-failures` 只跑主测量。间距单位是 h^-1 Mpc，采用 DESI DR1 的基准平直 LCDM 宇宙学（Omega_m = 0.31519）。

星系和随机星表取自 DESI DR1 大尺度结构星表 v1.5（iron）的 BGS_BRIGHT-21.5 南银冠样本，是经过修改的子集：只保留五列，只保留天区内的行，随机点抽样到星系数的三倍，数值做了舍入；切片脚本是 Sandbox Physics 源码库里的 `scripts/astronomy/ac65/freeze_desi_patch.py`，只需要 NumPy。数据按 CC BY 4.0 许可发布；再次使用时请引用上面的 DESI DR1 论文，并保留上面的英文致谢原文。BAO 模板是离线 CLASS 计算的理想参照，不是数据。这块天区测不出 BAO：拟合约束不住伸缩参数，粗略显著性只有 0.44，这正是 15,699 个星系应有的结果。
