def __init__(self,full_sky_pix,wdeg,hdeg,yoffset,mpi_comm=None,nsims=1,lmax=7000,pix_intermediate=None,bin_lmax=3000): self.dtype = np.float32 self.bin_edges = np.arange(80,bin_lmax,100) self.fshape, self.fwcs = enmap.fullsky_geometry(res=full_sky_pix*np.pi/180./60., proj="car") self.fshape = self.fshape[-2:] self.shape = {} self.wcs = {} self.taper = {} self.w2 = {} self.w3 = {} self.w4 = {} self.pix_intermediate = full_sky_pix if (pix_intermediate is None) else pix_intermediate self.wdeg = wdeg self.hdeg = hdeg degree = u.degree vwidth = hdeg/2. hwidth = wdeg/2. self.pos_south=np.array([[-vwidth+yoffset,-hwidth],[vwidth+yoffset,hwidth]])*degree self.pos_eq=np.array([[-vwidth,-hwidth],[vwidth,hwidth]])*degree # Get MPI comm self.comm = mpi_comm try: self.rank = mpi_comm.Get_rank() self.numcores = mpi_comm.Get_size() except: self.rank = 0 self.numcores = 1 if self.rank==0: self.logger = io.get_logger("rotrecon") num_each,each_tasks = mpi_distribute(nsims,self.numcores) self.mpibox = MPIStats(self.comm,num_each,tag_start=333) if self.rank==0: self.logger.info( "At most "+ str(max(num_each)) + " tasks...") self.tasks = each_tasks[self.rank] theory_file_root = "data/Aug6_highAcc_CDM" powspec_file = "data/Aug6_highAcc_CDM_lenspotentialCls.dat" self.ps = powspec.read_camb_full_lens(powspec_file).astype(self.dtype) self.theory = cmb.loadTheorySpectraFromCAMB(theory_file_root,unlensedEqualsLensed=False, useTotal=False,TCMB = 2.7255e6,lpad=9000,get_dimensionless=False) self.lmax = lmax self.count = 0
l, beamells = np.loadtxt(beamPath, unpack=True, usecols=[0, 1]) cmbellmin = 100 cmbellmax = 3000 kellmin = 100 kellmax = 3000 #cambRoot = "/astro/u/msyriac/repos/cmb-lensing-projections/data/TheorySpectra/ell28k_highacc" cambRoot = "/astro/u/msyriac/repos/actpLens/data/non-linear" TCMB = 2.7255e6 #theory = loadTheorySpectraFromCAMB(cambRoot,unlensedEqualsLensed=False,useTotal=False,TCMB = TCMB,lpad=4000) # !!!!!!!!!!!!! N2 bias theory = loadTheorySpectraFromCAMB(cambRoot, unlensedEqualsLensed=True, useTotal=False, TCMB=TCMB, lpad=(cmbellmax + 500)) ellkk = np.arange(2, 9000, 1) Clkk = theory.gCl("kk", ellkk) N = int(sys.argv[1]) assert N % numcores == 0 num_each = (N / numcores) startIndex = rank * num_each endIndex = startIndex + num_each myIs = range(N)[startIndex:endIndex]
noiseY = float(sys.argv[1]) tellminY = int(sys.argv[2]) pellminY = int(sys.argv[3]) #beamRange = np.arange(0.5,5.0,0.5) beamRange = np.arange(5.0, 10.5, 0.5) beamscale = lambda b: np.sqrt(8. * np.log(2.)) * 60. * 180. / np.pi / b kmin = 40 deg = 10. #px = 0.2 px = 0.5 dell = 10 theory = loadTheorySpectraFromCAMB(cambRoot, unlensedEqualsLensed=False, useTotal=False, lpad=9000) lmap = lm.makeEmptyCEATemplate(raSizeDeg=deg, decSizeDeg=deg, pixScaleXarcmin=px, pixScaleYarcmin=px) print((lmap.data.shape)) i = 0 for gradCut in [10000, 2000]: myNls = NlGenerator(lmap, theory, gradCut=gradCut) for polComb in ['TT', 'TE', 'EE', 'EB', 'ET', 'TB']: for beamY in beamRange: beamell = beamscale(beamY) for tellmaxY, pellmaxY in [(3000, 5000), (beamell, beamell)]:
namells, namclkk = np.loadtxt("data/nam_clkk.csv", delimiter=',', unpack=True) pl.add(namells, namclkk, marker="o", ls="none", color="C3") cdmfile = "data/May21_matter2lens_WF_CDM_cut_ibarrier_iconc_fCls.csv" fdmfile = "data/May21_matter2lens_WF_FDM_1.0_cut_ibarrier_iconc_fCls.csv" lcdm, ckkcdm = np.loadtxt(cdmfile, unpack=True) lfdm, ckkfdm = np.loadtxt(fdmfile, unpack=True) pl.add(lcdm, ckkcdm, color="C4") pl.add(lfdm, ckkfdm, color="C5") for cambRoot, lab, col in zip(clist, lablist, colist): theory = cmb.loadTheorySpectraFromCAMB(cambRoot, unlensedEqualsLensed=False, useTotal=False, TCMB=2.7255e6, lpad=lmax) ls, Nls, ellbb, dlbb, efficiency, cc = lensNoise( Config, expName, lensName, beamOverride=None, noiseTOverride=None, lkneeTOverride=None, lkneePOverride=None, alphaTOverride=None, alphaPOverride=None, gradCut=2000, deg=2.,
TCMB = 2.7255e6 hugeTemplate = lm.makeEmptyCEATemplate(degx,degy,pixScaleXarcmin=px,pixScaleYarcmin=px) lxMap,lyMap,modLMap,thetaMap,lx,ly = fmaps.getFTAttributesFromLiteMap(hugeTemplate) nfreq = modLMap.max() assert nfreq>cmbellmax assert nfreq>kellmax from orphics.tools.cmb import loadTheorySpectraFromCAMB cambRoot = os.environ['HOME']+"/repos/cmb-lensing-projections/data/TheorySpectra/ell28k_highacc" theory = loadTheorySpectraFromCAMB(cambRoot,unlensedEqualsLensed=True,useTotal=False,TCMB = 2.7255e6,lpad=9000) #theory = loadTheorySpectraFromCAMB(cambRoot,unlensedEqualsLensed=False,useTotal=False,TCMB = 2.7255e6,lpad=9000) Nlfuncdict={} Nlfuncdict['TT'] = cmb.get_noise_func(beamArcmin,noiseT,TCMB=TCMB) Nlfuncdict['EE'] = cmb.get_noise_func(beamArcmin,noiseP,TCMB=TCMB) Nlfuncdict['BB'] = cmb.get_noise_func(beamArcmin,noiseP,TCMB=TCMB) print modLMap.shape dlx = np.diff(lxMap,axis=1)[0,0] dly = np.diff(lyMap,axis=0)[0,0] Lmin = kellmin #10. Lmax = kellmax #2000.
Nsims = 16 comm = MPI.COMM_WORLD rank = comm.Get_rank() numcores = comm.Get_size() Ntot = Nsims num_each, each_tasks = mpi_distribute(Ntot, numcores) mpibox = MPIStats(comm, num_each, tag_start=333) if rank == 0: print(("At most ", max(num_each), " tasks...")) my_tasks = each_tasks[rank] theory_file_root = "data/Aug6_highAcc_CDM" theory = cmb.loadTheorySpectraFromCAMB(theory_file_root, unlensedEqualsLensed=False, useTotal=False, TCMB=2.7255e6, lpad=9000, get_dimensionless=False) ells = np.arange(0, 7000, 1) #pfunc = lambda x: theory.lCl('TT',x) #pfunc = lambda x: x*0.+1. pfunc = lambda x: x * 0. + (10. * np.pi / 180. / 60.)**2. #theory.gCl('kk',x) ps = pfunc(ells).reshape((1, 1, 7000)) wdeg = 40. hdeg = 15. yoffset = 60. pix = 0.5 lmax = 7000 fshape, fwcs = enmap.fullsky_geometry(res=pix * np.pi / 180. / 60., proj="car")
def theory_from_config(Config, theory_section, dimensionless=True): sec_type = Config.get(theory_section, "cosmo_type") lmax = Config.getint(theory_section, "lmax") cc = None if sec_type == "pycamb_params": raise NotImplementedError elif sec_type == "cluster": from szar.counts import ClusterCosmology with oio.nostdout(): with warnings.catch_warnings(): warnings.simplefilter("ignore") logger.disabled = True cc = ClusterCosmology(lmax=lmax, pickling=True, dimensionless=dimensionless) theory = cc.theory logger.disabled = False elif sec_type == "default": from orphics.theory.cosmology import Cosmology with oio.nostdout(): with warnings.catch_warnings(): warnings.simplefilter("ignore") logger.disabled = True cc = Cosmology(lmax=lmax, pickling=True, dimensionless=dimensionless) theory = cc.theory logger.disabled = False elif sec_type == "camb_file": cc = None import orphics.tools.cmb as cmb file_root = Config.get(theory_section, "camb_file_root") theory = cmb.loadTheorySpectraFromCAMB(file_root, unlensedEqualsLensed=False, useTotal=False, TCMB=2.7255e6, lpad=lmax, get_dimensionless=dimensionless) try: cforce = Config.getboolean(theory_section, "cluster_force") except: cforce = False if cforce: from szar.counts import ClusterCosmology cc = ClusterCosmology(skipCls=True, dimensionless=dimensionless) cc.theory = theory elif sec_type == "enlib_file": import orphics.tools.cmb as cmb file_root = Config.get(theory_section, "enlib_file_root") theory = cmb.load_theory_spectra_from_enlib( file_root, lpad=lmax, get_dimensionless=dimensionless) cc = None else: print(sec_type) raise ValueError return theory, cc, lmax