pysm icon indicating copy to clipboard operation
pysm copied to clipboard

Implement consistency unit test for Websky

Open zonca opened this issue 1 year ago • 0 comments

I'd like to propose a sanity regression test for this. The middle CMB band is usually chosen to balance the power of the radio and CIB foreground components. Thus, it should have a similar power spectrum for the two components, and indeed this plot is how I found this bug. I think a very sensible unit test would be to simply compute the power spectra as below and then check that they are within i.e. two orders of magnitude.

import numpy as np
import matplotlib.pyplot as plt
import healpy as hp
from pysm3 import WebSkyCIB, WebSkyRadioGalaxies
import pysm3.units as u

model_cib = WebSkyCIB(nside=512)
m_cib = model_cib.get_emission(143*u.GHz)
cl_cib = hp.alm2cl(hp.map2alm(m_cib.value[0,:]))

model_radio = WebSkyRadioGalaxies(nside=512)
m_radio = model_radio.get_emission(143*u.GHz)
cl_radio = hp.alm2cl(hp.map2alm(m_radio.value[0,:]))

plt.plot(cl_cib, label="CIB")
plt.plot(cl_radio, label="Radio")
plt.legend()
plt.xscale("log"); plt.yscale("log")
plt.ylabel(r"$C_{\ell}$ [$\mu$K$^2]$ at 143 GHz")

image

Also here's the shot noise power for reference from Planck. image

Originally posted by @xzackli in https://github.com/galsci/pysm/issues/138#issuecomment-1322301835

zonca avatar Nov 21 '22 18:11 zonca