Skip to main content
Sandbox Physics
CMB B-modes, dust and delensing

Recompute an E/B split and a two-frequency dust cleaning

Sandbox Physics ·

By the end of this guide you will have run one Python script that splits synthetic polarization maps into EE and BB, recovers a hidden tensor-to-scalar ratio, shows three ways EE leaks into BB, and removes dust from a 150 GHz150\ \mathrm{GHz} map with a 353 GHz353\ \mathrm{GHz} map. Everything runs from three saved files with the Python standard library, in about a second. The maps are Gaussian random fields drawn from model spectra. None of them is a BICEP/Keck, Planck or SPT map, and nothing here is a reanalysis of published data.

The formulas come from the chapters on splitting a map into E and B and on dust and lensing. Read those first if a step below is unclear.

Get the three files

Download the script, the saved inputs and the expected output into one empty folder. The script imports only cmath, json, math, random and sys, and it carries its own fast Fourier transform. The expected output was produced with Python 3.9.6 and reproduced with Python 3.14.3. The two runs agree in every number except values below 10−3010^{-30}, which are rounding noise, and the recorded version string.

From that folder, run:

python3 -I recompute_e_b_and_dust_bands.py tutorial-inputs.json my-output.json

The flag -I keeps Python from loading modules from the current folder or your environment. Running without the two file names stops with an IndexError. A run takes about one second on a laptop.

Read the inputs and their units

The patch is a 64×6464\times64 grid, 16∘16^\circ on a side, so a pixel is 1515 arcminutes and the smallest non-zero multipole is 22.522.5. Band powers are averaged in seven bands with edges 30,60,100,150,220,320,450,64030, 60, 100, 150, 220, 320, 450, 640. Waves above ℓ=640\ell = 640 and the unpaired lines at the grid's highest frequency are dropped.

The block spectra holds a frozen subset of CAMB spectra at 32 multipoles: lensed scalar EEEE, lensed scalar BBBB, and tensor BBBB for r=1r = 1. The generator block records CAMB 1.6.0 and the cosmology, the Planck 2018 values from table 2 of the parameters paper, with H0=67.36H_0 = 67.36, τ=0.0544\tau = 0.0544 and ns=0.9649n_s = 0.9649. Tensors use nt=0n_t = 0 at a pivot of 0.05 Mpc−10.05\ \mathrm{Mpc}^{-1}, the convention BK18 uses. The script interpolates between nodes in log-log.

The dust block holds Ad=4.4 μK2A_d = 4.4\ \mu\mathrm{K}^2 at 353 GHz353\ \mathrm{GHz} and ℓ=80\ell = 80 from BK18, Td=19.6 KT_d = 19.6\ \mathrm{K} and βd=1.53\beta_d = 1.53 from Planck, and a band-power slope of −0.54-0.54, which is Planck's Cℓ∝ℓ−2.54C_\ell \propto \ell^{-2.54}. Dust EEEE is twice dust BBBB, as BK18 assumes.

Units follow the units block: spectra in μK2\mu\mathrm{K}^2 of microwave-background temperature, band powers DℓD_\ell in μK2\mu\mathrm{K}^2, angles in degrees, frequencies in GHz, noise in μK\mu\mathrm{K}-arcmin in each of QQ and UU. Each run sets its own random seed, so the eight runs do not depend on each other.

Every band row in the output has measured, expected and sigma. The sigma is the scatter expected from the number of waves in the band, 2/Nb\sqrt{2/N_b} times the expected value.

Step 1: a sky with only E gives no B

Open my-output.json at runs, then pure-e-injection. The script draws EE waves, sets B=0B = 0, builds QQ and UU maps with the inverse rotation, and splits them again. BBOverEE is between 10−3110^{-31} and 4×10−314\times10^{-31} in every band. That is floating-point rounding, and it is the check that the two rotations in the script match.

If you change the script and this ratio becomes large, the forward and inverse rotations disagree, for example by a sign. Every later step would then be wrong.

Step 2: recover a hidden r

The run tensor-and-lensing draws BB from lensing plus tensors with r=0.03r = 0.03. Its BB band powers scatter around the model with χ2=7.06\chi^2 = 7.06 over seven bands. The script then subtracts the expected lensing in the first four bands, 30≤ℓ<22030 \le \ell < 220, and fits the remainder with the tensor shape, weighting each band by 1/σ21/\sigma^2. The block tensorRatioEstimate gives r=0.0290±0.0097r = 0.0290 \pm 0.0097, with input 0.030.03.

The uncertainty is about a third of the signal on this small patch, even with no noise and no dust. Lensing B is drawn here as a Gaussian field with the CAMB spectrum, which ignores its real non-Gaussian structure.

Step 3: rotate the instrument by two degrees

The run angle-miscalibration rotates every rod of the pure-EE sky by 2∘2^\circ before the split. BBOverEE is 0.00490.0049 in every band, and the output stores the prediction predictedBBOverEE =tan⁡24∘=0.00489= \tan^2 4^\circ = 0.00489. The rotation moves sin⁡24∘\sin^2 4^\circ of the power into BB and leaves cos⁡24∘\cos^2 4^\circ in EE, so their ratio is the tangent squared.

Step 4: use the wrong angle factor

The run wrong-angle-factor splits the same maps with φℓ\varphi_\ell in place of 2φℓ2\varphi_\ell. EE falls to about half of its model value, for example 0.2660.266 instead of 0.487 μK20.487\ \mu\mathrm{K}^2 in the band 60≤ℓ<10060 \le \ell < 100, and B/EB/E lies between 0.860.86 and 1.161.16. Half of the EE power has moved into BB. Seeing BB comparable to EE in a sky expected to be EE-dominated is the sign of this mistake.

Step 5: cut the sky with a mask

The run hard-and-tapered-mask multiplies the pure-EE maps by a centred square that covers 47 percent of the patch, first with hard edges and then with edges tapered by a cosine over 1212 percent of the patch width. Band powers are divided by the mean square of the mask, the sky fraction in the output.

Table 5.1 B/EB/E from a sky with no BB, after masking, as saved in the expected output.
BandHard edgeTapered edge
3030 to 60600.370.370.510.51
6060 to 1001000.320.320.290.29
100100 to 1501500.100.100.130.13
150150 to 2202200.140.140.0580.058
220220 to 3203200.0570.0570.0290.029
320320 to 4504500.0240.0240.00960.0096
450450 to 6406400.0240.0240.0060.006

Tapering helps above ℓ≈150\ell \approx 150 and does nothing for the largest scales, where the window is about the size of the waves. On this patch, simple masking leaks far more than the lensing BB level of about 0.0040.004 of EE. BK18 handles this with a matrix purification step; the script stops at showing the problem.

Step 6: clean dust with a 353 GHz map

The run dust-two-frequencies builds maps at 150 GHz150\ \mathrm{GHz} with noise 2.8 μK2.8\ \mu\mathrm{K}-arcmin and at 353 GHz353\ \mathrm{GHz} with noise 20 μK20\ \mu\mathrm{K}-arcmin. Both contain the same microwave background with r=0.03r = 0.03 and the same dust pattern scaled by the frequency law.

The output reports dustPowerFactorTo353 of 0.002280.00228 at 150 GHz150\ \mathrm{GHz}, and cleaningCoefficient a=0.0477a = 0.0477, its square root. Under combinations, the 150 GHz150\ \mathrm{GHz} map alone gives r=0.274±0.011r = 0.274 \pm 0.011: dust looks like nine times the true signal. The combination with weights 1.0501.050 and −0.0501-0.0501, which is (m150−a m353)/(1−a)(m_{150} - a\,m_{353})/(1 - a), gives r=0.0335±0.0118r = 0.0335 \pm 0.0118. Its noise rises from 2.82.8 to 3.11 μK3.11\ \mu\mathrm{K}-arcmin, and its dustResidualBB is at most 3×10−33 μK23\times10^{-33}\ \mu\mathrm{K}^2, which is zero up to rounding.

Step 7: two ways the cleaning fails

The run dust-wrong-index builds the same maps, but the cleaning assumes βd=1.63\beta_d = 1.63. Its coefficient becomes 0.04380.0438 instead of 0.04770.0477. The residual dust is 8.1×10−5 μK28.1\times10^{-5}\ \mu\mathrm{K}^2 in the lowest band and rr rises to 0.03610.0361.

The run dust-decorrelated keeps the right index, but the 150 GHz150\ \mathrm{GHz} dust pattern is correlated with the 353 GHz353\ \mathrm{GHz} one by only ρd=0.95\rho_d = 0.95. The residual dust is 4.3×10−44.3\times10^{-4} to 1.3×10−3 μK21.3\times10^{-3}\ \mu\mathrm{K}^2 in the first four bands, and rr rises to 0.04250.0425.

Table 5.2 Fitted rr for a sky made with r=0.03r = 0.03, first four bands.
RunMapFitted rr
tensor-and-lensingno dust, no noise0.0290±0.00970.0290 \pm 0.0097
dust-two-frequencies150 GHz150\ \mathrm{GHz} alone0.274±0.0110.274 \pm 0.011
dust-two-frequenciescleaned0.0335±0.01180.0335 \pm 0.0118
dust-wrong-indexcleaned with βd=1.63\beta_d = 1.630.0361±0.01180.0361 \pm 0.0118
dust-decorrelatedcleaned, ρd=0.95\rho_d = 0.950.0425±0.01180.0425 \pm 0.0118

The quoted uncertainties count only microwave-background and noise scatter. Each failure shifts rr by less than one sigma from the correctly cleaned value on this patch. Both add positive dust power, so the upward bias stays even on a larger patch.

What the numbers do not mean

The patch is 256 square degrees with one sky realization per run, so the uncertainties are larger than in a real survey and the digits depend on the seeds. BK18 reaches σ(r)=0.009\sigma(r) = 0.009 with real maps over about 400 to 600 square degrees at several frequencies, a likelihood that includes foreground parameters, and simulations of its own pipeline. The script has no beam, no filtering, no synchrotron, no instrument systematics and no delensing, and it treats lensing BB as Gaussian. Its purpose is to make each step visible and checkable.

If something goes wrong

A different Python version should change only values below 10−3010^{-30}. Any other difference means the input file or the script has changed. The grid size must be a power of two, because the Fourier transform is radix-2. Changing a seed changes every measured value in that run but none of the expected values.

Things to try

  1. Set rotationDegrees to 0.50.5 and check that BBOverEE becomes tan⁡21∘≈3.0×10−4\tan^2 1^\circ \approx 3.0\times10^{-4}.
  2. Set dustCorrelation to 0.990.99 and see how much of the bias in Step 7 disappears.
  3. Raise the 353 GHz353\ \mathrm{GHz} noise to 60 μK60\ \mu\mathrm{K}-arcmin and predict the cleaned noise from the weights before running.

Read the same angular band at four frequencies

In the measured BK18 spectra, the B-mode power around ℓ=72.5\ell = 72.5 rises sharply between 95 and 353 GHz. In the left panel below, compare the four dark points with the blue lensing curve. Lensing changes the pattern of the microwave background the same way in every channel. Galactic dust brightens toward the higher frequencies, even after we put all the maps on the same CMB temperature scale.

Start with the 150 GHz point alone. Subtract the reference lensing prediction and assign everything left to primordial waves. The exercise returns an apparent r=0.172r = 0.172. One bandpower gives you one equation for the three contributions. Now use all ten auto and cross spectra of the four maps. Their windows tell you which angular scales contribute to each band. The covariance tells you which measurements move together. Both come from the October 2021 BK18 data release.

The replay fits the nine bands per spectrum with a fixed dust colour and a fixed lensing shape. With r=0r = 0, the fitted lensing amplitude is 1.07±0.081.07 \pm 0.08 times the reference. The dust amplitude at 353 GHz and ℓ=80\ell = 80 is 4.18±0.41 μKCMB24.18 \pm 0.41\ \mu\mathrm{K}_{\rm CMB}^{2}. Look at the right panel to see how the two contributions change across angular scale. These are conditional Gaussian errors for this set of templates. The published BK18 limit combines more frequency maps and varies the foreground parameters in its own likelihood.

Download and unpack the replay beneath the figure. Save the two original files in an inputs directory, then run this command from the unpacked folder with NumPy and Matplotlib installed.

mkdir -p inputs
curl -fL https://lambda.gsfc.nasa.gov/data/suborbital/BICEPK_2021/BK18_cosmomc.tgz -o inputs/BK18_cosmomc.tgz
curl -fL https://lambda.gsfc.nasa.gov/data/suborbital/BICEPK_2021/BK18_bandpowers_20210607.txt -o inputs/BK18_bandpowers_20210607.txt
python3 recompute_observed_bands.py inputs camb-polarization-spectra.json output

Open bk18-observed-result.json. It records both source hashes and the agreement between the archive and the independently published bandpower table. Compare the fit with the covariance intact and the fit that discards its correlations. The latter gives a dust error of about 0.23 μKCMB20.23\ \mu\mathrm{K}_{\rm CMB}^{2} when the full-covariance fit with a free tensor template gives 0.41 μKCMB20.41\ \mu\mathrm{K}_{\rm CMB}^{2}. Shared sky and instrument contributions matter to the uncertainty.

Sources: BICEP/Keck 2021, BK18 constraints on primordial gravitational waves, Planck 2018 results XI, polarized dust foregrounds, Lewis and Challinor 2006, weak gravitational lensing of the CMB, section 5, Planck 2018 results VI, cosmological parameters, table 2.

Measured BK18 B-mode bandpowers rise strongly toward 353 GHz. At 150 GHz, the nine angular bands track the lensing plus dust model.
Points show BK18 measurements. Error bars show marginal standard deviations from the archived covariance. The fit also uses the correlations between the points. Data courtesy of the BICEP/Keck Collaboration and NASA Goddard’s LAMBDA archive.
Download the BK18 replay

Save a sky record from the Lab and compare its band powers with the script output.

Sources

  1. October 2021 BK18 data release
  2. BICEP/Keck 2021, BK18 constraints on primordial gravitational waves
  3. Planck 2018 results XI, polarized dust foregrounds
  4. Lewis and Challinor 2006, weak gravitational lensing of the CMB, section 5
  5. Planck 2018 results VI, cosmological parameters, table 2

Keep reading

What this page links to directly

See this series on the content map →

CMB B-modes, dust and delensing · Reading path

From polarized light to E and B, dust, lensing and the BICEP/Keck limit

  1. ArticleCan swirls in the microwave sky reveal the first gravitational waves?
  2. ArticleHow scattering polarizes the microwave background
  3. ArticleSplitting a polarization map into E and B modes
  4. ArticleHow dust and lensing add B-modes, and how to take them out
  5. You are hereRecompute an E/B split and a two-frequency dust cleaning
  6. ArticleHow to read the BICEP/Keck BK18 limit on primordial gravitational waves
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