Unit conversion with broadband detectors looking at the CMB
import healpy as hp
import numpy as np
import matplotlib.pyplot as plt
from pysm3 import units as u
import pysm3 as pysm
%matplotlib inline
dip = hp.synfast([0,1], lmax=1, nside=128) * u.V
/home/zonca/zonca/p/software/healpy/healpy/sphtfunc.py:438: FutureChangeWarning: The order of the input cl's will change in a future release.
Use new=True keyword to start using the new order.
See documentation of healpy.synalm.
category=FutureChangeWarning,
/home/zonca/zonca/p/software/healpy/healpy/sphtfunc.py:824: UserWarning: Sigma is 0.000000 arcmin (0.000000 rad)
sigma * 60 * 180 / np.pi, sigma
/home/zonca/zonca/p/software/healpy/healpy/sphtfunc.py:829: UserWarning: -> fwhm is 0.000000 arcmin
sigma * 60 * 180 / np.pi * (2.0 * np.sqrt(2.0 * np.log(2.0)))
hp.mollview(dip, unit=dip.unit)
We measure the sky with out broadband instrument, we assume we only measure the CMB solar dipole, initially the units are arbitrary, for example Volts of our instrument.
Next we calibrate on the solar dipole, which is known to be 3.3 mK.
calibration_factor = 2 * 3.3 * u.mK_CMB / (dip.max() - dip.min())
calibration_factor
<Quantity 3.9033114 mK_CMB / V>
calibrated_dip = calibration_factor * dip
calibrated_dip
<Quantity [ 0.44224864, 0.41525913, 0.40329058, ..., -0.43028009,
-0.44224864, -0.41525913] mK_CMB>
hp.mollview(calibrated_dip, unit=calibrated_dip.unit)
First we simplify and consider a delta-frequency instrument at 300 GHz
center_frequency = 300 * u.GHz
dip_peak = calibrated_dip.max()
calibrated_dip.max()
<Quantity 3.3 mK_CMB>
calibrated_dip.max().to(u.mK_RJ, equivalencies=u.cmb_equivalencies(center_frequency))
<Quantity 0.47252855 mK_RJ>
calibrated_dip.max().to(u.MJy/u.sr, equivalencies=u.cmb_equivalencies(center_frequency))
<Quantity 1.30659935 MJy / sr>
Next we assume instead that we have a broadband instrument, of 20% bandwidth, with uniform response in that range. For simplicity, we only take 4 points.
freq = [270, 290, 310, 330] * u.GHz
weights = [1, 1, 1, 1]
weights /= np.trapz(weights, freq)
weights
<Quantity [0.01666667, 0.01666667, 0.01666667, 0.01666667] 1 / GHz>
The instrument bandpass is defined in power so we can transform our signal in MJy/sr at the 4 reference frequencies, then integrate.
dip_peak_MJysr = dip_peak.to(u.MJy/u.sr, equivalencies=u.cmb_equivalencies(freq))
dip_peak_MJysr
<Quantity [1.46428149, 1.36325498, 1.24713961, 1.12324616] MJy / sr>
integrated_SR = np.trapz(dip_peak_MJysr * weights, freq)
integrated_SR
<Quantity 1.30138614 MJy / sr>
This is different than assuming uniform bandpass in , where instead we would recover the same result of the delta-bandpass:
np.trapz(dip_peak * weights, freq)
<Quantity 3.3 mK_CMB>
SR = u.MJy/u.sr
We use the PySM 3 function to compute unit conversion given a bandpass
which comes from equating in power:
SR
Unit("MJy / sr")
pysm.utils.bandpass_unit_conversion(freq, weights=weights, output_unit=u.mK_CMB, input_unit=SR)
<Quantity 2.53575776 mK_CMB sr / MJy>
integrated_SR * _
<Quantity 3.3 mK_CMB>
1 * u.mK_CMB / (1 * SR)
<Quantity 1. mK_CMB sr / MJy>
We can doublecheck the implementation of the PySM function by executing it here:
K_CMB_to_MJysr = ((1*SR).to(u.mK_CMB, equivalencies=u.cmb_equivalencies(freq)))/(1*SR)
K_CMB_to_MJysr
<Quantity [2.25366503, 2.42067702, 2.646055 , 2.93791344] mK_CMB sr / MJy>
Integrating the K_CMB_to_MJysr conversion factor is wrong, we always need to do the integral in power,
therefore we integrate the inverse and then take its inverse.
np.trapz(K_CMB_to_MJysr * weights, freq)
<Quantity 2.55417375 mK_CMB sr / MJy>
1/np.trapz(1/K_CMB_to_MJysr * weights, freq)
<Quantity 2.53575776 mK_CMB sr / MJy>