Skip to main content
Sandbox Physics
Weak gravitational lensing and mass maps

Recompute shear correlations and tomography from a simulation

Sandbox Physics ·

This guide measures the shear correlation functions ξ±\xi_\pm in two redshift bins from 24 restricted simulations and compares them with two predictions. It recovers the Einstein radius of an isothermal halo from 200 noisy catalogs without measurable bias, then breaks the analysis on purpose: shapes rotated by 45∘45^\circ flip the sign of ξ−\xi_-, and moving 20 percent of far galaxies into the near bin raises the near-bin signal by 42 percent. Every number comes from one script that runs in under ten seconds. Nothing here is survey data.

Read shear correlation functions and redshift tomography and turning a shear field into a mass map first.

Get the files

Put these ten files in one empty folder:

Then run:

python3 -m pip install numpy scipy
python3 reproduce.py

The script writes outputs/computed-outputs.json, compares every number with expected-outputs.json at a relative tolerance of 10−610^{-6} and prints PASS or the mismatches. We ran it with Python 3.9.6, numpy 2.0.2 and scipy 1.13.1. Another numpy version may draw different random numbers; then python3 reproduce.py --write-expected saves your own outputs, and the statistics below should stay close.

What the simulation contains

Table 5.1 Units and settings shared by every script.
QuantitySetting
Anglesarcminutes; multipoles ℓ\ell per radian
Distancescomoving, in units of c/H0c/H_0, flat universe with Ωm=0.3\Omega_{\rm m}=0.3
Grid512×512512\times512 pixels of 0.5′0.5', periodic, so a 256′256' square
Lens planesz=0.25z=0.25, 0.50.5, 0.80.8, independent Gaussian fields
Plane spectrumP(ℓ)=6×10−10 (ℓ/1000)−1.2 e−(ℓ/6000)2P(\ell)=6\times10^{-10}\,(\ell/1000)^{-1.2}\,e^{-(\ell/6000)^2}
Shearγ^=e2iβκ^\hat\gamma=e^{2i\beta}\hat\kappa on the grid, mean set to zero
Shapesϵ=ϵs+γ\epsilon=\epsilon^{\rm s}+\gamma, with σϵ=0.26\sigma_\epsilon=0.26 per component
Source binszs=0.6z_{\rm s}=0.6 and 1.21.2, 10 galaxies per square arcminute each
Realizations24, seeds 6701 to 6724

Each bin's convergence is the weighted sum of the three planes, with weight (1+zl)χl(χs−χl)/χs(1+z_{\rm l})\chi_{\rm l}(\chi_{\rm s}-\chi_{\rm l})/\chi_{\rm s} from the lensing kernel. Cosmology with cosmic shear observations: a review, Eqs. 21-24 The overall constant is absorbed into the plane amplitude.

This is a restricted simulation. It has no N-body structure, no nonlinear clustering, no correlation between planes, no masks, no point-spread function, no intrinsic alignments and a single redshift per bin. The shapes use the weak-shear limit, which drops terms of order κγ\kappa\gamma.

The estimator

Each galaxy is assigned to a pixel. Summing ellipticities per pixel and correlating the sums with fast Fourier transforms gives, for every lag Δ\boldsymbol\Delta on the periodic grid,

ξ+(θ)=Re∑ϵa∗ ϵbNpairs,ξ−(θ)=Re∑ϵa ϵb e−4iϕΔNpairs,\xi_+(\theta)=\frac{\mathrm{Re}\sum\epsilon_a^*\,\epsilon_b}{N_{\rm pairs}},\qquad \xi_-(\theta)=\frac{\mathrm{Re}\sum\epsilon_a\,\epsilon_b\,e^{-4i\phi_\Delta}}{N_{\rm pairs}},

summed over lags in each angular bin from 1′1' to 40′40'. Zero lag, which holds every galaxy paired with itself and therefore the shape noise, is excluded. This is the pair estimator of the review with unit weights. Cosmology with cosmic shear observations: a review, Eq. 33

Two predictions

The grid expectation is the exact mean the estimator must return on this periodic grid. It sums the input power spectrum over the grid's own wave vectors, with the same pair weights per lag. The continuous prediction is the flat-sky Hankel transform ξ±=(2π)−1∫dℓ ℓ J0,4(ℓθ)P(ℓ)\xi_\pm=(2\pi)^{-1}\int\mathrm d\ell\,\ell\,J_{0,4}(\ell\theta)P(\ell), computed with adaptive quadrature. Cosmology with cosmic shear observations: a review, Eq. 35 Both are multiplied by the tomographic weight of each bin pair.

Table 5.2 Tomographic weights from the plane weights WipW_{ip}.
Correlation∑pWipWjp\sum_pW_{ip}W_{jp}
Near bin, zs=0.6z_{\rm s}=0.60.319
Far bin, zs=1.2z_{\rm s}=1.22.277
Near with far0.606
Table 5.3 Measured against the grid expectation: diagonal χ2\chi^2 over 8 angular bins, using the standard error of the 24-field mean.
Correlationχ2\chi^2 for ξ+\xi_+χ2\chi^2 for ξ−\xi_-
Near bin6.07.1
Far bin12.34.1
Near with far15.64.9

Neighbouring angular bins share structures, so the eight terms are correlated. These χ2\chi^2 values ignore that and are a guide, not a goodness-of-fit test. 15.615.6 for 8 independent bins would have p≈0.05p\approx0.05; we did not estimate the covariance needed to decide whether the cross-correlation ξ+\xi_+ is in mild tension or simply correlated.

The two predictions disagree at large separations for ξ+\xi_+, and they should. At 33′33' the far-bin grid expectation is 2.10×10−52.10\times10^{-5} and the Hankel value is 4.51×10−54.51\times10^{-5}; the measurement is (2.74±0.50)×10−5(2.74\pm0.50)\times10^{-5}. The 256′256' box contains no wave vector below ℓ=2π/256′≈84\ell=2\pi/256'\approx84, and J0J_0 gives those long waves a large weight at large θ\theta. J4J_4 suppresses them, so for ξ−\xi_- the predictions agree to 2 percent at 33′33'. A finite field measures the finite-field expectation.

Failure cases kept on purpose

Shapes rotated by 45 degrees. Replacing every far-bin ellipticity by iϵi\epsilon leaves ξ+\xi_+ identical to the last digit and flips the sign of ξ−\xi_-: at 5.2′5.2' it goes from +9.77×10−5+9.77\times10^{-5} to −9.77×10−5-9.77\times10^{-5}. A sign or angle error in a shape catalog shows up as a negative ξ−\xi_- and, in a map, as mass in the B mode.

Redshift outliers. Moving a random 20 percent of far-bin galaxies into the near bin raises the near-bin weight from 0.3190.319 to 0.4530.453. The contaminated ξ+\xi_+ gives χ2=469.5\chi^2=469.5 against the nominal prediction and 8.28.2 against the mixture prediction, both over 8 bins. A wrong redshift distribution does not add noise. It moves the signal.

Recovering an isothermal halo

The second test is independent of the Lab code. A singular isothermal sphere with θE=0.5′\theta_{\rm E}=0.5' sits at the centre of a 40′40' field. Each of 200 trials draws 20 galaxies per square arcminute at random positions and Gaussian intrinsic shapes with σϵ=0.26\sigma_\epsilon=0.26. It applies the exact transformation ϵ=(ϵs+g)/(1+g∗ϵs)\epsilon=(\epsilon^{\rm s}+g)/(1+g^*\epsilon^{\rm s}) with g=γ/(1−κ)g=\gamma/(1-\kappa), drops galaxies inside θE\theta_{\rm E} so that ∣g∣<1|g|<1, bins the tangential ellipticity in annuli from 1′1' to 16′16' and fits θE\theta_{\rm E} by least squares. Weak Gravitational Lensing, Eqs. 3.17-3.18

Table 5.4 Halo recovery over 200 trials.
QuantityValue
True θE\theta_{\rm E}0.5′0.5'
Mean fitted θE\theta_{\rm E}0.4997′±0.0018′0.4997'\pm0.0018'
Scatter of the fits0.0253′0.0253'
Median quoted uncertainty0.0224′0.0224'
Standard deviation of the pulls1.14
Cross-shear significance, mean and spread0.07 and 0.99

The fit is unbiased. The quoted uncertainties are about 12 percent too small; we have not traced why. The cross shear behaves like pure noise, as it should for a lens.

The first version of the fit placed each annulus at its arithmetic-mean radius and came out 1.2 percent high. The shear falls as 1/θ1/\theta, so the average shear in an annulus matches the model at the harmonic-mean radius. Switching to that radius removed the bias.

Testing the map inversion

A noise-free isothermal halo on a 256×256256\times256 grid, inverted with Kaiser-Squires, checks what the map can recover. In the inner half of the field, excluding the centre, the true convergence has an rms of 0.0420.042. The reconstruction differs from it by a nearly constant offset of 0.02250.0225; the true mean convergence of the field is 0.02200.0220. After removing the offset the residual rms is 0.00360.0036, and the B mode has an rms of 0.00070.0007. The lost mode is the field mean, as the mass-sheet argument predicts.

What this does not show

Nothing here reproduces a survey measurement. The simulation tests the estimator, the tomographic bookkeeping and two failure modes on Gaussian fields with known answers. Real cosmic shear needs nonlinear structure, realistic redshift distributions, masks, weights and calibration of the shape measurement. The guide to the DES Year 3 analysis shows how one survey handles them.

Sources

  1. Cosmology with cosmic shear observations: a review, Eqs. 21-24
  2. Weak Gravitational Lensing, Eqs. 3.17-3.18

Keep reading

What this page links to directly

See this series on the content map →

Weak gravitational lensing and mass maps · Reading path

From galaxy shapes to a map of mass

  1. ArticleHow can galaxies that are barely stretched map dark matter?
  2. ArticleConvergence, shear and what a galaxy shape measures
  3. ArticleTurning a shear field into a mass map
  4. ArticleShear correlation functions and redshift tomography
  5. You are hereRecompute shear correlations and tomography from a simulation
  6. ArticleHow to read the DES Year 3 lensing and clustering analysis
Something broken, confusing, or missing on this page?Tell us
What kind of feedback?

Sent with this page’s address, its Lab ID, the site language and your device type. Please leave out personal details. Feedback is kept for up to 12 months.Privacy policy