def test_dependence_on_nu0_RJ(self): NSIDE = 8 MODEL = 'c1s0' INSTRUMENT = 'litebird' sky = pysm.Sky(get_sky(NSIDE, MODEL)) instrument = pysm.Instrument( get_instrument(INSTRUMENT, NSIDE, units='uK_RJ')) components100 = [ cm.CMB(units='K_RJ'), cm.Synchrotron(100., units='K_RJ') ] components10 = [ cm.CMB(units='K_RJ'), cm.Synchrotron(10., units='K_RJ') ] with suppress_stdout(): freq_maps, _ = instrument.observe(sky, write_outputs=False) res100 = basic_comp_sep(components100, instrument, freq_maps) res10 = basic_comp_sep(components10, instrument, freq_maps) aac(res100.Sigma, res10.Sigma) aac(res100.x, res10.x) aac(res100.s[0], res10.s[0]) aac(res100.s[1], res10.s[1] * 10**res10.x[0])
def test_Sigma_synchrotron(self): NSIDE = 8 MODEL = 's0' INSTRUMENT = 'litebird' SIGNAL_TO_NOISE = 20 sky = pysm.Sky(get_sky(NSIDE, MODEL)) instrument = pysm.Instrument(get_instrument(INSTRUMENT, NSIDE)) components = [cm.Synchrotron(100.)] ref = [] for component in components: ref += component.defaults with suppress_stdout(): freq_maps, noise_maps = instrument.observe(sky, write_outputs=False) signal = freq_maps[:, 0, 0] noise = np.std(noise_maps[:, 0], axis=-1) maps = signal / np.dot(signal, noise) * SIGNAL_TO_NOISE maps = maps[:, np.newaxis] + noise_maps[:, 0] res = basic_comp_sep(components, instrument, maps, nside=hp.get_nside(maps)) white = (res.x[0] - ref[0]) / res.Sigma[0, 0]**0.5 _, p = kstest(white, 'norm') assert p > 0.01
def test_Sigma_dust_sync_betas_temp(self): NSIDE = 8 MODEL = 'd0s0' INSTRUMENT = 'litebird' SIGNAL_TO_NOISE = 10000 UNITS = 'uK_CMB' sky = pysm.Sky(get_sky(NSIDE, MODEL)) instrument = pysm.Instrument( get_instrument(INSTRUMENT, NSIDE, units=UNITS)) components = [ cm.Dust(150., temp=20., units=UNITS), cm.Synchrotron(150., units=UNITS) ] ref = [] for component in components: ref += component.defaults ref = np.array(ref) with suppress_stdout(): freq_maps, noise_maps = instrument.observe(sky, write_outputs=False) signal = freq_maps[:, 0, 0] # Same signal for all the pixels noise = noise_maps[:, 0] signal_ver = signal / np.dot(signal, signal)**0.5 noise_std = np.std([np.dot(n, signal_ver) for n in noise.T]) maps = signal_ver * noise_std * SIGNAL_TO_NOISE maps = maps[:, np.newaxis] + noise res = basic_comp_sep(components, instrument, maps, nside=NSIDE) diff = (res.x.T - ref) postS = np.mean(diff[..., None] * diff[..., None, :], axis=0) S = res.Sigma.T[0] aac(postS, S, rtol=1. / NSIDE)
def test_Sigma_synchrotron(self): NSIDE = 8 MODEL = 's0' INSTRUMENT = 'LiteBIRD' SIGNAL_TO_NOISE = 20 sky = get_sky(NSIDE, MODEL) instrument = get_instrument(INSTRUMENT) components = [cm.Synchrotron(100.)] ref = [] for component in components: ref += component.defaults freq_maps = get_observation(instrument, sky) noise_maps = get_noise_realization(NSIDE, instrument) signal = freq_maps[:, 0, 0] noise = np.std(noise_maps[:, 0], axis=-1) maps = signal / np.dot(signal, noise) * SIGNAL_TO_NOISE maps = maps[:, np.newaxis] + noise_maps[:, 0] if not hasattr(instrument, 'depth_i'): instrument['depth_i'] = instrument.depth_p / np.sqrt(2) res = basic_comp_sep(components, instrument, maps, nside=hp.get_nside(maps)) white = (res.x[0] - ref[0]) / res.Sigma[0, 0]**0.5 _, p = kstest(white, 'norm') assert p > 0.01, f'KS probability is {p}'
def test_Sigma_dust_sync_betas_temp(self): NSIDE = 8 MODEL = 'd0s0' INSTRUMENT = 'LiteBIRD' SIGNAL_TO_NOISE = 10000 UNITS = 'uK_CMB' sky = get_sky(NSIDE, MODEL) instrument = get_instrument(INSTRUMENT) components = [ cm.Dust(150., temp=20., units=UNITS), cm.Synchrotron(150., units=UNITS) ] ref = [] for component in components: ref += component.defaults ref = np.array(ref) freq_maps = get_observation(instrument, sky, unit=UNITS) noise_maps = get_noise_realization(NSIDE, instrument, unit=UNITS) signal = freq_maps[:, 0, 0] # Same signal for all the pixels noise = noise_maps[:, 0] signal_ver = signal / np.dot(signal, signal)**0.5 noise_std = np.std([np.dot(n, signal_ver) for n in noise.T]) maps = signal_ver * noise_std * SIGNAL_TO_NOISE maps = maps[:, np.newaxis] + noise if not hasattr(instrument, 'depth_i'): instrument['depth_i'] = instrument.depth_p / np.sqrt(2) res = basic_comp_sep(components, instrument, maps, nside=NSIDE) diff = (res.x.T - ref) postS = np.mean(diff[..., None] * diff[..., None, :], axis=0) S = res.Sigma.T[0] aac(postS, S, rtol=1. / NSIDE)
def test_dependence_on_nu0_CMB(self): NSIDE = 4 MODEL = 'c1s0' INSTRUMENT = 'LiteBIRD' sky = get_sky(NSIDE, MODEL) instrument = get_instrument(INSTRUMENT) components100 = [cm.CMB(), cm.Synchrotron(100.)] components10 = [cm.CMB(), cm.Synchrotron(10.)] freq_maps = get_observation(instrument, sky) res10 = basic_comp_sep(components10, instrument, freq_maps) res100 = basic_comp_sep(components100, instrument, freq_maps) aac(res100.Sigma, res10.Sigma) aac(res100.x, res10.x) aac(res100.s[0], res10.s[0], atol=1e-7) factor = _cmb2rj(10.) * _rj2cmb(100.) aac(res100.s[1], res10.s[1] * 10**res10.x[0] * factor)
def test_dependence_on_nu0_RJ(self): NSIDE = 8 MODEL = 'c1s0' INSTRUMENT = 'LiteBIRD' sky = get_sky(NSIDE, MODEL) instrument = get_instrument(INSTRUMENT) components100 = [ cm.CMB(units='K_RJ'), cm.Synchrotron(100., units='K_RJ') ] components10 = [ cm.CMB(units='K_RJ'), cm.Synchrotron(10., units='K_RJ') ] freq_maps = get_observation(instrument, sky, unit='K_RJ') res100 = basic_comp_sep(components100, instrument, freq_maps) res10 = basic_comp_sep(components10, instrument, freq_maps) aac(res100.Sigma, res10.Sigma) aac(res100.x, res10.x) aac(res100.s[0], res10.s[0]) aac(res100.s[1], res10.s[1] * 10**res10.x[0])
def setUp(self): NSIDE = 16 MODEL = 'c1d0s0f1' INSTRUMENT = 'LiteBIRD' X0_FACTOR = 0.99 sky = get_sky(NSIDE, MODEL) self.instrument = get_instrument(INSTRUMENT) self.freq_maps = get_observation(self.instrument, sky) self.components = [cm.CMB(), cm.Dust(200.), cm.Synchrotron(100.)] freefree = cm.PowerLaw(100.) freefree.defaults = [-2.14] # Otherwise it is the same as Synchrotron self.components.append(freefree) self.input = [] for component in self.components: self.input += component.defaults component.defaults = [d * X0_FACTOR for d in component.defaults]
def setUp(self): self.DX = 5e-4 # NOTE: this is a bit fine-tuned np.random.seed(0) self.n_freq = 6 self.nu = np.logspace(1, 2.5, self.n_freq) self.n_stokes = 3 self.n_pixels = 2 self.components = [cm.CMB(), cm.Dust(200.), cm.Synchrotron(70.)] self.mm = MixingMatrix(*(self.components)) self.params = [1.54, 20, -3] self.A = self.mm.eval(self.nu, *(self.params)) self.A_dB = self.mm.diff(self.nu, *(self.params)) self.A_dBdB = self.mm.diff_diff(self.nu, *(self.params)) self.invN = uniform(size=(self.n_pixels, self.n_stokes, self.n_freq, self.n_freq)) self.invN += _T(self.invN) self.invN += 10 * np.eye(self.n_freq) self.invN *= 10
def setUp(self): NSIDE = 16 MODEL = 'c1d0s0f1' INSTRUMENT = 'litebird' X0_FACTOR = 0.99 sky = pysm.Sky(get_sky(NSIDE, MODEL)) self.instrument = pysm.Instrument(get_instrument(INSTRUMENT, NSIDE)) with suppress_stdout(): self.freq_maps, self.noise = self.instrument.observe( sky, write_outputs=False) self.components = [cm.CMB(), cm.Dust(200.), cm.Synchrotron(100.)] freefree = cm.PowerLaw(100.) freefree.defaults = [-2.14] # Otherwise it is the same as Synchrotron self.components.append(freefree) self.input = [] for component in self.components: self.input += component.defaults component.defaults = [d * X0_FACTOR for d in component.defaults]