This lesson is about simulating the input sky signal using PySM 3.
If you used PySM
in the past, you most probably used PySM 2
from https://github.com/bthorne93/PySM_public.
PySM 3
is a rewrite of PySM
which offers all the same functionality and the same models of PySM 2
but is focused on:
numba
It is available from https://github.com/healpy/pysm, it is still missing a few models and the documentation but is already integrated into TOAST to overcame the strong performance limits of PySM 2
.
If anyone is interested in learning more about PySM 3, check the PySM 3 tutorial, we can work through this during the hack day.
The lower level TOAST class is PySMSky
, it performs the following operations:
PySM
with the input sky configurationPySM
to generate the sky emission at all frequencies in the bandpass and integrate# Load common tools for all lessons
import sys
sys.path.insert(0, "..")
from lesson_tools import (
fake_focalplane
)
# Capture C++ output in the jupyter cells
%reload_ext wurlitzer
import toast
import healpy as hp
import numpy as np
env = toast.Environment.get()
env.set_log_level("DEBUG")
focal_plane = fake_focalplane()
from toast.todmap import PySMSky
PySMSky?
NSIDE = 64
npix = hp.nside2npix(NSIDE)
You can find out details about all the models available in PySM 2 and 3 at:
pysm_sky_config = ["s1", "f1", "a1", "d1"]
pysm_sky = PySMSky(comm=None,
pixel_indices=None,
nside=NSIDE,
units="uK_RJ",
pysm_sky_config=pysm_sky_config
)
pysm_sky
We can directly access the underlying PySM.Sky
object as the sky
attribute of the PySMSky
object.
pysm_sky.sky
import pysm.units as u
pysm_sky.sky.get_emission(12 * u.GHz)
%matplotlib inline
## _ refers to the output of the previous cell, so this works only if you run cells in sequence
hp.mollview(_[0], cmap="coolwarm", min=-100, max=1e4)
First we need bandpasses for the channels, first element of the tuple is frequency, second element are weights, we define a top-hat of 10 points with a bandwidth of 10 GHz:
bandpasses = {}
for ch in focal_plane: # loops through dict keys
bandpasses[ch] = (np.linspace(65, 75, 10), np.ones(10))
bandpasses
local_maps = {}
pysm_sky.exec(local_maps, out="sky", bandpasses=bandpasses)
hp.mollview(local_maps["sky_0A"][0], cmap="coolwarm", min=0, max=1e3, unit="uK_RJ")
local_maps["sky_0B"][0]-local_maps["sky_0A"][0]
bandpasses["0B"] = (np.linspace(63, 73, 10), np.ones(10))
local_maps = {}
pysm_sky.exec(local_maps, out="sky", bandpasses=bandpasses)
hp.mollview(local_maps["sky_0A"][0]-local_maps["sky_0B"][0], cmap="coolwarm", unit="uK_RJ")
hp.gnomview(local_maps["sky_0A"][0]-local_maps["sky_0B"][0], rot=(0,0), xsize=5000, ysize=2000, cmap="coolwarm")
Create a PySMSky
object with pure CMB (model c1
), in uK_CMB
Get the CMB signal for 2 channels at 2 different frequencies and verify that the maps are the same to double precision error (~1e-14). To specify a channel at a single frequency instead of a bandpass, you can specify:
bandpasses={"ch0":(100,1)}
Where the first element of the tuple is frequency in GHz
, the second its weight.