def get_spectra_and_std(my_spec, name, test): lb, ps = so_spectra.read_ps("spectra_%s/spectra/Dl_%s_cross.dat" % (my_spec, name), spectra=spectra) lb, noise = so_spectra.read_ps("spectra_%s/spectra/Dl_%s_noise.dat" % (my_spec, name), spectra=spectra) cov = np.load("covariances_%s/covariances/analytic_cov_%s_%s.npy" % (my_spec, name, name)) cov = so_cov.selectblock(cov, ["TT", "TE", "ET", "EE"], n_bins=len(lb), block="%s%s" % (test, test)) std = np.sqrt(cov.diagonal()) return lb, ps[test], noise[test], cov, std
arrays_2 = d["arrays_%s" % sv2] for id_ar2, ar2 in enumerate(arrays_2): freq2 = d["nu_eff_%s_%s" % (sv2, ar2)] if (id_sv1 == id_sv2) & (id_ar1 > id_ar2): continue if (id_sv1 > id_sv2): continue combin = "%s_%sx%s_%s" % (sv1, ar1, sv2, ar2) spec_name = "%s_%s_%s" % (type, combin, kind) lb, Db = so_spectra.read_ps("%s/%s.dat" % (specDir, spec_name), spectra=spectra) cov = np.load("%s/analytic_cov_%s_%s.npy" % (cov_dir, combin, combin)) cov = so_cov.selectblock(cov, ["TT", "TE", "ET", "EE"], n_bins=len(lb), block="TT") std = np.sqrt(cov.diagonal()) lp, clp, errorp = np.loadtxt(planck_data_dir + "spectrum_TT_100x100.dat") plt.errorbar(lb, Db[spec], std, fmt=".", label="%s_%s" % (spec, combin), color=c)
# TT+TE+EE chi2 ps1_ttteee = np.concatenate([ps1[mode] for mode in modes]) ps2_ttteee = np.concatenate([ps2[mode] for mode in modes]) residual_ps = ps1_ttteee - ps2_ttteee chi2 = residual_ps @ np.linalg.solve(res_cov, residual_ps) chi2_dict["all", surv1, surv2, spec1, spec2] = [chi2, len(residual_ps)] line.append(chi2) ndof_line.append(len(residual_ps)) # Loop on TT, TE, ET, EE for mode in modes: # Select block res_covblock = so_cov.selectblock(res_cov, modes, n_bins=len(lb), block=mode + mode) # Compute power spectrum and errors res_std = np.sqrt(res_covblock.diagonal()) res_ps = ps1[mode] - ps2[mode] # Compute chi2 chi2 = res_ps @ np.linalg.solve(res_covblock, res_ps) chi2_dict[mode, surv1, surv2, spec1, spec2] = [chi2, len(lb)] line.append(chi2) ndof_line.append(len(lb)) # Low-ell (ell < 1000) chi2 id_low = np.where(lb < 1000) low_ps = res_ps[id_low]
for id_sv1, sv1 in enumerate(surveys): for id_sv2, sv2 in enumerate(surveys): if (id_sv1 > id_sv2): continue combin = "%s_%sx%s_%s" % (sv1, ar, sv2, ar) print("producing plots for : ", combin) spec_name = "%s_%s_%s" % (type, combin, "cross") lb, Db = so_spectra.read_ps("%s/%s.dat" % (specDir, spec_name), spectra=spectra) cov = np.load("%s/analytic_cov_%s_%s.npy" % (cov_dir, combin, combin)) cov_select = so_cov.selectblock(cov, ["TT", "TE", "ET", "EE"], n_bins=len(lb), block=spec + spec) std = np.sqrt(cov_select.diagonal()) if (sv1 == sv2): if spec == "TE": Db["TE"] = (Db["TE"] + Db["ET"]) / 2 _, f = ar.split("_") f_choi = f if f == "f220": f_choi = "f150" if spec == "TT": plt.semilogy()
binning_file, lmax) n_bins = len(bin_hi) 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_cov_sub = so_cov.selectblock(mc_cov, ["TT", "TE", "ET", "EE"], n_bins, block=bl) analytic_cov_sub = so_cov.selectblock(analytic_cov, ["TT", "TE", "ET", "EE"], n_bins, block=bl) var = mc_cov_sub.diagonal() analytic_var = analytic_cov_sub.diagonal() plt.subplot(3, 6, count) if count == 1: plt.semilogy() plt.plot(lb[1:], var[1:], ".",
pspy_utils.create_directory(plot_dir) # Check effect of weighting for bl in ["TTTT", "TETE", "EEEE"]: for scan in scan_list: for run in runs: _name = "%s_%sx%s_%s" % (scan, "split0", "split0", run) lb, _ = so_spectra.read_ps("%s/spectra_%s.dat" % (spectra_dir, _name), spectra=spectra) n_bins = len(lb) cov = np.load("%s/analytic_cov_%s_%s.npy" % (cov_dir, scan, run)) cov_select = so_cov.selectblock(cov, ["TT", "TE", "ET", "EE"], n_bins, block=bl) var = cov_select.diagonal() plt.plot(lb, np.sqrt(var), label=run) plt.title(r"$\sigma^{%s}_{\ell}$, %s" % (bl, scan), fontsize=14) plt.xlabel(r"$\ell$", fontsize=14) plt.legend() plt.savefig("%s/sigma_%s_%s.png" % (plot_dir, bl, scan), bbox_inches="tight") plt.clf() plt.close()
cov_dir + "analytic_cov_{0}_{1}.npy".format(cross_name, actxact_name)) TT_actxact = ps_actxact["TT"] TT_actxplanck = ps_actxplanck["TT"] id = np.where((lb >= lmin[act_map]) & (lb <= lmax)) TT_actxact = TT_actxact[id] TT_actxplanck = TT_actxplanck[id] TT = {"actxact": TT_actxact, "actxplanck": TT_actxplanck} for key in cov: cov[key] = so_cov.selectblock(cov[key], modes, n_bins=len(lb), block="TTTT") cov[key] = cov[key][np.ix_(id[0], id[0])] spectra_and_covariances[act_map] = (TT, cov) for act_map in reference_maps: TT, TT_cov = spectra_and_covariances[act_map] def loglike(c): #PlanckxPlanck - ACTxPLanck res_ps = c**2 * TT["actxact"] - c * TT["actxplanck"] res_cov = c**2 * (c**2 * TT_cov["actxact_actxact"] + TT_cov["actxplanck_actxplanck"] - 2 * c * TT_cov["actxact_actxplanck"])