示例#1
0
文件: io.py 项目: msyriac/alhazen
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
示例#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)
示例#3
0
import numpy as np
import sys, os, glob
from orphics.analysis.pipeline import mpi_distribute, MPIStats, SpectrumVerification
import orphics.tools.stats as stats
import alhazen.io as aio
import orphics.tools.io as io
import orphics.analysis.flatMaps as fmaps
import warnings
import logging
logger = logging.getLogger()
with io.nostdout():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        from enlib import enmap, lensing, resample
from alhazen.quadraticEstimator import Estimator
import alhazen.lensTools as lt
from configparser import SafeConfigParser
from szar.counts import ClusterCosmology
import enlib.fft as fftfast
import argparse
from mpi4py import MPI

# Get MPI comm
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
numcores = comm.Get_size()

out_dir = "./"
analysis_section = "analysis"
sim_section = "sims"
expf_name = "experiment_noiseless"
示例#4
0
文件: io.py 项目: msyriac/alhazen
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