Read the chapter on counting pairs with randoms first. It derives the estimator and the jackknife used here.
Get the files
Download these into one empty folder:
The expected output was made with Python 3.9.6, NumPy 2.0.2 and SciPy 1.13.1. From the folder, run:
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 flag -I keeps Python from importing anything from the current folder. Add --skip-failures to run only the main measurement, which takes about 20 seconds.
What is in the data
The galaxies come from the DESI DR1 large-scale structure catalogue BGS_BRIGHT-21.5 in the South Galactic Cap: bright galaxies with an absolute magnitude cut, the same sample DESI used for its lowest-redshift BAO measurement. The patch keeps right ascension −20∘ to 20∘, declination −10∘ to 10∘ and redshift 0.1≤z<0.4. The randoms come from the first of DESI's random files for the same sample. Inside the patch that file holds 1,043,189 points. The download keeps a random subsample three times the galaxy count, 47,097 points, to stay small.
Each row holds ra_deg, dec_deg, z, weight and weight_fkp. The weight column combines DESI's corrections for completeness and imaging systematics. The FKP column balances the sample against its changing number density. DESI 2024 III says the first is meant for any calculation and the second is included in all two-point measurements, so the script uses their product.
The provenance file records the SHA-256 hashes of both DESI input files and both outputs, and every change made: columns dropped, rows cut to the patch, randoms subsampled with a fixed seed, values rounded. The data are released under CC BY 4.0. If you reuse them, cite the DESI DR1 paper and keep the acknowledgment in the README.
Step 1: redshifts to distances
The script converts each redshift to a comoving distance in DESI's fiducial flat cosmology, Ωm=0.31519, using
The prefactor makes distances come out in h−1Mpc, the unit DESI uses for separations. Radiation is left out, which changes distances below z=0.4 by less than 0.01 percent. Right ascension, declination and distance then give Cartesian positions.
Step 2: weighted pair counts
The script builds k-d trees with SciPy and counts weighted pairs in twenty bins of 10h−1Mpc out to 200h−1Mpc. It counts data with data, data with randoms and randoms with randoms, normalises each by its total weight of pairs, and forms the Landy-Szalay estimate.
For the jackknife it divides the patch into an 8 by 4 grid on the sky. Two of the 32 cells contain no randoms, because they fall outside the DESI footprint, so 30 regions are used. Leaving out an empty region would just repeat the full sample and shrink the error bars.
Step 3: read the correlation function
Open my-result.json at correlation. Each row gives s, ξ, its jackknife error, and the same in s2ξ.
At small separations the signal is strong and the errors are tiny. Near 100h−1Mpc the error in s2ξ is larger than the value itself. Any bump there is hidden.
Step 4: the BAO fit
The fit uses the CLASS template computed for DESI's fiducial cosmology at z=0.295, with the linear power spectrum multiplied by exp(−k2Σ2/2). Here Σ=7.84h−1Mpc is the root mean square of DESI's pre-reconstruction BGS damping scales, 6.5, 6.5 and 10.0h−1Mpc. DESI's own model damps only the oscillating part of the spectrum; this simpler template damps all of it. In s2ξ its bump peaks at 102h−1Mpc. The model is
fitted over 50 to 150h−1Mpc, ten bins, with the jackknife covariance and the Hartlap factor 0.621. For each α from 0.80 to 1.20 the script solves for B≥0 and the broadband terms.
The block fit in the output gives the answer. The best α is 0.80, at the edge of the grid. The Δχ2=1 interval covers the whole grid, so intervalTouchesGridEdge is true. The profile in Δχ2 never rises above 0.15. Adding the template improves χ2 from 1.08 to 0.89, a naive significance of 0.44. This patch leaves α free across the whole grid.
Compare with DESI
DESI 2024 III reports DV/rd=7.93±0.15 at zeff=0.30 for the full BGS sample. The script converts this with the fiducial cosmology, DVfid/rdfid=8.057, into αiso=0.984±0.019, close to the 0.9829±0.0185 that the paper prints in its Table 15. The small difference comes from our use of z=0.295 where Table 18 prints the rounded 0.30, and from our CLASS value of rdfid.
DESI's measurement used 300,017 galaxies over the whole DR1 footprint, an effective volume the paper gives as 1.7Gpc3, and reconstruction. The patch holds 15,699 galaxies in a geometric volume below 0.1h−3Gpc3, which is 0.33Gpc3. For scale, the 2005 SDSS detection used 0.72h−3Gpc3 and reached 3.4σ. The patch has too few pairs at 100h−1Mpc, and its own sample variance is large. That is the lesson of this guide: the BAO is a volume-limited measurement.
Four ways the measurement fails
Each failure case in the output changes one step and repeats the measurement.
Dropping the weights shifts the curve by up to about 33 inside the fit range, comparable to the errors. In a full survey, where errors are ten times smaller, that bias would dominate. Using too few randoms adds noise from the random catalogue itself. The changes of up to 66 are within the errors here, and they grow as the random catalogue shrinks.
Forgetting the normalisation adds the constant offset (m−1)2/m2≈0.44 derived in the pair-counting chapter. Multiplied by s2 it grows into thousands.
Mixing units is the subtlest. With distances in Mpc, every separation is 1/h=1.48 times larger, so the bin labelled 100 holds pairs that are really at 67h−1Mpc, where ξ is higher. Against a template in h−1Mpc, a fit would read a dilation near 0.67 even with perfect data.
None of these fits bound α. In a larger sample, the last two would give wrong answers with small error bars.
What the numbers can support
The measured ξ(s) at separations below about 50h−1Mpc is a real, well-measured property of these galaxies. The covariance comes from 30 jackknife regions that are not identical in size, so it is itself uncertain at the tens-of-percent level. The fit result is only that the patch cannot bound α. The script has no reconstruction, no redshift-space modelling, no systematics weights beyond those in the catalogue, and a monopole-only fit. Those simplifications would matter for a real measurement. They do not change the conclusion here.
Sources: DESI 2024 III, sections 2 and 4 and tables 15 and 18, DESI DR1 data release paper, DESI DR1 large-scale structure catalogue documentation, DESI data licence and acknowledgment, Eisenstein et al. 2005, volume and significance of the first detection.
Export the Lab record and compare its galaxy count and error bars with the DESI patch output.