import healpy as hp
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import astropy.units as uNoise-Equivalent-Temperature, it is a measure of sensitivity of a detector, in cosmology, it is often quoted in
For example let’s consider a white noise NET of
it means that if you integrate for 100 seconds for each pixel, the standard deviation will be
net = 200 * u.Unit("uK * sqrt(s)")netintegration_time_per_pixel = 100 * u.sstandard_deviation = net / np.sqrt(integration_time_per_pixel)Create a white noise map
Now that we have an estimate of the standard deviation per pixel, we can use numpy to create a map of gaussian white noise.
nside = 128
npix = hp.nside2npix(nside)m = np.random.normal(scale = standard_deviation.value, size=npix) * standard_deviation.unithp.mollview(m, unit=m.unit, title="White noise map")
Power spectrum
Finally we can compute the angular power spectrum with anafast, i.e. the power as a function of the angular scales, from low
At low
Where:
cl = hp.anafast(m)cl[100:].mean()0.02516797566530168
pixel_area = hp.nside2pixarea(nside)white_noise_cl = standard_deviation.value**2 * pixel_areawhite_noise_cl0.025566346464760685
plt.figure(figsize=(6,4))
plt.loglog(cl, label="Map power spectrum", alpha=.7)
plt.hlines(white_noise_cl, 0, len(cl), label="White noise level")
plt.xlabel("$\ell$")
plt.ylabel("$C_\ell [\mu K ^ 2]$");
Masking
In case we are removing some pixels from a map, for example to mask out a strong signal (e.g. the Milky Way), our estimate of the power spectrum on the partial sky is lower. However we assume that the properties of the noise will be the same also in the masked region. At first order, for simple masks, we can just correct for the amplitude by dividing the power spectrum by the sky fraction.
m.value[len(m)//2-30000:len(m)//2+30000] = hp.UNSEENhp.mollview(m, unit=m.unit, title="White noise map")
cl_masked = hp.anafast(m)plt.figure(figsize=(6,4))
plt.loglog(cl, label="Map power spectrum", alpha=.7)
plt.loglog(cl_masked, label="Map power spectrum (Masked)", alpha=.7)
plt.hlines(white_noise_cl, 0, len(cl), label="White noise level")
plt.xlabel("$\ell$")
plt.ylabel("$C_\ell [\mu K ^ 2]$")
plt.legend();
sky_fraction = hp.mask_good(m).sum() / len(m)
print(sky_fraction)0.69482421875
plt.figure(figsize=(6,4))
plt.loglog(cl, label="Map power spectrum", alpha=.7)
plt.loglog(cl_masked / sky_fraction, label="Map power spectrum (Masked) - corrected", alpha=.7)
plt.hlines(white_noise_cl, 0, len(cl), label="White noise level")
plt.xlabel("$\ell$")
plt.ylabel("$C_\ell [\mu K ^ 2]$")
plt.legend();