a_gal=0.8, a_cibp=1, a_cibc=1, a_radps=rads[i] * rads[j], a_ksz=1, a_tsz=0) pl.add(ells, t1d, color=f"C{c}", lw=1, ls='--') tfgres[i, j] = t1d.copy()[:lmax] tfgres[j, i] = t1d.copy()[:lmax] c += 1 pl._ax.set_xlim(2, 5800) #pl._ax.set_xlim(2,300) # !!! pl.done("debugfits.png") corr = cov2corr(cfgres) tcorr = cov2corr(tfgres) corr[~np.isfinite(corr)] = 0 tcorr[~np.isfinite(tcorr)] = 0 assert np.all(tcorr <= 1) hmat = correlated_hybrid_matrix(cfgres, theory_corr=tcorr) hmat[~np.isfinite(hmat)] = 0 hcorr = cov2corr(hmat) hcorr[~np.isfinite(hcorr)] = 0 print(hcorr.max()) assert np.all(hcorr <= (1 + 1e-5)) sample_ells = [500, 1000] for sell in sample_ells: cmat = cfgres
s.add_to_stats("cbb", cl22_coupled[3] / w2) # Naive PS calculation p2d, _, _ = fc.power2d(imaps, imaps) mtt = binit(p2d[0, 0]) mte = binit(p2d[0, 1]) mee = binit(p2d[1, 1]) s.add_to_stats("mtt", mtt) s.add_to_stats("mee", mee) s.add_to_stats("mte", mte) s.get_stats() # PLOT STUFF io.plot_img(stats.cov2corr(s.stats["uke"]['cov']), io.dout_dir + "cov.png", flip=False) io.plot_img(stats.cov2corr(s.stats["cke"]['cov']), io.dout_dir + "ccov.png", flip=False) def gstats(key): return s.stats[key]['mean'], s.stats[key]['errmean'] pl = io.Plotter(yscale='log', xlabel="$L$", ylabel="$C_L$") pl.add(ellrange, clkk, color='r', label='Input KK') pl.add(ellrange, clkg, color='g', label='Input KG') pl.add(ellrange, clgg, color='b', label='Input GG')
marker="o", alpha=0.5, label="auto n0subbed") pl.add(lcents, nlkk, ls="--", label="theory n0") pl.add(lcents, nstats['mean'], ls="--", label="superdumb n0") pl.add(lcents, nstats['mean'] + clkk1d, ls="--", label="superdumb n0 + clkk") pl.add(ellrange, clkk, color="k") pl.legendOn(loc="lower left", labsize=9) pl._ax.set_xlim(30, 1e5) pl._ax.set_ylim(1e-12, 1e-5) pl.done(out_dir + "cpower.png") io.quickPlot2d(stats.cov2corr(astats['covmean']), out_dir + "corr.png") io.quickPlot2d(stats.cov2corr(rstats['covmean']), out_dir + "rcorr.png") np.save(out_dir + str(area) + "sqdeg_covmat_dl300.npy", rstats['cov']) np.save(out_dir + str(area) + "sqdeg_autocovmat_dl300.npy", astats['cov']) np.save(out_dir + str(area) + "sqdeg_lbin_edges_dl300.npy", lbin_edges) import pickle as pickle pickle.dump((lcents, mpibox.stats['noisett']['mean']), open(out_dir + "noise_mpismall.pkl", 'wb')) pl = io.Plotter() ldiff = (cstats['mean'] - istats['mean']) * 100. / istats['mean'] lerr = cstats['errmean'] * 100. / istats['mean'] pl.addErr(lcents, ldiff, yerr=lerr, marker="o", ls="-") pl._ax.axhline(y=0., ls="--", color="k") pl.done(out_dir + "powerdiff.png")
c = c + 1 pl._ax.scatter(c, bcov[i, j], color=f"C{seed}", marker="o") vals[seed].append(bcov[i, j]) gvals[seed].append(gcov[i, j]) if i == j: print(qid1, gcov[i, j]) if qid1 == 'p03': gcov[i, j] = bcov[i, j] = 0 if gcov[i, j] == 0.: gcov[i, j] = 700000 if bcov[i, j] == 0.: bcov[i, j] = 700000 print(np.diagonal(bcov)) print(bcov) np.savetxt(f"bcov_{seed}.txt", bcov, delimiter=',') np.savetxt(f"gcov_{seed}.txt", gcov, delimiter=',') gcorr = stats.cov2corr(gcov) bcorr = stats.cov2corr(bcov) print(gcorr.min(), gcorr.max()) print(bcorr.min(), bcorr.max()) io.plot_img(gcorr, f"det_gcov_{seed}.png", flip=False, lim=[0.5, 1]) io.plot_img(bcorr, f"det_bcov_{seed}.png", flip=False, lim=[0.5, 1]) print(seed) gi = np.linalg.inv(gcov) bi = np.linalg.inv(bcov) bi2 = utils.eigpow(bcov, -1) print(np.linalg.eigh(gcov)[0]) print(np.linalg.eigh(bcov)[0]) pl.done("detscatter.png") pl = io.Plotter(xyscale='linlin', xlabel='a', ylabel='r')
aperrs = np.array(aperrs) apmeans = np.array(apmeans) bfit, bcov, chisquare, pte = stats.fit_linear_model( x, apmeans, ycov=np.diag(aperrs**2.), funcs=[lambda x: yflux(x, 1.), lambda x: dflux(x, 1.)]) Yfit, Dfit = bfit eYfit, eDfit = np.sqrt(np.diagonal(bcov)) #print(dT,Y,D) print(Yfit, Dfit) print(Yfit / eYfit, Dfit / eDfit) print(chisquare, pte) print(bcov) bcor = stats.cov2corr(bcov) print(bcor) # print(freqs) # print(Yfit[0]) # print(Dfit[0]) # print(dTfit[0]) # print(Sflux(freqs,Yfit[0],Dfit[0],dTfit[0])) # print(np.abs(Sflux(freqs,Yfit[0],Dfit[0],dTfit[0]))) pl = io.Plotter(xlabel='$\\nu$ (GHz)', ylabel='Flux ($K-\mathrm{arcmin}^2$)', yscale='log') pl.add(freqs, np.abs(yflux(freqs, Yfit[0])), label='Y') pl.add(freqs, dflux(freqs, Dfit[0]), label="D") pl.add(freqs, np.abs(Sflux(freqs, Yfit[0], Dfit[0])), label='Fit') pl.add_err(x, np.abs(apmeans), yerr=aperrs, marker="o", ls="none")