コード例 #1
0
# ... and we apodize it
mask = so_window.create_apodization(mask,
                                    apo_type="C1",
                                    apo_radius_degree=apo_radius_degree_mask)
# the window is given by the product of the survey window and the mask window
window.data *= mask.data

# let's look at it
window.plot(file_name="%s/window" % (test_dir), hp_gnomv=(lon, lat, 3500, 1))

print("Compute spin0 power spectra a la pspy")
t0 = time.time()
# Compute spin 0 spectra a la pspy
mbb_inv, Bbl = so_mcm.mcm_and_bbl_spin0(window,
                                        binning_file,
                                        lmax=lmax,
                                        type=type,
                                        niter=niter)
alm = sph_tools.get_alms(split, window, niter, lmax)
l, ps = so_spectra.get_spectra(alm)
lb, Cb_pspy = so_spectra.bin_spectra(l,
                                     ps,
                                     binning_file,
                                     lmax,
                                     type=type,
                                     mbb_inv=mbb_inv)
print("pspy run in %.2f s" % (time.time() - t0))

# Compute spin 0 spectra a la namaster
print("Compute spin0 power spectra a la namaster")
nlb = 40
コード例 #2
0
def compute_mode_coupling(window,
                          type,
                          lmax,
                          binning_file,
                          ps_method="master",
                          beam=None,
                          lmax_pad=None,
                          l_thres=None,
                          l_toep=None,
                          compute_T_only=False):
    """Compute the mode coupling corresponding the the window function

    Parameters
    ----------

    window: so_map
        the window function of the patch
    type: string
        the type of binning, either bin Cl or bin Dl
    lmax : integer
        the maximum multipole to consider for the spectra computation
    binning_file: text file
      a binning file with three columns bin low, bin high, bin mean
      note that either binning_file or bin_size should be provided
    ps_method: string
        the method for the computation of the power spectrum
        can be "master", "pseudo", or "2dflat" for now
    beam: text file
        file describing the beam of the map, expect bl to be the second column and start at l=0 (standard is : l,bl, ...)
    lmax_pad: integer
        the maximum multipole to consider for the mcm computation (optional)
        lmax_pad should always be greater than lmax
    compute_T_only: boolean
        True to compute only T spectra
    """

    bin_lo, bin_hi, bin_c, bin_size = pspy_utils.read_binning_file(
        binning_file, lmax)
    n_bins = len(bin_hi)

    fsky = enmap.area(window.data.shape, window.data.wcs) / 4. / np.pi
    fsky *= np.mean(window.data)

    if beam is not None:
        beam_data = np.loadtxt(beam)
        if compute_T_only:
            beam = beam_data[:, 1]
        else:
            beam = (beam_data[:, 1], beam_data[:, 1])

    if compute_T_only:
        if ps_method == "master":
            mbb_inv, Bbl = so_mcm.mcm_and_bbl_spin0(window,
                                                    binning_file,
                                                    bl1=beam,
                                                    lmax=lmax,
                                                    type=type,
                                                    niter=0,
                                                    lmax_pad=lmax_pad,
                                                    l_thres=l_thres,
                                                    l_toep=l_toep)

        elif ps_method == "pseudo":
            mbb_inv = np.identity(n_bins)
            mbb_inv *= 1 / fsky
    else:
        window = (window, window)
        if ps_method == "master":
            print("compute master MCM")
            mbb_inv, Bbl = so_mcm.mcm_and_bbl_spin0and2(window,
                                                        binning_file,
                                                        bl1=beam,
                                                        lmax=lmax,
                                                        type=type,
                                                        niter=0,
                                                        lmax_pad=lmax_pad,
                                                        l_thres=l_thres,
                                                        l_toep=l_toep)

        elif ps_method == "pseudo":
            mbb_inv = {}
            spin_list = ["spin0xspin0", "spin0xspin2", "spin2xspin0"]
            for spin in spin_list:
                mbb_inv[spin] = np.identity(n_bins)
                mbb_inv[spin] *= 1 / fsky
            mbb_inv["spin2xspin2"] = np.identity(4 * n_bins)
            mbb_inv["spin2xspin2"] *= 1 / fsky

    if ps_method == "2dflat":
        mbb_inv = None

    return mbb_inv