示例#1
0
def get_bbl(ea, fa, pa, eb, fb, pb):

    spin_pairs = ["spin0xspin0", "spin0xspin2", "spin2xspin0", "spin2xspin2"]

    prefix = "%s/%s_%sx%s_%s" % (mcm_dir, ea, fa, eb, fb)
    mbb_inv, Bbl = so_mcm.read_coupling(prefix=prefix, spin_pairs=spin_pairs)

    Bbl_TT = Bbl["spin0xspin0"]
    Bbl_TE = Bbl["spin0xspin2"]
    Bbl_EE = Bbl["spin2xspin2"][:Bbl_TE.shape[0], :Bbl_TE.shape[1]]

    px = pa + pb
    if px in ["EE", "EB", "BE", "BB"]:
        return Bbl_EE
    elif px in ["TE", "TB", "ET", "BT"]:
        return Bbl_TE
    else:
        return Bbl_TT
                freqs2 = d["freqs_%s" % exp2]
                nsplits2 = d["nsplits_%s" % exp2]

                for id_f2, f2 in enumerate(freqs2):

                    if (id_exp1 == id_exp2) & (id_f1 > id_f2): continue
                    if (id_exp1 > id_exp2): continue

                    for spec in spectra:
                        ps_dict[spec, "auto"] = []
                        ps_dict[spec, "cross"] = []

                    for s1 in range(nsplits1):
                        for s2 in range(nsplits2):
                            mbb_inv, Bbl = so_mcm.read_coupling(
                                prefix="%s/%s_%sx%s_%s" %
                                (mcm_dir, exp1, f1, exp2, f2),
                                spin_pairs=spin_pairs)

                            l, ps_master = so_spectra.get_spectra(
                                master_alms[exp1, f1, s1],
                                master_alms[exp2, f2, s2],
                                spectra=spectra)

                            spec_name = "%s_%s_%s_%dx%s_%s_%d_%05d" % (
                                type, exp1, f1, s1, exp2, f2, s2, iii)

                            lb, ps = so_spectra.bin_spectra(l,
                                                            ps_master,
                                                            binning_file,
                                                            lmax,
                                                            type=type,
示例#3
0
            for id_ar2, ar2 in enumerate(arrays_2):


                if  (id_sv1 == id_sv2) & (id_ar1 > id_ar2) : continue
                if  (id_sv1 > id_sv2) : continue

                for spec in spectra:
                    ps_dict[spec, "auto"] = []
                    ps_dict[spec, "cross"] = []
                
                for s1 in range(nsplits_1):
                    for s2 in range(nsplits_2):
                        if (sv1 == sv2) & (ar1 == ar2) & (s1>s2) : continue
                    
                        mbb_inv, Bbl = so_mcm.read_coupling(prefix="%s/%s_%sx%s_%s" % (mcm_dir, sv1, ar1, sv2, ar2),
                                                            spin_pairs=spin_pairs)

                        l, ps_master = so_spectra.get_spectra_pixell(master_alms[sv1, ar1, s1],
                                                                     master_alms[sv2, ar2, s2],
                                                                     spectra=spectra)
                                                              
                        spec_name="%s_%s_%sx%s_%s_%d%d" % (type, sv1, ar1, sv2, ar2, s1, s2)
                        
                        lb, ps = so_spectra.bin_spectra(l,
                                                        ps_master,
                                                        binning_file,
                                                        lmax,
                                                        type=type,
                                                        mbb_inv=mbb_inv,
                                                        spectra=spectra)
                                                        
示例#4
0
                if sv1 == sv2:
                    lb, nlth = so_spectra.read_ps(
                        "%s/mean_%sx%s_%s_noise.dat" %
                        (noise_dir, ar1, ar2, sv1),
                        spectra=spectra)
                    for spec in spectra:
                        nlth[spec] /= (bl1 * bl2)
                else:
                    nlth = {}
                    for spec in spectra:
                        nlth[spec] = np.zeros(lmax)

                prefix = "%s/%s_%sx%s_%s" % (mcm_dir, sv1, ar1, sv2, ar2)

                mbb_inv, Bbl = so_mcm.read_coupling(prefix=prefix,
                                                    spin_pairs=spin_pairs)

                for kind in ["cross", "noise", "auto"]:

                    if (sv1 != sv2) & (kind == "noise"): continue
                    if (sv1 != sv2) & (kind == "auto"): continue

                    ps_th = {}
                    for spec in spectra:
                        ps = Dlth[spec].copy()
                        if spec == "TT":

                            nu_eff_1 = d["nu_eff_%s_%s" % (sv1, ar1)]
                            nu_eff_2 = d["nu_eff_%s_%s" % (sv2, ar2)]

                            _, flth = np.loadtxt(
                                              nl_all, "EEET")
    analytic_cov[3 * nbins:4 * nbins,
                 1 * nbins:2 * nbins] = so_cov.bin_mat(M_31, binning_file,
                                                       lmax)

    # EaEbEcTd
    M_32 = coupling["PaPcPbTd"] * so_cov.chi(na, nc, nb, nd, ns, ps_all,
                                             nl_all, "EEET")
    M_32 += coupling["PaTdPbPc"] * so_cov.chi(na, nd, nb, nc, ns, ps_all,
                                              nl_all, "ETEE")
    analytic_cov[3 * nbins:4 * nbins,
                 2 * nbins:3 * nbins] = so_cov.bin_mat(M_32, binning_file,
                                                       lmax)

    mbb_inv_ab, Bbl_ab = so_mcm.read_coupling(prefix="%s/%sx%s" %
                                              (mcm_dir, na, nb),
                                              spin_pairs=spin_pairs)
    mbb_inv_ab = so_cov.extract_TTTEEE_mbb(mbb_inv_ab)

    mbb_inv_cd, Bbl_cd = so_mcm.read_coupling(prefix="%s/%sx%s" %
                                              (mcm_dir, nc, nd),
                                              spin_pairs=spin_pairs)
    mbb_inv_cd = so_cov.extract_TTTEEE_mbb(mbb_inv_cd)

    #transpose = analytic_cov.copy().T
    #transpose[analytic_cov != 0] = 0
    #analytic_cov += transpose

    #analytic_cov = np.triu(analytic_cov) + np.tril(analytic_cov.T, -1)

    analytic_cov = np.dot(np.dot(mbb_inv_ab, analytic_cov), mbb_inv_cd.T)
示例#6
0
spin_pairs = ['spin0xspin0', 'spin0xspin2', 'spin2xspin0', 'spin2xspin2']

Db_dict = {}
spec_name_list = []
for c1, freq1 in enumerate(freqs):
    for c2, freq2 in enumerate(freqs):
        if c1 > c2: continue
        for s1, hm1 in enumerate(splits):
            for s2, hm2 in enumerate(splits):
                if (s1 > s2) & (c1 == c2): continue

                prefix = '%s/%s_%sx%s_%s-%sx%s' % (mcmDir, experiment, freq1,
                                                   experiment, freq2, hm1, hm2)

                mcm_inv, mbb_inv, Bbl = so_mcm.read_coupling(
                    prefix=prefix, spin_pairs=spin_pairs, unbin=True)

                l, ps = so_spectra.get_spectra(alms[hm1, freq1],
                                               alms[hm2, freq2],
                                               spectra=spectra)
                spec_name = '%s_%sx%s_%s-%sx%s' % (experiment, freq1,
                                                   experiment, freq2, hm1, hm2)
                l, cl, lb, Db = planck_utils.process_planck_spectra(
                    l,
                    ps,
                    binning_file,
                    lmax,
                    type=type,
                    mcm_inv=mcm_inv,
                    spectra=spectra)
                spec_name_list += [spec_name]
示例#7
0
    win["Td"] = so_map.read_map(d["window_T_%s" % nd_r])
    win["Pa"] = so_map.read_map(d["window_pol_%s" % na_r])
    win["Pb"] = so_map.read_map(d["window_pol_%s" % nb_r])
    win["Pc"] = so_map.read_map(d["window_pol_%s" % nc_r])
    win["Pd"] = so_map.read_map(d["window_pol_%s" % nd_r])

    coupling = so_cov.cov_coupling_spin0and2_simple(win,
                                                    lmax,
                                                    niter=niter,
                                                    l_exact=l_exact,
                                                    l_band=l_band,
                                                    l_toep=l_toep)

    try:
        mbb_inv_ab, Bbl_ab = so_mcm.read_coupling(prefix="%s/%sx%s" %
                                                  (mcms_dir, na_r, nb_r),
                                                  spin_pairs=spin_pairs)
    except:
        mbb_inv_ab, Bbl_ab = so_mcm.read_coupling(prefix="%s/%sx%s" %
                                                  (mcms_dir, nb_r, na_r),
                                                  spin_pairs=spin_pairs)

    try:
        mbb_inv_cd, Bbl_cd = so_mcm.read_coupling(prefix="%s/%sx%s" %
                                                  (mcms_dir, nc_r, nd_r),
                                                  spin_pairs=spin_pairs)
    except:
        mbb_inv_cd, Bbl_cd = so_mcm.read_coupling(prefix="%s/%sx%s" %
                                                  (mcms_dir, nd_r, nc_r),
                                                  spin_pairs=spin_pairs)
                name_list += ["%s%s" % (field, s)]
                id_list += ["%s%s" % (field, id)]

        Clth_dict = {}
        for name1, id1 in zip(name_list, id_list):
            for name2, id2 in zip(name_list, id_list):
                spec = id1[0] + id2[0]
                Clth_dict[id1 +
                          id2] = ps_theory[spec] + nl_th[spec] * so_cov.delta2(
                              name1, name2)

        window = so_map.read_map("%s/window_%s_%s.fits" %
                                 (window_dir, scan, run))

        mbb_inv, Bbl = so_mcm.read_coupling(prefix="%s/%s_%s" %
                                            (mcm_dir, scan, run),
                                            spin_pairs=spin_pairs)

        coupling_dict = so_cov.cov_coupling_spin0and2_simple(window,
                                                             lmax,
                                                             niter=niter,
                                                             planck=False)
        analytic_cov = so_cov.cov_spin0and2(Clth_dict, coupling_dict,
                                            binning_file, lmax, mbb_inv,
                                            mbb_inv)

        fsky[scan, run], quick_cov = SO_noise_utils.quick_analytic_cov(
            lth, Clth_dict, window, binning_file, lmax)

        np.save("%s/analytic_cov_%s_%s.npy" % (cov_dir, scan, run),
                analytic_cov)
示例#9
0
            print(f"Adding {f1}x{f2} GHz - {spec} spectra")
            # Set sacc tracer type and names
            pa, pb = spec
            ta_name = f"ACT_{f1}_s0" if pa == "T" else f"ACT_{f1}_s2"
            tb_name = f"ACT_{f2}_s0" if pb == "T" else f"ACT_{f2}_s2"

            map_types = {"T": "0", "E": "e", "B": "b"}
            if pb == "T":
                cl_type = "cl_" + map_types[pb] + map_types[pa]
            else:
                cl_type = "cl_" + map_types[pa] + map_types[pb]

            # Get Bbl
            mbb_inv, Bbl = so_mcm.read_coupling(
                os.path.join(mcm_dir, f"dr6_pa4_f150xdr6_pa4_f150"),
                spin_pairs=[
                    "spin0xspin0", "spin0xspin2", "spin2xspin0", "spin2xspin2"
                ],
            )
            Bbl_TT = Bbl["spin0xspin0"]
            Bbl_TE = Bbl["spin0xspin2"]
            Bbl_EE = Bbl["spin2xspin2"][:Bbl_TE.shape[0], :Bbl_TE.shape[1]]

            if spec in ["EE", "EB", "BE", "BB"]:
                Bbl = Bbl_EE
            elif spec in ["TE", "TB", "ET", "BT"]:
                Bbl = Bbl_TE
            else:
                Bbl = Bbl_TT
            ls_w = np.arange(2, Bbl.shape[-1] + 2)
            bp_window = sacc.BandpowerWindow(ls_w, Bbl.T)
示例#10
0
    bl_tuple = (bl, bl)

    if recompute_mcm == True:
        mbb_inv, Bbl = so_mcm.mcm_and_bbl_spin0and2(window_tuple,
                                                    binning_file,
                                                    niter=niter,
                                                    bl1=bl_tuple,
                                                    lmax=lmax,
                                                    type=type,
                                                    save_file='%s/%s' %
                                                    (mcmDir, ar))
    else:
        spin_pairs = [
            'spin0xspin0', 'spin0xspin2', 'spin2xspin0', 'spin2xspin2'
        ]
        mbb_inv, Bbl = so_mcm.read_coupling(prefix='%s/%s' % (mcmDir, ar),
                                            spin_pairs=spin_pairs)

    almList = []
    nameList = []

    map_T = d['map_T_%s' % ar][0]
    map_Q = d['map_Q_%s' % ar][0]
    map_U = d['map_U_%s' % ar][0]

    print("compute harmonic transform ...")

    so_mpi.init(True)
    subtasks = so_mpi.taskrange(imin=d['iStart'], imax=d['iStop'])

    for iii in range(subtasks):
        t0 = time.time()