Пример #1
0
    def format_toepliz(coupling, l_toep, lmax):
        """take a matrix and apply the toepliz appoximation
        Parameters
        ----------

        toepliz_array: array
        consist of an array where the upper part is the exact matrix and
        the lower part is the diagonal. We will feed the off diagonal
        of the lower part using the measurement of the correlation from the exact computatio
        l_toep: integer
        the l at which we start the approx
        lmax: integer
        the maximum multipole of the array

        """

        toepliz_array = coupling.copy() * 0
        diag = np.sqrt(np.diag(coupling))
        corr = so_cov.cov2corr(coupling, remove_diag=False)

        for ell in range(0, l_toep - 2):
            toepliz_array[ell:ell + lmax - (l_toep - 2),
                          ell] = corr[l_toep - 2:lmax, l_toep - 2]
        for ell in range(l_toep - 2, lmax):
            pix = ell - (l_toep - 2)
            toepliz_array[ell:, ell] = corr[l_toep - 2:lmax - pix, l_toep - 2]

        toepliz_array = toepliz_array * np.outer(diag, diag)
        toepliz_array = toepliz_array + toepliz_array.T - np.diag(
            np.diag(toepliz_array))

        return toepliz_array
Пример #2
0
    def toeplitz(coupling, lmax):
        toepliz_array = coupling.copy() * 0
        diag = np.sqrt(np.diag(coupling))
        corr = so_cov.cov2corr(coupling, remove_diag=False)
        last_column = corr[:, lmax - 1]

        for ell in range(lmax):
            toepliz_array[:ell + 1, ell] = last_column[lmax - 1 - ell:lmax]

        toepliz_array = toepliz_array * np.outer(diag, diag)
        toepliz_array = toepliz_array + toepliz_array.T - np.diag(
            np.diag(toepliz_array))

        return toepliz_array
Пример #3
0
            plt.plot(lb[1:],
                     var[1:] / analytic_var[1:],
                     label="MC/Analytic %sx%s" % (bl[:2], bl[2:4]))
            if count == 1:
                plt.ylabel(r"Ratio $Cov_{i,i,\ell}$", fontsize=22)
            if count == 4:
                plt.xlabel(r"$\ell$", fontsize=22)
            plt.legend()
            count += 1
        plt.savefig("%s/covariance_pseudo_diagonal_ratio_%s_%s.png" %
                    (cov_plot_dir, spec1, spec2),
                    bbox_inches="tight")
        plt.clf()
        plt.close()

        analytic_corr = so_cov.cov2corr(analytic_cov)
        mc_corr = so_cov.cov2corr(mc_cov)

        plt.figure(figsize=(15, 15))
        plt.suptitle(
            "%s %s (press c/v to switch between covariance matrix elements)" %
            (spec1, spec2),
            fontsize=30)
        count = 1
        for bl in [
                "TTTT", "TETE", "ETET", "EEEE", "TTTE", "TTEE", "TTET", "TEET",
                "TEEE", "ETEE", "EETE", "EEET", "ETTE", "ETTT", "EETT", "TETT"
        ]:

            mc_corr_sub = so_cov.selectblock(mc_corr, ["TT", "TE", "ET", "EE"],
                                             n_bins,
cl_00 = compute_master(f0, f0, w00)
n_ell = len(cl_00[0])

cw = nmt.NmtCovarianceWorkspace()
cw.compute_coupling_coefficients(f0, f0, f0, f0)
covar_00_00 = nmt.gaussian_covariance(cw,
                                      0,
                                      0,
                                      0,
                                      0, [cl_tt], [cl_tt], [cl_tt], [cl_tt],
                                      w00,
                                      wb=w00).reshape([n_ell, 1, n_ell, 1])

cov_namaster = covar_00_00[:, 0, :, 0]

corr_pspy = so_cov.cov2corr(cov_pspy)
plt.matshow(corr_pspy, vmin=-0.3, vmax=0.3)
plt.savefig("%s/corr_pspsy.png" % (test_dir))
plt.clf()
plt.close()

corr_namaster = so_cov.cov2corr(cov_namaster)
plt.matshow(corr_namaster, vmin=-0.3, vmax=0.3)
plt.savefig("%s/corr_namaster.png" % (test_dir))
plt.clf()
plt.close()

print("cov mat sim")
nsims = 1000
Db_list = []
for iii in range(nsims):
Пример #5
0
from pspy import so_dict, so_cov, pspy_utils
import cov_plot_utils
import numpy as np
import sys

d = so_dict.so_dict()
d.read_from_file(sys.argv[1])

run_name = d["run_name"]
plot_dir = "plot_%s" % run_name

pspy_utils.create_directory(plot_dir)

coupling_dir = "coupling_%s" % run_name

name_list = ["00", "02", "20", "++", "--"]
mcm_dict = {}

cov_plot_utils.residual_plot(plot_dir,
                             coupling_dir,
                             d["clfile"],
                             9998,
                             vmax=5 * 10**-6)

for id_mcm, name in enumerate(name_list):
    coupling = np.load("%s/coupling_exact_%s.npy" % (coupling_dir, name))
    corr = so_cov.cov2corr(coupling, remove_diag=False)
    cov_plot_utils.toepliz_plot(plot_dir, corr, name, lsplit=2500)