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_dust_one_parameter(self): NSIDE = 8 MODEL = 'd0' INSTRUMENT = 'litebird' SIGNAL_TO_NOISE = 10 sky = pysm.Sky(get_sky(NSIDE, MODEL)) instrument = pysm.Instrument(get_instrument(INSTRUMENT, NSIDE)) components = [cm.Dust(100., temp=20.)] 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 = 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=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 = 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_Sigma_dust_one_parameter(self): NSIDE = 8 MODEL = 'd0' INSTRUMENT = 'LiteBIRD' SIGNAL_TO_NOISE = 10 sky = get_sky(NSIDE, MODEL) instrument = get_instrument(INSTRUMENT) components = [cm.Dust(100., temp=20.)] 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 = 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=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 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]