uEqualsL=True, gradCut=gradCut, verbose=False, bigell=lmax) clkk2d = theory.gCl('kk', modlmap_dat) for k, index in enumerate(my_tasks): if rank == 0: print( ("Rank ", rank, " doing job ", k + 1, " / ", len(my_tasks), "...")) unlensed = parray_sim.get_unlensed_cmb(seed=index, scalar=False) luteb, dummy = sverif_cmb.add_power("unlensed", unlensed) kappa = parray_sim.get_kappa(ktype="grf", vary=False, seed=index + 1000000) phi, fphi = lt.kappa_to_phi(kappa, parray_sim.modlmap, return_fphi=True) grad_phi = enmap.grad(phi) lensed = lensing.lens_map(unlensed.copy(), grad_phi, order=lens_order) llteb, dummy = sverif_cmb.add_power("lensed", lensed) pdelensed = lensing.delens_map(lensed, grad_phi, nstep=delens_steps, order=lens_order) lpteb, dummy = sverif_cmb.add_power("pdelensed", pdelensed) qest.updateTEB_X(llteb[0], llteb[1], llteb[2], alreadyFTed=True) qest.updateTEB_Y(alreadyFTed=True) with io.nostdout(): rawkappa_TT = qest.getKappa("TT").real rawkappa_EB = qest.getKappa("EB").real
grad_cut = None clkk = theory.gCl("kk", fine_ells) clkk.resize((1, 1, clkk.size)) kappa_map = enmap.rand_map(shape_sim[-2:], wcs_sim, cov=clkk, scalar=True) pkk = fmaps.get_simple_power_enmap(kappa_map) debug_edges = np.arange(2, 12000, 80) dbinner = stats.bin2D(modlmap_sim, debug_edges) cents, bclkk = dbinner.bin(pkk) clkk.resize((clkk.shape[-1])) pl = io.Plotter(scaleY='log', scaleX='log') pl.add(fine_ells, clkk) pl.add(cents, bclkk) pl.done(out_dir + "clkk.png") phi, fphi = lt.kappa_to_phi(kappa_map, modlmap_sim, return_fphi=True) io.quickPlot2d(kappa_map, out_dir + "kappa_map.png") io.quickPlot2d(phi, out_dir + "phi.png") alpha_pix = enmap.grad_pixf(fphi) # === SIM AND RECON LOOP === kappa_stack = {} if cluster: profiles = {} else: apowers = {} cpowers = {} for polcomb in pol_list: kappa_stack[polcomb] = 0. if cluster:
model_uniform_kappa = 0.02 #02 else: clkk = theory.gCl("kk", fine_ells) clkk.resize((1, 1, clkk.size)) kappa_map = enmap.rand_map(shape_sim[-2:], wcs_sim, cov=clkk, scalar=True) if debug: pkk = fmaps.get_simple_power_enmap(kappa_map) debug_edges = np.arange(kellmin, 8000, 80) dbinner = stats.bin2D(modlmap_sim, debug_edges) cents, bclkk = dbinner.bin(pkk) clkk.resize((clkk.shape[-1])) pl = io.Plotter(scaleY='log', scaleX='log') pl.add(fine_ells, clkk) pl.add(cents, bclkk) pl.done(out_dir + "clkk.png") phi, fphi = lt.kappa_to_phi(kappa_map, modlmap_sim, return_fphi=True) io.quickPlot2d(kappa_map, out_dir + "kappa_map.png") io.quickPlot2d(phi, out_dir + "phi.png") alpha_pix = enmap.grad_pixf(fphi) # === EXPERIMENT === if deconvolve_beam: ntfunc = cmb.get_noise_func(beam_arcmin, noise_T_uK_arcmin, ellmin=tellmin, ellmax=tellmax, TCMB=TCMB) npfunc = cmb.get_noise_func(beam_arcmin, noise_P_uK_arcmin, ellmin=pellmin,
noise_T = 1.0 pa = fmaps.PatchArray(shape,wcs,dimensionless=False,skip_real=False) pa.add_theory(cc,theory,lmax) pa.add_gaussian_beam(1.0) pa.add_white_noise_with_atm(noise_T,0.,0,1,0,1) Npoints = 60 mrange = np.linspace(1,3,Npoints)*1.e14 trueM = 2e14 kappa = nfwkappa(trueM) phi, fphi = lt.kappa_to_phi(kappa,pa.modlmap,return_fphi=True) #grad_phi = enmap.grad(phi) alpha_pix = enmap.grad_pixf(fphi) N = 10000 Nfor = N totlikes = 0. allike = 1. Ms = [] logdets = [] cinvs = [] TCMB = 1. #2.7255e6 from scipy.linalg import pinv2
fmaskY2dTEB=[fMaskCMB_T, fMaskCMB_P, fMaskCMB_P], fmaskKappa=fMask, kBeamX=kbeampass, kBeamY=kbeampass, doCurl=False, TOnly=not (pol), halo=True, uEqualsL=False, gradCut=gradCut, verbose=False, bigell=lmax, lEqualsU=False) kappa = get_nfw(5.e14) #+ parray_sim.get_grf_kappa(seed=10,skip_update=False) phi, fphi = lt.kappa_to_phi(kappa, parray_sim.modlmap, return_fphi=True) grad_phi = enmap.grad(phi) kappa_model = kappa.copy() / 5. #kappa_model = kappa.copy()# /5. for k, index in enumerate(my_tasks): if rank == 0: print( ("Rank ", rank, " doing job ", k + 1, " / ", len(my_tasks), "...")) unlensed = parray_sim.get_unlensed_cmb(seed=index, scalar=False) luteb, dummy = sverif_cmb.add_power("unlensed", unlensed) lensed = lensing.lens_map(unlensed.copy(), grad_phi, order=lens_order) lensed += parray_dat.get_noise_sim(seed=index + 100000) llteb, dummy = sverif_cmb.add_power("lensed", lensed)
pixratio = analysis_resolution/Config.getfloat(sim_section,"pixel_arcmin") px_dat = analysis_resolution lens_order = Config.getint(sim_section,"lens_order") k = -1 for index in my_tasks: k += 1 if k==0: from alhazen.halos import nfw_kappa kappa = nfw_kappa(cluster_mass,parray_sim.modrmap,cc) #kappa = parray_sim.get_grf_kappa(seed=1) phi, fphi = lt.kappa_to_phi(kappa,parray_sim.modlmap,return_fphi=True) grad_phi = enmap.grad(phi) if rank==0: print(("Generating unlensed CMB for ", k, "...")) unlensed = parray_sim.get_unlensed_cmb(seed=index) if rank==0: print("Lensing...") lensed = unlensed if nolens else lensing.lens_map(unlensed.copy(), grad_phi, order=lens_order, mode="spline", border="cyclic", trans=False, deriv=False, h=1e-7) #lensed = lensing.lens_map_flat(unlensed.copy(), phi, order=lens_order) if rank==0: print("Downsampling...") cmb = lensed if abs(pixratio-1.)<1.e-3 else resample.resample_fft(lensed,shape_dat) cmb = enmap.ndmap(cmb,wcs_dat) if rank==0: print("Adding noise...") flensed = fftfast.fft(cmb,axes=[-2,-1]) flensed *= parray_dat.lbeam lensedt = fftfast.ifft(flensed,axes=[-2,-1],normalize=True).real