import healpy as hp
import numpy as np
import matplotlib.pyplot as plt
from pysm3 import units as u
import pysm3 as pysm
%matplotlib inlinedip = 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_factorcalibrated_dip = calibration_factor * dipcalibrated_diphp.mollview(calibrated_dip, unit=calibrated_dip.unit)
First we simplify and consider a delta-frequency instrument at 300 GHz
center_frequency = 300 * u.GHzdip_peak = calibrated_dip.max()calibrated_dip.max()calibrated_dip.max().to(u.mK_RJ, equivalencies=u.cmb_equivalencies(center_frequency))calibrated_dip.max().to(u.MJy/u.sr, equivalencies=u.cmb_equivalencies(center_frequency))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.GHzweights = [1, 1, 1, 1]weights /= np.trapz(weights, freq)weightsThe 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_MJysrintegrated_SR = np.trapz(dip_peak_MJysr * weights, freq)integrated_SRThis is different than assuming uniform bandpass in
np.trapz(dip_peak * weights, freq)SR = u.MJy/u.srWe use the PySM 3 function to compute unit conversion given a bandpass
$ [unit_{out}] = [unit_{in}] { C_{unit_{out}}{Jy~sr{-1}}() g() d} $
which comes from equating in power:
$ [unit_{out}]{ C_{unit_{out}}{Jy~sr{-1}}() g() d} = [unit_{in}]C_{unit_{in}}{Jy~sr{-1}}() g() d$
SRpysm.utils.bandpass_unit_conversion(freq, weights=weights, output_unit=u.mK_CMB, input_unit=SR)integrated_SR * _1 * u.mK_CMB / (1 * SR)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_MJysrIntegrating 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)1/np.trapz(1/K_CMB_to_MJysr * weights, freq)