def __init__(self, paramDict=cosmo.defaultCosmology, constDict=cosmo.defaultConstants, lmax=None, clTTFixFile=None, skipCls=False, pickling=False, fill_zero=True, dimensionless=True, verbose=True, skipPower=True, skip_growth=True, low_acc=False): Cosmology.__init__(self, paramDict, constDict, lmax, clTTFixFile, skipCls, pickling, fill_zero, dimensionless=dimensionless, verbose=verbose, skipPower=skipPower, skip_growth=skip_growth, low_acc=low_acc, nonlinear=False) self.om = (self.omch2 + self.ombh2) / self.h**2. self.rhoc0om = self.rho_crit0H100 * self.om
def lensNoise(Config, expName, lensName, beamOverride=None, noiseTOverride=None, lkneeTOverride=None, lkneePOverride=None, alphaTOverride=None, alphaPOverride=None, tellminOverride=None, pellminOverride=None, tellmaxOverride=None, pellmaxOverride=None, deg=5., px=1.0, gradCut=10000, bigell=9000, plot=False, theoryOverride=None, lensedEqualsUnlensed=True, noiseFuncT=None, noiseFuncP=None): from orphics.io import list_from_config beam = list_from_config(Config, expName, 'beams') noise = list_from_config(Config, expName, 'noises') freq = list_from_config(Config, expName, 'freqs') lkneeT, lkneeP = list_from_config(Config, expName, 'lknee') alphaT, alphaP = list_from_config(Config, expName, 'alpha') if (noiseFuncT is None) and (noiseFuncP is None): print 'Not using noise files for generating lensing noise' else: print 'Using noise files for generating lensing noise' tellmin, tellmax = list_from_config(Config, expName, 'tellrange') if tellminOverride is not None: tellmin = tellminOverride if tellmaxOverride is not None: tellmax = tellmaxOverride pellmin, pellmax = list_from_config(Config, expName, 'pellrange') if pellminOverride is not None: pellmin = pellminOverride if pellmaxOverride is not None: pellmax = pellmaxOverride lmax = int(Config.getfloat(expName, 'lmax')) pols = Config.get(lensName, 'polList').split(',') freq_to_use = Config.getfloat(lensName, 'freq') ind = np.where(np.isclose(freq, freq_to_use)) beamFind = np.array(beam)[ind] noiseFind = np.array(noise)[ind] assert beamFind.size == 1 assert noiseFind.size == 1 if beamOverride is not None: beamX = beamY = beamOverride else: beamX = beamY = beamFind[0] if noiseTOverride is not None: noiseTX = noiseTY = noiseTOverride else: noiseTX = noiseTY = noiseFind[0] if lkneeTOverride is not None: lkneeT = lkneeTOverride if lkneePOverride is not None: lkneeP = lkneePOverride if alphaTOverride is not None: alphaT = alphaTOverride if alphaPOverride is not None: alphaP = alphaPOverride from orphics.lensing import NlGenerator, getMax from orphics import maps #deg = 5. #px = 1.0 dell = 10 kellmin = 10 shape, wcs = maps.rect_geometry(width_deg=deg, px_res_arcmin=px) kellmax = max(tellmax, pellmax) if theoryOverride is None: from orphics.cosmology import Cosmology cc = Cosmology(lmax=int(kellmax), pickling=True) theory = cc.theory else: theory = theoryOverride cc = None bin_edges = np.arange(kellmin, kellmax, dell) myNls = NlGenerator(shape, wcs, theory, bin_edges, gradCut=gradCut, bigell=bigell, unlensedEqualsLensed=lensedEqualsUnlensed) myNls.updateNoise(beamX, noiseTX, np.sqrt(2.) * noiseTX, tellmin, tellmax, pellmin, pellmax, beamY=beamY, noiseTY=noiseTY, noisePY=np.sqrt(2.) * noiseTY, lkneesX=(lkneeT, lkneeP), lkneesY=(lkneeT, lkneeP), alphasX=(alphaT, alphaP), alphasY=(alphaT, alphaP), noiseFuncTX=noiseFuncT, noiseFuncTY=noiseFuncT, noiseFuncPX=noiseFuncP, noiseFuncPY=noiseFuncP) lsmv, Nlmv, ells, dclbb, efficiency = myNls.getNlIterative(pols, kellmin, kellmax, tellmax, pellmin, pellmax, dell=dell, halo=True, plot=plot) return lsmv, Nlmv, ells, dclbb, efficiency, cc
from enlib import enmap #import orphics.m as fmaps import orphics.maps as maps import orphics.io as io import orphics.stats as stats from orphics.cosmology import Cosmology import numpy as np import os, sys out_dir = os.environ['WWW'] + "plots/pureTest_" cc = Cosmology(lmax=6000, pickling=True, dimensionless=False) theory = cc.theory deg = 20. px = 1.0 shape, wcs = maps.rect_geometry(width_deg=deg, px_res_arcmin=px, pol=True) pa = maps.PatchArray(shape, wcs, cc=cc, orphics_is_dimensionless=False) ulensed = pa.get_unlensed_cmb() kappa = pa.get_grf_kappa() cmb = pa.get_lensed(ulensed, order=5) # io.highResPlot2d(cmb[0],out_dir+"t.png") # io.highResPlot2d(cmb[1],out_dir+"q.png") # io.highResPlot2d(cmb[2],out_dir+"u.png") modlmap = enmap.modlmap(shape, wcs) fc = maps.FourierCalc(shape, wcs) lbin_edges = np.arange(200, 6000, 40) lbinner = stats.bin2D(modlmap, lbin_edges) def plot_powers(cmb, suffix, power=None, w2=1.):
fgFuncY = None import flipper.liteMap as lm from alhazen.quadraticEstimator import NlGenerator, getMax deg = 5. px = 1.0 dell = 10 gradCut = 2000 kellmin = 10 lmap = lm.makeEmptyCEATemplate(raSizeDeg=deg, decSizeDeg=deg, pixScaleXarcmin=px, pixScaleYarcmin=px) kellmax = max(tellmax, pellmax) from orphics.cosmology import Cosmology cc = Cosmology(lmax=int(kellmax), pickling=True) theory = cc.theory bin_edges = np.arange(kellmin, kellmax, dell) myNls = NlGenerator(lmap, theory, bin_edges, gradCut=gradCut) nTX, nPX, nTY, nPY = myNls.updateNoiseAdvanced( beamTX, noiseTX, beamPX, noisePX, tellminX, tellmaxX, pellminX, pellmaxX, beamTY, noiseTY, beamPY, noisePY, tellminY, tellmaxY, pellminY, pellmaxY, (lkneeTX, lkneePX), (alphaTX, alphaPX), (lkneeTY, lkneePY), (alphaTY, alphaPY), None, None, None, None, None, None, None, None, fgFuncX, fgFuncY, None, None, None, None, None, None, None, None) ls, Nls, ells, dclbb, efficiency = myNls.getNlIterative(pols, kellmin, kellmax, tellmax,
# differentiating between small and large telescope for future compatibility assert spellmin<=pellmin, "Why does your large telescope have a smaller lmin_P than the small one?" dFile = Config.get('rForecast','rDerivFile') fFile = Config.get('rForecast','rFidFile') rInFid = Config.getfloat('rForecast','rInFid') rExp = Config.getfloat('rForecast','rExpected') fgPer = Config.getfloat('rForecast','fgPer') dCls = np.loadtxt(dFile,delimiter=",") fCls = np.loadtxt(fFile,delimiter=",") from orphics.cosmology import Cosmology cc = Cosmology(lmax=int(max(pellmax,spellmax)),pickling=True) theory = cc.theory ellBBRange = np.arange(spellmin,spellmax) fclbb = cosmology.noise_pad_infinity(interp1d(ellBBRange,theory.lCl('BB',ellBBRange)*TCMB**2.,fill_value=np.inf,bounds_error=False),spellmin,spellmax) # clbbnow = theory.lCl('BB',ellBBRange)#*TCMB**2. # pl = Plotter(scaleY='log',xscale='log') # pl.add(ellBBRange,clbbnow*ellBBRange**2.) # pl.add(ellbb,dlbb*ellbb**2.) # # pl._ax.set_ylim(-max(Clkk),max(Clkk)) # pl.done("clbb.png")