Пример #1
0
    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)
Пример #2
0
    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}'
Пример #3
0
    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
Пример #4
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]
Пример #5
0
    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)
Пример #6
0
    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])
Пример #7
0
def estimate_Stat_and_Sys_residuals(
    idpatches,
    galactic_binmask,
    parameter_string,
    randomseed=1234567,
    version="v28",
    instrument_conf="LiteBIRD",
):

    nside = hp.get_nside(galactic_binmask)
    v = {
        "v27": np.array(
            [
                39.76,
                25.76,
                20.69,
                12.72,
                10.39,
                8.95,
                6.43,
                4.3,
                4.43,
                4.86,
                5.44,
                9.72,
                12.91,
                19.07,
                43.53,
            ]
        ),
        "v28": np.array(
            [
                59.29,
                32.78,
                25.76,
                15.91,
                13.10,
                11.25,
                7.74,
                5.37,
                5.65,
                5.81,
                6.48,
                15.16,
                17.98,
                24.99,
                49.90,
            ]
        ),
    }

    sens_I_LB = np.array(
        [
            25.60283688,
            13.90070922,
            14.32624113,
            8.0141844,
            7.30496454,
            5.95744681,
            4.96453901,
            4.11347518,
            3.33333333,
            4.96453901,
            4.11347518,
            5.67375887,
            6.45390071,
            8.08510638,
            13.90070922,
        ]
    )
    skyconst = get_sky(nside, "d0s0")

    instrument = get_instrument(instrument_conf)
    instrument.depth_i = sens_I_LB
    instrument.depth_p = v["v28"]
    patches = np.zeros_like(galactic_binmask, dtype=np.int_)

    patches[galactic_binmask] = np.int_(idpatches) + 1

    skyvar, patchlist = fitting_parameters(parameter_string, nside, patches)

    np.random.seed(seed=randomseed)

    signalvar = get_observation(instrument, skyvar, noise=False)

    signoisemaps = get_observation(instrument, skyconst, noise=True)

    signalvar[:, :, ~galactic_binmask] = hp.UNSEEN
    signoisemaps[:, :, ~galactic_binmask] = hp.UNSEEN
    components = [CMB(), Synchrotron(20), Dust(353)]

    sysresult = adaptive_comp_sep(components, instrument, signalvar[:, 1:], patchlist)
    statresult = adaptive_comp_sep(
        components, instrument, signoisemaps[:, 1:], patchlist
    )

    msys = np.zeros_like(signalvar[0])
    mstat = np.zeros_like(signoisemaps[0])

    # Mask eventually unconstrained pixels
    for i in range(2):
        nan = np.ma.masked_invalid(sysresult.s[0, i]).mask

        msys[i + 1, :] = sysresult.s[0, i]
        msys[i + 1, nan] = hp.UNSEEN

        nan = np.ma.masked_invalid(statresult.s[0, i]).mask

        mstat[i + 1, :] = statresult.s[0, i]
        mstat[i + 1, nan] = hp.UNSEEN
    return msys, mstat