ps = Dlth[spec] + flth[:lmax] if kind == "cross": ps_th[spec] = ps elif kind == "noise": ps_th[spec] = nlth[spec] elif kind == "auto": ns = len(d["maps_%s_%s" % (sv1, ar1)]) ps_th[spec] = ps + nlth[spec] * ns theory[sv1, ar1, sv2, ar2, kind] = ps_th bin_theory[sv1, ar1, sv2, ar2, kind] = so_mcm.apply_Bbl(Bbl, ps_th, spectra=spectra) os.system("cp %s/multistep2.js %s/multistep2.js" % (multistep_path, plot_dir)) filename = "%s/SO_spectra.html" % plot_dir g = open(filename, mode='w') g.write('<html>\n') g.write('<head>\n') g.write('<title> SO spectra </title>\n') g.write('<script src="multistep2.js"></script>\n') g.write('<script> add_step("sub", ["c","v"]) </script> \n') g.write('<script> add_step("all", ["j","k"]) </script> \n') g.write('<script> add_step("type", ["a","z"]) </script> \n') g.write('</head> \n') g.write('<body> \n') g.write('<div class=sub> \n')
continue spec_name = "%s_%s_%sx%s_%s" % (type, sv1, ar1, sv2, ar2) lb, Db = so_spectra.read_ps( spec_dir + "/%s_cross_00000.dat" % spec_name, spectra=spectra ) if chi2_with_respect_to_theory: spin_pairs = ["spin0xspin0", "spin0xspin2", "spin2xspin0", "spin2xspin2"] clfile = "%s/lcdm.dat" % bestfit_dir lth, Dlth = pspy_utils.ps_lensed_theory_to_dict( clfile, output_type=type, lmax=lmax, start_at_zero=False ) 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) Db_th = so_mcm.apply_Bbl(Bbl, Dlth, spectra=spectra) n_bins = len(lb) cov = cov_EB[ spec_id * n_bins : (spec_id + 1) * n_bins, spec_id * n_bins : (spec_id + 1) * n_bins, ] # Let's only use the diagonal element (the rest is too noisy given the number of sim) cov = np.diag(np.diagonal(cov)) inv_cov = np.linalg.inv(cov) # This bit is doing a mcmc fit for alpha def compute_loglike_data(alpha): chi2 = compute_chi2_data(Db, inv_cov, alpha) return -0.5 * chi2
flth_all = 0 for foreground in fg_components[spec.lower()]: l, flth = np.loadtxt("%s/%s_%s_%sx%s.dat" % (fg_dir,spec.lower(), foreground, f1, f2) ,unpack=True) flth_all += flth[:lmax] ps = Dlth[spec] + flth_all if kind == "cross": ps_th[spec] = ps elif kind == "noise": ps_th[spec] = nlth[spec] * lth**2 / (2 * np.pi) elif kind == "auto": ps_th[spec] = ps + nlth[spec] * lth**2 / (2 * np.pi) * ns[exp1] theory[exp1, f1, exp2, f2, kind] = ps_th bin_theory[exp1, f1, exp2, f2, kind] = so_mcm.apply_Bbl(Bbl, ps_th, spectra=spectra) os.system("cp %s/multistep2.js %s/multistep2.js" % (multistep_path, plot_dir)) filename = "%s/SO_spectra.html" % plot_dir g = open(filename, mode='w') g.write('<html>\n') g.write('<head>\n') g.write('<title> SO spectra </title>\n') g.write('<script src="multistep2.js"></script>\n') g.write('<script> add_step("sub", ["c","v"]) </script> \n') g.write('<script> add_step("all", ["j","k"]) </script> \n') g.write('<script> add_step("type", ["a","z"]) </script> \n') g.write('</head> \n') g.write('<body> \n') g.write('<div class=sub> \n')
# we will compare simulation power spectrum to theory # we need to add foreground in TT lth, Dlth = pspy_utils.ps_lensed_theory_to_dict(clfile, output_type=type, lmax=lmax, start_at_zero=False) n1, n2 = spec.split("x") nu_eff_1 = d["nu_eff_%s" % (n1)] nu_eff_2 = d["nu_eff_%s" % (n2)] _, flth = np.loadtxt("%s/fg_%sx%s_TT.dat" % (bestfit_dir, nu_eff_1, nu_eff_2), unpack=True) Dlth["TT"] = Dlth["TT"] + flth[:lmax] bin_theory = so_mcm.apply_Bbl(Bbl, Dlth, spectra=spectra) mean, std = {}, {} for spectrum in ["TT", "EE", "BB"]: nofilt_list = [] filt_list = [] tf_list = [] for iii in range(iStart, iStop): spec_name_no_filter = "%s_%s_nofilter_standard_%05d" % (type, spec, iii) spec_name_filter = "%s_%s_filter_standard_%05d" % (type, spec, iii)