Ejemplo n.º 1
0
def get_input_alms_v0p5(
        cmb_set,
        phi_set,
        i,
        path='/scratch/r/rbond/msyriac/data/sims/signal/v0.5_lenstest/'):
    ps = powspec.read_camb_full_lens(path + "/lenspotentialCls.dat")
    lmax = config_from_yaml(path + "/args.yml")['lmax']
    ncomp = 3
    cmb_seed = seedgen.get_cmb_seed(cmb_set, i)
    phi_seed = seedgen.get_phi_seed(phi_set, i)
    phi_alm, unlensed_cmb_alm, ainfo = plensing.rand_alm(ps_lensinput=ps,
                                                         lmax=lmax,
                                                         seed=cmb_seed,
                                                         phi_seed=phi_seed,
                                                         verbose=False,
                                                         ncomp=ncomp)
    return plensing.phi_to_kappa(phi_alm), unlensed_cmb_alm
Ejemplo n.º 2
0
def get_input(input_name,set_idx,sim_idx,shape,wcs):
    if input_name=='CMB':
        cmb_type = 'LensedUnabberatedCMB'
        signal_path = sints.dconfig['actsims']['signal_path']
        cmb_file   = os.path.join(signal_path, 'fullsky%s_alm_set%02d_%05d.fits' %(cmb_type, set_idx, sim_idx))
        alms = hp.fitsfunc.read_alm(cmb_file, hdu = 1)
    elif input_name=='tSZ':
        ellmax = 8101
        ells = np.arange(ellmax)
        cyy = fgs.power_y(ells)[None,None]
        cyy[0,0][ells<2] = 0
        comptony_seed = seed_tracker.get_fg_seed(set_idx, sim_idx, 'comptony')
        alms = curvedsky.rand_alm(cyy, seed = comptony_seed,lmax=ellmax)
    elif input_name=='kappa':
        signal_path = sints.dconfig['actsims']['signal_path']
        k_file   = os.path.join(signal_path, 'fullskyPhi_alm_%05d.fits' %(sim_idx))
        palms = hp.fitsfunc.read_alm(k_file)
        from pixell import lensing as plensing
        alms = plensing.phi_to_kappa(palms)
    omap = enmap.zeros((1,)+shape[-2:],wcs)
    omap = curvedsky.alm2map(np.complex128(alms),omap,spin=0)[0]
    return omap
Ejemplo n.º 3
0
def get_kappa_alm(i, path=config['signal_path']):
    istr = str(i).zfill(5)
    fname = path + "fullskyPhi_alm_%s.fits" % istr
    return plensing.phi_to_kappa(hp.read_alm(fname))
Ejemplo n.º 4
0
    npp = maps.interp(ells, np.nan_to_num(ps_noise[1, 1] / lbeam**2.))

    # Filter
    talm_y = qe.filter_alms(alm[0], lambda x: 1. /
                            (theory.lCl('TT', x) + ntt(x)), args.lmint,
                            args.lmaxt)
    ealm_y = qe.filter_alms(alm[1], lambda x: 1. /
                            (theory.lCl('EE', x) + npp(x)), args.lminp,
                            args.lmaxp)
    balm_y = qe.filter_alms(alm[2], lambda x: 1. /
                            (theory.lCl('BB', x) + npp(x)), args.lminp,
                            args.lmaxp)

    # Inputs
    ikalm = lensing.phi_to_kappa(
        maps.change_alm_lmax(
            hp.read_alm(sim_location + "fullskyPhi_alm_%s.fits" % (sindex)),
            mlmax))

    if args.all:

        with bench.show("qe all"):
            res = qe.qe_all(
                shape,
                wcs,
                lambda x, y: theory.lCl(x, y),
                mlmax,
                talm_y,
                ealm_y,
                balm_y,
                estimators=['TT', 'TE', 'EE', 'EB', 'TB', 'mv', 'mvpol'])
        for key in res.keys():
Ejemplo n.º 5
0
ikalm = utils.change_alm_lmax(
    utils.get_kappa_alm(sindex).astype(np.complex128), mlmax)

# Cross-correlate and plot
kalms = {}
icls = hp.alm2cl(ikalm, ikalm)
ells = np.arange(len(icls))
bin_edges = np.geomspace(2, mlmax, 15)
print(bin_edges)
binner = stats.bin1D(bin_edges)
bin = lambda x: binner.bin(ells, x)
print(ells.shape)
for est in ests:
    pl = io.Plotter('CL')
    pl2 = io.Plotter('rCL', xyscale='loglin')
    kalms[est] = plensing.phi_to_kappa(
        hp.almxfl(recon[est][0].astype(np.complex128),
                  Als[est][0]))  # ignore curl
    pl.add(ells, (ells * (ells + 1.) / 2.)**2. * Als[est][0], ls='--')
    cls = hp.alm2cl(kalms[est], ikalm)
    acls = hp.alm2cl(kalms[est], kalms[est])
    pl.add(ells, acls, label='r x r')
    pl.add(ells, cls, label='r x i')
    pl.add(ells, icls, label='i x i')
    pl2.add(*bin((cls - icls) / icls), marker='o')
    pl2.hline(y=0)
    pl2._ax.set_ylim(-0.1, 0.1)
    pl2.done(f'simple_recon_diff_{est}.png')
    pl._ax.set_ylim(1e-9, 1e-5)
    pl.done(f'simple_recon_{est}.png')
Ejemplo n.º 6
0
    kmap_func = {'rdn0': get_kmap_rdn0, 'mcn1': get_kmap_mcn1}

else:

    # This is the filtered map loading function that RDN0 and MCN1 will use
    kmap_func = {'rdn0': get_kmap, 'mcn1': get_kmap}

# Let's make a single map and cross-correlate with input
if rank == 0:
    # Get kappa alm
    ikalm = utils.change_alm_lmax(
        utils.get_kappa_alm(1999).astype(np.complex128),
        mlmax)  # TODO: fix hardcoding

    # New convention in falafel means maps are potential; we convert to convergence
    r_nobh_1 = plensing.phi_to_kappa(q_nobh_1(Xdat, Xdat))
    r_nobh_2 = plensing.phi_to_kappa(q_nobh_2(Xdat, Xdat))

    uicls = cs.alm2cl(ikalm, ikalm)
    uxcls_nobh_1 = cs.alm2cl(r_nobh_1[0], ikalm)
    uxcls_nobh_2 = cs.alm2cl(r_nobh_2[0], ikalm)
    uacls_nobh = cs.alm2cl(r_nobh_1, r_nobh_2)
    np.save(f'{opath}uicls_{e1}_{e2}.npy', uicls)
    np.save(f'{opath}uxcls_nobh_1_{e1}_{e2}.npy', uxcls_nobh_1)
    np.save(f'{opath}uxcls_nobh_2_{e1}_{e2}.npy', uxcls_nobh_2)
    np.save(f'{opath}uacls_nobh_{e1}_{e2}.npy', uacls_nobh)

    if bh:
        r_bh_1 = plensing.phi_to_kappa(q_bh_1(Xdat, Xdat))
        r_bh_2 = plensing.phi_to_kappa(q_bh_2(Xdat, Xdat))
        uxcls_bh_1 = cs.alm2cl(r_bh_1[0], ikalm)
Ejemplo n.º 7
0
    uacls_bh = []

# Let's make a single map and cross-correlate with input
for task in my_tasks:
    with bench.show("iKALM"):
        # Get kappa alm
        ikalm = utils.change_alm_lmax(
            utils.get_kappa_alm(task).astype(np.complex128), mlmax)

    with bench.show("Xdat"):
        # Get data
        Xdat = get_kmap((0, 0, task))

    with bench.show("QE"):
        # New convention in falafel means maps are potential; we convert to convergence
        r_nobh_1 = plensing.phi_to_kappa(q_nobh_1(Xdat, Xdat))
        r_nobh_2 = plensing.phi_to_kappa(q_nobh_2(
            Xdat, Xdat)) if not (diag) else r_nobh_1.copy()

    with bench.show("alm2cl and append"):
        uicl = cs.alm2cl(ikalm, ikalm)
        uxcl_nobh_1 = cs.alm2cl(r_nobh_1[0], ikalm)
        uxcl_nobh_2 = cs.alm2cl(r_nobh_2[0], ikalm)
        uacl_nobh = cs.alm2cl(r_nobh_1[0], r_nobh_2[0])

        uicls.append(uicl)
        uxcls_nobh_1.append(uxcl_nobh_1)
        uxcls_nobh_2.append(uxcl_nobh_2)
        uacls_nobh.append(uacl_nobh)

        if bh: