Ejemplo n.º 1
0
def recon_from_config(Config,
                      recon_section,
                      parray,
                      theory,
                      lmax,
                      grad_cut=None,
                      pol=False,
                      u_equals_l=True):
    min_ell = fmaps.minimum_ell(parray.shape, parray.wcs)
    lb = ellbounds_from_config(Config, recon_section, min_ell)
    tellmin = lb['tellminY']
    tellmax = lb['tellmaxY']
    pellmin = lb['pellminY']
    pellmax = lb['pellmaxY']
    kellmin = lb['kellmin']
    kellmax = lb['kellmax']

    lxmap_dat, lymap_dat, modlmap_dat, angmap_dat, lx_dat, ly_dat = fmaps.get_ft_attributes_enmap(
        parray.shape, parray.wcs)
    template_dat = fmaps.simple_flipper_template_from_enmap(
        parray.shape, parray.wcs)
    nT = parray.nT
    nP = parray.nP
    kbeam_dat = parray.lbeam
    fMaskCMB_T = fmaps.fourierMask(lx_dat,
                                   ly_dat,
                                   modlmap_dat,
                                   lmin=tellmin,
                                   lmax=tellmax)
    fMaskCMB_P = fmaps.fourierMask(lx_dat,
                                   ly_dat,
                                   modlmap_dat,
                                   lmin=pellmin,
                                   lmax=pellmax)
    fMask = fmaps.fourierMask(lx_dat,
                              ly_dat,
                              modlmap_dat,
                              lmin=kellmin,
                              lmax=kellmax)
    with oio.nostdout():
        from alhazen.quadraticEstimator import Estimator
        qest = Estimator(template_dat,
                         theory,
                         theorySpectraForNorm=None,
                         noiseX2dTEB=[nT, nP, nP],
                         noiseY2dTEB=[nT, nP, nP],
                         fmaskX2dTEB=[fMaskCMB_T, fMaskCMB_P, fMaskCMB_P],
                         fmaskY2dTEB=[fMaskCMB_T, fMaskCMB_P, fMaskCMB_P],
                         fmaskKappa=fMask,
                         kBeamX=kbeam_dat,
                         kBeamY=kbeam_dat,
                         doCurl=False,
                         TOnly=not (pol),
                         halo=True,
                         uEqualsL=u_equals_l,
                         gradCut=grad_cut,
                         bigell=lmax)

    return tellmin, tellmax, pellmin, pellmax, kellmin, kellmax, qest
Ejemplo n.º 2
0
    def _init_qests(self):

        
        mlist = ['e','s','r']
        self.qest = {}
        tellminY = 500
        tellmaxY = 3000
        pellminY = 500
        pellmaxY = 3000
        tellminX = 500
        tellmaxX = 3000
        pellminX = 500
        pellmaxX = 3000
        kellmin = 80
        kellmax = 3000
        self.kellmin = kellmin
        self.kellmax = kellmax
        
        for m in mlist:
            lxmap_dat,lymap_dat,modlmap_dat,angmap_dat,lx_dat,ly_dat = fmaps.get_ft_attributes_enmap(self.shape[m],self.wcs[m])
            nT = modlmap_dat.copy()*0.
            nP = modlmap_dat.copy()*0.
            lbeam = modlmap_dat.copy()*0.+1.
            template_dat = fmaps.simple_flipper_template_from_enmap(self.shape[m],self.wcs[m])
            fMaskCMB_TX = fmaps.fourierMask(lx_dat,ly_dat,modlmap_dat,lmin=tellminX,lmax=tellmaxX)
            fMaskCMB_TY = fmaps.fourierMask(lx_dat,ly_dat,modlmap_dat,lmin=tellminY,lmax=tellmaxY)
            fMaskCMB_PX = fmaps.fourierMask(lx_dat,ly_dat,modlmap_dat,lmin=pellminX,lmax=pellmaxX)
            fMaskCMB_PY = fmaps.fourierMask(lx_dat,ly_dat,modlmap_dat,lmin=pellminY,lmax=pellmaxY)
            fMask = fmaps.fourierMask(lx_dat,ly_dat,modlmap_dat,lmin=kellmin,lmax=kellmax)
            with io.nostdout():
                self.qest[m] = Estimator(template_dat,
                                         self.theory,
                                         theorySpectraForNorm=None,
                                         noiseX2dTEB=[nT,nP,nP],
                                         noiseY2dTEB=[nT,nP,nP],
                                         fmaskX2dTEB=[fMaskCMB_TX,fMaskCMB_PX,fMaskCMB_PX],
                                         fmaskY2dTEB=[fMaskCMB_TY,fMaskCMB_PY,fMaskCMB_PY],
                                         fmaskKappa=fMask,
                                         kBeamX = lbeam,
                                         kBeamY = lbeam,
                                         doCurl=False,
                                         TOnly=True,
                                         halo=True,
                                         uEqualsL=True,
                                         gradCut=None,verbose=False,
                                         bigell=self.lmax)
Ejemplo n.º 3
0
    def __init__(self, shape, wcs, gradCut=None, kBeamX=None, kBeamY=None):
        '''

        templateFT is a template liteMap FFT object
    

    
        '''
        self.Ny, self.Nx = shape[-2:]
        self.lxMap, self.lyMap, self.modLMap, self.thetaMap, self.lx, self.ly = fmaps.get_ft_attributes_enmap(
            shape, wcs)
        self.lxHatMap = self.lxMap * np.nan_to_num(1. / self.modLMap)
        self.lyHatMap = self.lyMap * np.nan_to_num(1. / self.modLMap)

        if kBeamX is not None:
            self.kBeamX = kBeamX
        else:
            self.kBeamX = 1.

        if kBeamY is not None:
            self.kBeamY = kBeamY
        else:
            self.kBeamY = 1.

        self.uClNow2d = {}
        self.uClFid2d = {}
        self.lClFid2d = {}
        self.noiseXX2d = {}
        self.noiseYY2d = {}

        if gradCut is not None:
            self.gradCut = gradCut
        else:
            self.gradCut = self.modLMap.max()

        self.Nlkk = {}
        self.pixScaleY, self.pixScaleX = enmap.pixshape(shape, wcs)
Ejemplo n.º 4
0
    pl.add(ellrange,cltt*ellrange**2.,color="k")
    pl.add(ellrange,clee*ellrange**2.,color="k")
    pl.add(ellrange,clbb*ellrange**2.,color="k")
    pl.add(cents,dtt*cents**2.)
    pl.add(cents,dee*cents**2.)
    pl.add(cents,dbb*cents**2.)
    pl.done(out_dir+"powers_"+suffix+".png")


plot_powers(cmb,suffix="periodic",w2=1.)    
taper,w2 = fmaps.get_taper(shape,taper_percent = 12.0,pad_percent = 3.0,weight=None)
plot_powers(cmb*taper,suffix="tapered",w2=w2)    

print("Pure...")
windict = pure.initializeDerivativesWindowfuntions(taper,px*np.pi/180./60.)
lxMap,lyMap,modLMap,angLMap,lx,ly = fmaps.get_ft_attributes_enmap(shape,wcs)
fT, fE, fB = pure.TQUtoPureTEB(cmb[0],cmb[1],cmb[2],modlmap,angLMap,windowDict=windict,method='pure')
power = np.zeros((3,3,shape[-2],shape[-1]))
power[0,0,:,:] = fc.f2power(fT,fT)
power[1,1,:,:] = fc.f2power(fE,fE)
power[2,2,:,:] = fc.f2power(fB,fB)
plot_powers(None,suffix="pure",power=power,w2=w2)    
                 

def mcm(power,bin_edges,\
        kmask,\
        transfer = None,\
        binningWeightMap = None):
    """
    window: data window
    
Ejemplo n.º 5
0
# Efficiently distribute sims over MPI cores
num_each, each_tasks = mpi_distribute(Nsims, numcores)
# Initialize a container for stats and stacks
mpibox = MPIStats(comm, num_each, tag_start=333)
if rank == 0: print(("At most ", max(num_each), " tasks..."))
# What am I doing?
my_tasks = each_tasks[rank]

# === COSMOLOGY ===
theory, cc, lmax = aio.theory_from_config(Config,
                                          cosmology_section,
                                          dimensionless=False)
parray_dat.add_theory(cc, theory, lmax, orphics_is_dimensionless=False)
parray_sim.add_theory(cc, theory, lmax, orphics_is_dimensionless=False)

lxmap_dat, lymap_dat, modlmap_dat, angmap_dat, lx_dat, ly_dat = fmaps.get_ft_attributes_enmap(
    shape_dat, wcs_dat)
lxmap_sim, lymap_sim, modlmap_sim, angmap_sim, lx_sim, ly_sim = fmaps.get_ft_attributes_enmap(
    shape_sim, wcs_sim)
kellmin = args.kellmin
kellmax = args.kellmax
lbin_edges = np.arange(kellmin, kellmax, 200)
lbinner_dat = stats.bin2D(modlmap_dat, lbin_edges)
lbinner_sim = stats.bin2D(modlmap_sim, lbin_edges)

sverif_cmb = SpectrumVerification(mpibox,
                                  theory,
                                  shape_sim,
                                  wcs_sim,
                                  lbinner=lbinner_sim,
                                  pol=pol)
sverif_dcmb = SpectrumVerification(mpibox,
Ejemplo n.º 6
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)
fmask = fmaps.fourierMask(lx_dat,
                          ly_dat,
                          modlmap_dat,
                          lmin=kellmin,
                          lmax=kellmax)
nlgen = qe.NlGenerator(template, theory)
nTX, nPX, nTY, nPY = nlgen.updateNoise(beamX=beam,
                                       noiseTX=noiseT,
                                       noisePX=0.,
                                       tellminX=tellmin,
                                       tellmaxX=tellmax,
                                       pellminX=pellmin,
                                       pellmaxX=pellmax)
Ejemplo n.º 7
0
from enlib import enmap, curvedsky, lensing
import orphics.tools.io as io
import orphics.tools.cmb as cmb
import orphics.analysis.flatMaps as fmaps
import numpy as np
import healpy as hp

deg = 20.
px = 2.0

shape,wcs = enmap.rect_geometry(deg*60.,px,proj="car",pol=False)
modlmap = enmap.modlmap(shape,wcs)


lxmap,lymap,modlmap,angmap,lx,ly = fmaps.get_ft_attributes_enmap(shape,wcs)
amajor = 3000
bminor = 100
angle = np.pi/4.
r_square = ((lxmap)*np.cos(angle)+(lymap)*np.sin(angle))**2./amajor**2.+((lxmap)*np.sin(angle)-(lymap)*np.cos(angle))**2./bminor**2.
elfact = (1.+1.e3*np.exp(-r_square))
#elfact = 1.
p2d = elfact * cmb.white_noise_with_atm_func(modlmap,uk_arcmin=10.0,lknee=4000,alpha=-4.5,dimensionless=False,TCMB=2.7255e6) 
p2d[modlmap<90]=0.
p2d[modlmap>4000]=0.
io.quickPlot2d(np.fft.fftshift(np.log10(p2d)),io.dout_dir+"p2d.png")
mg = enmap.MapGen(shape,wcs,p2d.reshape(1,1,modlmap.shape[0],modlmap.shape[1]))
imap = mg.get_map()

io.quickPlot2d(imap,io.dout_dir+"cmb.png")
# imap2 = mg.get_map()
# io.quickPlot2d(imap2,io.dout_dir+"cmb2.png")