Beispiel #1
0
def load_binned_ty(mb,
                   dtype='dr2_smica',
                   fltr='cinv',
                   cmask='Lmask',
                   mtype=0,
                   ytype='nilc',
                   bhe=['lens']):

    # load filenames
    d = prjlib.data_directory()
    p = prjlib.init_analysis(dtype=dtype, fltr=fltr, wtype=cmask)
    cy = init_compy(p.ids, masktype=mtype, ytype=ytype)
    qobj = quad_func.quad(stag=p.stag,
                          root=d['root'],
                          ids=p.ids,
                          qtype='tau',
                          bhe=bhe,
                          rlmin=100,
                          rlmax=2048)
    ftxy = init_cross(qobj, cy, p.ids, p.stag)

    # optimal binning
    yy = savgol_filter((np.loadtxt(cy.fclyy)).T[1], 51, 3)
    al = (np.loadtxt(qobj.f['TT'].al)).T[1]
    vl = np.sqrt(al * yy) / np.sqrt(qobj.l + 1e-30)

    # results
    return bn.binned_spec(mb, ftxy.xl, cn=1, opt=True, vl=vl)
Beispiel #2
0
def init_quad(snmax, qtypes, **ikwargs):

    d = local.data_directory()

    kwargs = {\
        'n0min':1, \
        'n0max':int(snmax/2), \
        'mfmin':1, \
        'mfmax':snmax, \
        'rdmin':1, \
        'rdmax':snmax \
    }

    qlist = {}
    qlist['lens'] = ['TT', 'TE', 'EE', 'TB', 'EB']
    qlist['ilens'] = ['TB', 'EB', 'BB']

    # setup parameters for lensing reconstruction (see cmblensplus/utils/quad_func.py)
    return {
        qt: quad_func.quad(root=d['root'],
                           qtype=qt,
                           qlist=qlist[qt],
                           **kwargs,
                           **ikwargs)
        for qt in qtypes
    }
Beispiel #3
0
def init_quad(ids, stag, rlz=[], **kwargs):

    d = prjlib.data_directory()
    # setup parameters for lensing reconstruction (see cmblensplus/utils/quad_func.py)
    qtau = quad_func.quad(rlz=rlz,
                          stag=stag,
                          root=d['root'],
                          ids=ids,
                          qtype='tau',
                          **kwargs)
    qlen = quad_func.quad(rlz=rlz,
                          stag=stag,
                          root=d['root'],
                          ids=ids,
                          qtype='lens',
                          **kwargs)
    qsrc = quad_func.quad(rlz=rlz,
                          stag=stag,
                          root=d['root'],
                          ids=ids,
                          qtype='src',
                          **kwargs)
    qtbh = quad_func.quad(rlz=rlz,
                          stag=stag,
                          root=d['root'],
                          ids=ids,
                          qtype='tau',
                          bhe=['lens'],
                          **kwargs)
    qtBH = quad_func.quad(rlz=rlz,
                          stag=stag,
                          root=d['root'],
                          ids=ids,
                          qtype='tau',
                          bhe=['lens', 'src'],
                          **kwargs)

    #qtau.fname(d['root'],ids,stag)
    #qlen.fname(d['root'],ids,stag)
    #qsrc.fname(d['root'],ids,stag)
    #qtbh.fname(d['root'],ids,stag)
    #qtBH.fname(d['root'],ids,stag)

    return qtau, qlen, qsrc, qtbh, qtBH
Beispiel #4
0
def load_binned_tt(mb,
                   dtype='dr2_smica',
                   fltr='cinv',
                   cmask='Lmask',
                   bhe=['lens'],
                   snmax=100):

    # filename
    d = prjlib.data_directory()
    p = prjlib.init_analysis(snmax=snmax, dtype=dtype, fltr=fltr, wtype=cmask)
    qobj = quad_func.quad(stag=p.stag,
                          root=d['root'],
                          ids=p.ids,
                          qtype='tau',
                          bhe=bhe,
                          rlmin=100,
                          rlmax=2048)

    # optimal filter
    al = (np.loadtxt(qobj.f['TT'].al)).T[1]
    vl = al / np.sqrt(qobj.l + 1e-30)

    # binned spectra
    mtt, __, stt, ott = bn.binned_spec(mb,
                                       qobj.f['TT'].cl,
                                       cn=1,
                                       doreal=True,
                                       opt=True,
                                       vl=vl)

    # noise bias
    nb = bn.binning((np.loadtxt(qobj.f['TT'].n0bs)).T[1], mb, vl=vl)
    rd = np.array([(np.loadtxt(qobj.f['TT'].rdn0[i])).T[1] for i in p.rlz])
    rb = bn.binning(rd, mb, vl=vl)

    # debias
    ott = ott - rb[0] - nb / (qobj.mfsim)
    stt = stt - rb[1:, :] - nb / (qobj.mfsim - 1)

    # sim mean and std
    mtt = mtt - np.mean(rb[1:, :], axis=0) - nb / (qobj.mfsim - 1)
    vtt = np.std(stt, axis=0)

    # subtract average of sim
    ott = ott - mtt

    return mtt, vtt, stt, ott
    def __init__(self, config, ver=''):

        #//// get parameters ////#
        conf = config['DEFAULT']
        self.nside = conf.getint('nside', 4096)  #Nside for fullsky cmb map
        self.npix = 12 * self.nside**2
        self.lmin = conf.getint('lmin', 0)
        self.lmax = conf.getint('lmax', 3000)
        self.olmin = 1
        self.olmax = self.lmax
        self.ol = [self.olmin, self.olmax]
        self.bn = conf.getint('bn', 30)
        self.binspc = conf.get('binspc', '')

        self.snmin = conf.getint('snmin', 0)
        self.snmax = conf.getint('snmax', 100)
        self.stype = conf.get('stype', 'lcmb')
        self.PSA = conf.get('PSA', 's14&15_deep56')
        self.ascale = conf.getint('ascale', 1)
        self.doreal = conf.getboolean('doreal', False)
        self.dodust = conf.getboolean('dodust', False)
        self.dearot = conf.getboolean('dearot', False)
        self.lcut = conf.getint('lcut', 100)

        self.ver = conf.get('ver', ver)

        # reconstruction
        self.quad = quad_func.quad(config['QUADREC'])

        #//// Error check ////#
        #dearot
        if self.dearot:
            if not self.doreal:
                sys.exit('derot abs angle: doreal should be True')
            if self.stype != 'lcmb':
                sys.exit('derot abs angle: stype should be lcmb')

        #//// derived parameters ////#
        # total number of real + sim
        self.snum = self.snmax - self.snmin + 1
        self.psa = self.PSA.replace('&', '+')

        #mtype
        if '0p' in self.stype or self.stype == 'dust':
            self.mlist = ['E', 'B']
        else:
            self.mlist = ['T', 'E', 'B']

        #rlz num
        if '0p' in self.stype:
            self.quad.n0min = 1
            self.quad.n0max = 50
            self.quad.rdmin = 1
            self.quad.rdmax = 100
            self.quad.mfmin = 1
            self.quad.mfmax = 100
            self.quad.n0sim = 50
            self.quad.rdsim = 100
            self.quad.mfsim = 100

        #specific version
        if self.ver == 'v1':
            self.quad.n0min = 1
            self.quad.n0max = 100
            self.quad.rdmin = 1
            self.quad.rdmax = 200
            self.quad.mfmin = 1
            self.quad.mfmax = 200
            self.quad.n0sim = 100
            self.quad.rdsim = 200
            self.quad.mfsim = 200

        if self.ver == 'v2':
            self.quad.n0min = 1
            self.quad.n0max = 250
            self.quad.rdmin = 1
            self.quad.rdmax = 500
            self.quad.mfmin = 201
            self.quad.mfmax = 500
            self.quad.n0sim = 250
            self.quad.rdsim = 500
            self.quad.mfsim = 300

        #doreal
        if self.stype in ['dust']:
            self.doreal = False

        #noreal
        if self.stype in ['absrot', 'relrot']:
            self.doreal = False
            self.snmin = 1

        # directory
        self.Dir = '/global/homes/t/toshiyan/Work/Ongoing/ACT/data/curvedsky/'

        # tag
        self.stag = self.stype + '_' + self.psa + '_ns' + str(
            self.nside) + '_lc' + str(self.lcut) + '_a' + str(
                self.ascale) + 'deg'
        self.ids = [str(i).zfill(5) for i in range(501)]
        if self.doreal: self.ids[0] = 'real'
        if self.dearot: self.ids[0] = self.ids[0] + '_dearot'

        # alpha reconstruction
        quad_func.quad.fname(self.quad, self.Dir, self.ids, self.stag)

        # for v1 rec files
        if self.ver != '':
            q = 'EB'
            for i in range(501):
                self.quad.f[q].cl[i] = self.quad.f[q].cl[i].replace(
                    '.dat', '_' + self.ver + '.dat')