Ejemplo n.º 1
0
def qu2eb(qmap, umap):
    import polTools

    qtemp = qmap.to_flipper()
    utemp = umap.to_flipper()
    emap, bmap = polTools.convertToEB(qtemp, utemp, True, False) 

    emap = enmap.from_flipper(emap)
    bmap = enmap.from_flipper(bmap)

    return (emap, bmap)
Ejemplo n.º 2
0
def get_sim(sim_idx):
    ret = act_sim.getActpolCmbSim(None, coords, sim_idx, cmb_dir, doBeam=False, pixelFac= 2)
     
    for i in range(len(ret)):
        ret[i]  = enmap.from_flipper(ret[i])
        ret[i] -= np.mean(ret[i])
    return (ret[0], ret[1], ret[2]) # TQU
Ejemplo n.º 3
0
def get_sim(sim_idx, beam_fwhm=beam_fwhm, noise_level=noise_level):
    ret = act_sim.getActpolCmbSim(None,
                                  coords,
                                  sim_idx,
                                  cmb_dir,
                                  doBeam=False,
                                  pixelFac=1)

    np.random.seed(sim_idx)

    # handle mean
    for i in range(len(ret)):
        ret[i].data -= np.mean(ret[i].data)
        ret[i] = enmap.from_flipper(ret[i])

    # beam convolve
    owcs, shape = (ret[0].wcs.copy(), ret[0].shape)
    tqu = np.zeros((3, ) + ret[0].shape)
    tqu[0], tqu[1], tqu[2] = (ret[0], ret[1], ret[2])
    tqu = enmap.enmap(tqu, owcs)
    alm = curvedsky.map2alm(tqu, lmax=lmax)
    del ret

    _, beam = cmblens.theory.get_gauss_beam(np.arange(lmax + 1), beam_fwhm)
    fl = np.sqrt(beam)

    log.info("beam convolution")
    for i in range(alm.shape[0]):
        alm[i] = hp.sphtfunc.almxfl(alm[i], fl)

    tqu = curvedsky.alm2map(alm[:, None], tqu.copy()[:, None])[:, 0]

    if noise_level > 0:
        log.info("adding noise")
        for i in range(len(tqu)):
            noise = enmap.to_flipper(tqu[i]).getTemplate()
            l_n = np.arange(lmax + 1000)
            noise_fact = 1. if i == 0 else np.sqrt(2)
            nl = cmblens.theory.get_white_noise_power(l_n,
                                                      noise_level * noise_fact)
            ps = nl.reshape((1, 1, nl.size))
            noise = curvedsky.rand_map(shape, owcs, ps, lmax=(lmax + 1000))
            #noise.fillWithGaussianRandomField(l_n, nl, bufferFactor=1)
            tqu[i] += noise
            del noise

    # beam deconvolve
    log.info("beam deconvolution")
    alm = curvedsky.map2alm(tqu, lmax=lmax)
    for i in range(alm.shape[0]):
        alm[i] = hp.sphtfunc.almxfl(alm[i], 1. / fl)
    tqu = curvedsky.alm2map(alm[:, None], tqu.copy()[:, None])[:, 0]

    return (tqu[0], tqu[1], tqu[2])  # TQU
Ejemplo n.º 4
0
def get_sim(sim_idx, mode='flat'):
    assert (mode in ['flat', 'actsim'])

    ret = None
    if mode == 'flat':
        assert (False)
        ret = mg.get_map(seed=sim_idx)
    elif mode == 'actsim':
        ret = act_sim.getActpolCmbSim(None,
                                      coords,
                                      sim_idx,
                                      cmb_dir,
                                      doBeam=False)
    else:
        assert (1)

    for i in range(len(ret)):
        ret[i] = enmap.from_flipper(ret[i])
        ret[i] -= np.mean(ret[i])
    return (ret[0], ret[1], ret[2])  # TQU