Ejemplo n.º 1
0
from enlib import enmap
import orphics.analysis.flatMaps as fmaps
import orphics.maps as maps
import orphics.analysis.pure as pure
import orphics.tools.io as io
import orphics.tools.stats as stats
from orphics.theory.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 = fmaps.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.):
Ejemplo n.º 2
0
from orphics.theory.cosmology import Cosmology
import numpy as np
import orphics.tools.io as io

cc = Cosmology(lmax=6000,pickling=True)


ells = np.arange(2,6000,1)
ucltt = cc.theory.uCl('TT',ells)
lcltt = cc.theory.lCl('TT',ells)

pl = io.Plotter(scaleY='log',scaleX='log')
pl.add(ells,ucltt*ells**2.,ls="--")
pl.add(ells,lcltt*ells**2.)
pl.done("cmbdemo.png")
Ejemplo n.º 3
0
Archivo: FigBeam.py Proyecto: mntw/szar
lkneePX = lkneePY = lkneeP
alphaTY = alphaT
alphaPX = alphaPY = alphaP

import flipper.liteMap as lm
from alhazen.quadraticEstimator import NlGenerator, getMax
dell = 10
gradCut = 2000
kellmin = 10
lmap = lm.makeEmptyCEATemplate(raSizeDeg=deg,
                               decSizeDeg=deg,
                               pixScaleXarcmin=px,
                               pixScaleYarcmin=px)
kellmax = max(tellmax, pellmax)
from orphics.theory.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)

from scipy.interpolate import interp1d

from orphics.tools.io import Plotter
ellkk = np.arange(2, 9000, 1)
Clkk = theory.gCl("kk", ellkk)
clfunc = interp1d(ellkk, Clkk, bounds_error=False, fill_value="extrapolate")

kellmax = 8000

cc = ClusterCosmology(cosmoDict, constDict, kellmax, pickling=True)
theory = cc.theory
Ejemplo n.º 4
0
tellmin = 10
tellmax = 6000
pellmin = tellmin
pellmax = tellmax
niter = 10

# S4
#beam = 1.0
#noiseT = 1.5

# noiseless
beam = 0.
noiseT = 0.

# cosmology
cc = Cosmology(lmax=lmax_global, pickling=True)  #,dimensionless=False)
theory = cc.theory
ellrange = np.arange(0, lmax_global, 1)
clkk = theory.gCl('kk', ellrange)
lcltt = theory.lCl('TT', ellrange)
ucltt = theory.uCl('TT', ellrange)

# quadratic estimator
deg = 5.
px = 0.5
shape, wcs = enmap.get_enmap_patch(deg * 60., px, proj="car", pol=False)
template = fmaps.simple_flipper_template_from_enmap(shape, wcs)
lxmap_dat, lymap_dat, modlmap_dat, angmap_dat, lx_dat, ly_dat = fmaps.get_ft_attributes_enmap(
    shape, wcs)
lbin_edges = np.arange(kellmin, kellmax, 200)
lbinner_dat = stats.bin2D(modlmap_dat, lbin_edges)
Ejemplo n.º 5
0
import orphics.analysis.flatMaps as fmaps 
import flipper.liteMap as lm
from orphics.tools.stats import timeit, bin2D
from ConfigParser import SafeConfigParser 


cosmologyName = 'Planck15' 
iniFile = "input/params.ini"
Config = SafeConfigParser()
Config.optionxform=str
Config.read(iniFile)

lmax = Config.getint('general','camb_ellmax')
cosmoDict = dictFromSection(Config,cosmologyName)
constDict = dictFromSection(Config,'constants')
cc = Cosmology(cosmoDict,constDict,lmax)
theory = cc.theory

expX = Config.get('general','X')
expY = Config.get('general','Y')

beamX,beamFileX,fgFileX,noiseTX,noisePX,tellminX,tellmaxX,pellminX, \
    pellmaxX,lxcutTX,lycutTX,lxcutPX,lycutPX,lkneeTX,alphaTX,lkneePX,alphaPX = getLensParams(Config,expX)
beamY,beamFileY,fgFileY,noiseTY,noisePY,tellminY,tellmaxY,pellminY, \
    pellmaxY,lxcutTY,lycutTY,lxcutPY,lycutPY,lkneeTY,alphaTY,lkneePY,alphaPY = getLensParams(Config,expY)

cmb_bin_edges = np.arange(10,9000,10)


TCMB = Config.getfloat('general','TCMB')
gradCut = Config.getint('general','gradCut')
Ejemplo n.º 6
0
ellmin_cmb = 100
ellmax_cmb = 10000
dell_cmb = 100
lmax = 8000
beamArcmin = 1.4
noiseMukArcmin = 16.0
lknee = 3000
alpha = -4.6

bin_edges = np.arange(ellmin_cmb,ellmax_cmb,dell_cmb)
ellfine = np.arange(ellmin_cmb,ellmax_cmb,1)
binner = stats.bin2D(modLMap,bin_edges)

cents, pcls = binner.bin(pwindow)

cc = Cosmology(lmax=lmax,pickling=True)
theory = cc.theory
cltt = theory.lCl('TT',ellfine)

cltt2d = theory.lCl('TT',modLMap)


nfunc = cmb.get_noise_func(beamArcmin,noiseMukArcmin,ellmin=ellmin_cmb,ellmax=ellmax_cmb,TCMB=2.7255e6,lknee=lknee,alpha=alpha)

nells = nfunc(ellfine)

n2d = nfunc(modLMap)

n2dp = n2d/pwindow**2.
cents, nclsp = binner.bin(n2dp)
cents, ncls = binner.bin(n2d)
Ejemplo n.º 7
0
        x) * TCMB**2.

    # 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.theory.cosmology import Cosmology
    cc = Cosmology(lmax=int(max(pellmax, spellmax)), pickling=True)
    theory = cc.theory

    ellBBRange = np.arange(spellmin, spellmax)

    fclbb = cmb.noise_pad_infinity(
        interp1d(ellBBRange,
                 theory.lCl('BB', ellBBRange) * TCMB**2.,
                 fill_value=np.inf,
                 bounds_error=False), spellmin, spellmax)
    fflbb = interp1d(range(len(fCls[:, 2])),
                     rExp * fCls[:, 2] / rInFid,
                     bounds_error=False,
                     fill_value=np.inf)
    fdCls = interp1d(range(len(dCls[:, 2])),
                     dCls[:, 2],
Ejemplo n.º 8
0
tellmax = 3000
gradCut = 10000

pellmin = 100
pellmax = 5000

deg = 5.
px = 1.0
arc = deg * 60.

kellmin = 10
kellmax = 5000
bin_edges = np.arange(kellmin, kellmax, 10)

from orphics.theory.cosmology import Cosmology
cc = Cosmology(lmax=int(max(tellmax, pellmax, kellmax)), pickling=True)
theory = cc.theory

lmap = lm.makeEmptyCEATemplate(raSizeDeg=arc / 60.,
                               decSizeDeg=arc / 60.,
                               pixScaleXarcmin=px,
                               pixScaleYarcmin=px)
myNls = NlGenerator(lmap, theory, bin_edges, gradCut=gradCut)
myNls.updateNoise(beam, noiseT, noiseP, tellmin, tellmax, pellmin, pellmax)

polCombList = ['TT', 'EE', 'ET', 'EB', 'TB']
colorList = ['red', 'blue', 'green', 'orange', 'purple']
ellkk = np.arange(2, 9000, 1)
Clkk = theory.gCl("kk", ellkk)

lsmv, Nlmv, ells, dclbb, efficiency = myNls.getNlIterative(polCombList,
Ejemplo n.º 9
0
import os, sys
from orphics.theory.cosmology import Cosmology
import orphics.tools.cmb as cmb
import orphics.tools.io as io
import numpy as np

camb_lmax = 8500
cc = Cosmology(lmax=camb_lmax, pickling=True, dimensionless=False)
theory = cc.theory

lmax_of_interest = 6000
assert (lmax_of_interest + 2000) < camb_lmax

ellrange = np.arange(0, lmax_of_interest + 2000, 1)
clkk = theory.gCl('kk', ellrange)
dtheory = cmb.get_lensed_cls(theory, ellrange, clkk, lmax_of_interest)

#sys.exit()

ellrange = np.arange(2, lmax_of_interest, 1)
ucltt = theory.uCl('TT', ellrange)
lcltt = theory.lCl('TT', ellrange)
clcltt = dtheory.lCl('TT', ellrange)
clkk = theory.gCl('kk', ellrange)
pl = io.Plotter(scaleY='log')
pl.add(ellrange, ucltt * ellrange**2.)
pl.add(ellrange, lcltt * ellrange**2.)
pl.add(ellrange, clcltt * ellrange**2.)
pl._ax.set_xlim(2, lmax_of_interest)
pl.done("dcltt.png")
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
import flipper.liteMap as lm
from orphics.theory.cosmology import Cosmology
import numpy as np
import os, sys
import orphics.tools.io as io
import orphics.tools.stats as stats
import orphics.analysis.flatMaps as fmaps

out_dir = os.environ['WWW']
cc = Cosmology(pickling=True, clTTFixFile="../szar/data/cltt_lensed_Feb18.txt")

lmap = lm.makeEmptyCEATemplate(raSizeDeg=20., decSizeDeg=20.)

ells = np.arange(2, 6000, 1)
Cell = cc.clttfunc(ells)  #cc.theory.lCl('TT',ells)

lmap.fillWithGaussianRandomField(ells, Cell, bufferFactor=1)

io.highResPlot2d(lmap.data, out_dir + "map.png")

p2d = fmaps.get_simple_power(lmap, lmap.data * 0. + 1.)
lxMap, lyMap, modLMap, thetaMap, lx, ly = fmaps.getFTAttributesFromLiteMap(
    lmap)

bin_edges = np.arange(20, 4000, 40)
b = stats.bin2D(modLMap, bin_edges)
cents, cdat = b.bin(p2d)

pl = io.Plotter(scaleX='log', scaleY='log')
pl.add(ells, Cell * ells**2.)
pl.add(cents, cdat * cents**2.)