for id_ar2, ar2 in enumerate(arrays): if id_ar1 > id_ar2: continue l, bl_ar1 = pspy_utils.read_beam_file(d["beam_%s_%s" % (sv, ar1)]) l, bl_ar2 = pspy_utils.read_beam_file(d["beam_%s_%s" % (sv, ar2)]) lb, bb_ar1 = pspy_utils.naive_binning(l, bl_ar1, binning_file, lmax) lb, bb_ar2 = pspy_utils.naive_binning(l, bl_ar2, binning_file, lmax) nsplits = len(d["maps_%s_%s" % (sv, ar1)]) spec_name_noise = "%s_%s_%sx%s_%s_noise" % (type, sv, ar1, sv, ar2) print(spec_name_noise) lb, nbs = so_spectra.read_ps("%s/%s.dat" % (spectra_dir, spec_name_noise), spectra=spectra) nl_dict = {} for spec in spectra: nbs_mean = nbs[spec] * bb_ar1 * bb_ar2 plt.figure(figsize=(12, 12)) if (spec == "TT" or spec == "EE" or spec == "BB") & (ar1 == ar2): nl = scipy.interpolate.interp1d(lb, nbs_mean, fill_value="extrapolate") nl_dict[spec] = np.array([nl(i) for i in lth]) id = np.where(lth <= np.min(lb))
"dr6_pa4_f150": "Planck_f143", "dr6_pa4_f220": "Planck_f217", "dr6_pa5_f090": "Planck_f100", "dr6_pa5_f150": "Planck_f143", "dr6_pa6_f090": "Planck_f100", "dr6_pa6_f150": "Planck_f143" } spectra_and_covariances = {} for act_map in reference_maps: print("Calibration of %s ..." % act_map) planck_map = reference_maps[act_map] print("Using %s map ..." % planck_map) lb, ps_actxact = so_spectra.read_ps(spec_dir + "Dl_%sx%s_cross.dat" % (act_map, act_map), spectra=spectra) try: cross_name = "%sx%s" % (act_map, planck_map) lb, ps_actxplanck = so_spectra.read_ps(spec_dir + "Dl_%s_cross.dat" % (cross_name), spectra=spectra) except: cross_name = "%sx%s" % (planck_map, act_map) lb, ps_actxplanck = so_spectra.read_ps(spec_dir + "Dl_%s_cross.dat" % (cross_name), spectra=spectra) print("ACTxPlanck : %s" % cross_name) cov = {} actxact_name = "%sx%s" % (act_map, act_map)
freqs1=d['freq_%s'%exp1] for id_f1,f1 in enumerate(freqs1): for id_exp2,exp2 in enumerate(experiment): freqs2=d['freq_%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 if (exp1!=exp2) & (kind=='noise'): continue if (exp1!=exp2) & (kind=='auto'): continue spec_name='%s_%s_%s_%sx%s_%s_%s'%(type,run_name,exp1,f1,exp2,f2,kind) if hdf5: lb,Db=so_spectra.read_ps_hdf5(spectra_hdf5,spec_name,spectra=spectra) else: lb,Db=so_spectra.read_ps(specDir+'/%s.dat'%spec_name,spectra=spectra) Db_dict[kind,spec,exp1,f1,exp2,f2]=Db[spec] #plt.figure(figsize=(8,7)) # if spec=='TT': # plt.semilogy() # plt.plot(lth,Dlth[spec]) # plt.errorbar(lb,Db[spec],fmt='.',color='red') # plt.title(r'$D^{%s,%s_{%s}x%s_{%s}}_{%s,\ell}$'%(spec,exp1,f1,exp2,f2,kind),fontsize=20) # plt.xlabel(r'$\ell$',fontsize=20) # plt.savefig('%s/spectra_%s_%s_%s_%sx%s_%s_%s.png'%(plot_dir,run_name,spec,exp1,f1,exp2,f2,kind),bbox_inches='tight') # plt.clf()
for spec in spectra: for id_exp1, exp1 in enumerate(experiments): freqs1 = d["freqs_%s" % exp1] for id_f1, f1 in enumerate(freqs1): for id_exp2, exp2 in enumerate(experiments): freqs2 = d["freqs_%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 if (exp1 != exp2) & (kind == "noise"): continue if (exp1 != exp2) & (kind == "auto"): continue spec_name = "%s_%s_%sx%s_%s_%s_%05d" % (type, exp1, f1, exp2, f2, kind, iii) lb, Db = so_spectra.read_ps(specDir + "/%s.dat" % spec_name, spectra=spectra) n_bins = len(lb) vec = np.append(vec, Db[spec]) if (exp1 == exp2) & (f1 == f2): if spec == "TT" or spec == "EE" or spec == "TE" : vec_restricted = np.append(vec_restricted, Db[spec]) else: if spec == "TT" or spec == "EE" or spec == "TE" or spec == "ET": vec_restricted = np.append(vec_restricted, Db[spec]) vec_list += [vec] vec_list_restricted += [vec_restricted]
for id_sv1, sv1 in enumerate(surveys): arrays_1 = d["arrays_%s" % sv1] for id_ar1, ar1 in enumerate(arrays_1): for id_sv2, sv2 in enumerate(surveys): arrays_2 = d["arrays_%s" % sv2] for id_ar2, ar2 in enumerate(arrays_2): if (id_sv1 == id_sv2) & (id_ar1 > id_ar2): continue if (id_sv1 > id_sv2): continue spec_name = "%s_%sx%s_%s" % (sv1, ar1, sv2, ar2) spectra = [ "TT", "TE", "TB", "ET", "BT", "EE", "EB", "BE", "BB" ] lb, Db = so_spectra.read_ps(spec_dir + "/%s_%s_cross.dat" % (type, spec_name), spectra=spectra) # remove same array, same season ET if (spec == "ET") & (ar1 == ar2) & (sv1 == sv2): continue data_vec = np.append(data_vec, Db[spec]) # Lets combine the data (following the doc) print("invert cov mat") inv_cov_mat = np.linalg.inv(cov_mat) proj_cov_mat = np.linalg.inv(np.dot(np.dot(P_mat, inv_cov_mat), P_mat.T)) proj_data_vec = np.dot(proj_cov_mat, np.dot(P_mat, np.dot(inv_cov_mat, data_vec))) print("is matrix positive definite:",
type = d["type"] binning_file = d["binning_file"] lth = np.arange(2, lmax + 2) for sv in surveys: arrays = d["arrays_%s" % sv] for id_ar1, ar1 in enumerate(arrays): for id_ar2, ar2 in enumerate(arrays): if id_ar1 > id_ar2: continue l, bl_ar1 = pspy_utils.read_beam_file(d["beam_%s_%s" % (sv, ar1)]) l, bl_ar2 = pspy_utils.read_beam_file(d["beam_%s_%s" % (sv, ar2)]) lb, nbs_ar1xar1 = so_spectra.read_ps( "%s/%s_%s_%sx%s_%s_noise.dat" % (spectra_dir, type, sv, ar1, sv, ar1), spectra=spectra) lb, nbs_ar1xar2 = so_spectra.read_ps( "%s/%s_%s_%sx%s_%s_noise.dat" % (spectra_dir, type, sv, ar1, sv, ar2), spectra=spectra) lb, nbs_ar2xar2 = so_spectra.read_ps( "%s/%s_%s_%sx%s_%s_noise.dat" % (spectra_dir, type, sv, ar2, sv, ar2), spectra=spectra) lb, bb_ar1 = pspy_utils.naive_binning(l, bl_ar1, binning_file, lmax) lb, bb_ar2 = pspy_utils.naive_binning(l, bl_ar2, binning_file, lmax)
for id_sv2, sv2 in enumerate(surveys): arrays_2 = d["arrays_%s" % sv2] for id_ar2, ar2 in enumerate(arrays_2): _, bl2 = pspy_utils.read_beam_file(d["beam_%s_%s" % (sv2, ar2)]) bl2 = bl2[2:lmax + 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 if (sv1 == sv2) & (ar1 == ar2): spec_name_noise = "mean_%sx%s_%s_noise" % (ar1, ar2, sv1) _, Nl = so_spectra.read_ps(ps_model_dir + "/%s.dat" % spec_name_noise, spectra=spectra) for spec in ["TT", "TE", "ET", "EE"]: name = "%sx%s_%s" % (freq1, freq2, spec) _, ps_th = np.loadtxt("%s/best_fit_%s.dat" % (bestfit_dir, name), unpack=True) ps_all["%s&%s" % (sv1, ar1), "%s&%s" % (sv2, ar2), spec] = bl1 * bl2 * ps_th[:lmax] if (sv1 == sv2) & (ar1 == ar2): ns[sv1] = len(d["maps_%s_%s" % (sv1, ar1)])
for spec in spectra: for id_sv1, sv1 in enumerate(surveys): arrays_1 = d["arrays_%s" % sv1] for id_ar1, ar1 in enumerate(arrays_1): for id_sv2, sv2 in enumerate(surveys): arrays_2 = d["arrays_%s" % sv2] for id_ar2, ar2 in enumerate(arrays_2): if (id_sv1 == id_sv2) & (id_ar1 > id_ar2) : continue if (id_sv1 > id_sv2) : continue if (sv1 != sv2) & (kind == "noise"): continue if (sv1 != sv2) & (kind == "auto"): continue spec_name = "%s_%s_%sx%s_%s_%s_%05d" % (type, sv1, ar1, sv2, ar2, kind, iii) lb, Db = so_spectra.read_ps(spec_dir + "/%s.dat" % spec_name, spectra=spectra) n_bins = len(lb) vec = np.append(vec, Db[spec]) if (sv1 == sv2) & (ar1 == ar2): if spec == "TT" or spec == "EE" or spec == "TE" : vec_restricted = np.append(vec_restricted, Db[spec]) else: if spec == "TT" or spec == "EE" or spec == "TE" or spec == "ET": vec_restricted = np.append(vec_restricted, Db[spec]) vec_list += [vec] vec_list_restricted += [vec_restricted]
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) lb, ps_nofilt = so_spectra.read_ps(spec_dir + "/%s.dat" % spec_name_no_filter, spectra=spectra) lb, ps_filt = so_spectra.read_ps(spec_dir + "/%s.dat" % spec_name_filter, spectra=spectra) nofilt_list += [ps_nofilt[spectrum]] filt_list += [ps_filt[spectrum]] tf_list += [ps_filt[spectrum] / ps_nofilt[spectrum]] mean[spectrum, "nofilt"] = np.mean(nofilt_list, axis=0) mean[spectrum, "filt"] = np.mean(filt_list, axis=0) mean[spectrum, "tf"] = np.mean(tf_list, axis=0) std[spectrum, "nofilt"] = np.std(nofilt_list, axis=0) std[spectrum, "filt"] = np.std(filt_list, axis=0)
bin_start = 0 bin_stop = 0 for spec in ["TT", "EE", "TE"]: for fpair in freq_pairs: f0, f1 = fpair if (spec == "TT") & (f0 == "100") & (f1 == "143"): continue if (spec == "TT") & (f0 == "100") & (f1 == "217"): continue spec_name = "Planck_%sxPlanck_%s-hm1xhm2" % (f0, f1) lb, ps_dict = so_spectra.read_ps("%s/sim_spectra_%s_%04d.dat" % (sim_spectra_dir, spec_name, iii), spectra=spectra) if f0 != f1: spec_name2 = "Planck_%sxPlanck_%s-hm2xhm1" % (f0, f1) lb, ps_dict2 = so_spectra.read_ps( "%s/sim_spectra_%s_%04d.dat" % (sim_spectra_dir, spec_name2, iii), spectra=spectra) ps_dict[spec] = (ps_dict[spec] + ps_dict2[spec]) / 2 if spec == "TE": ps_dict["ET"] = (ps_dict["ET"] + ps_dict2["ET"]) / 2 if spec == "TE": ps_dict["TE"] = (ps_dict["TE"] + ps_dict["ET"]) / 2