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)
def filename(self, ids): d = prjlib.data_directory() #//// public data ////# # original mask file for ymap self.fmask_org = plf.subd['pr2'][ 'ysz'] + 'COM_CompMap_Compton-SZMap-masks_2048_R2.01.fits' # ymap self.fymap = plf.subd['pr2']['ysz'] + self.ytype + '_ymaps.fits' #//// reduced data ////# # reduced mask (multiplied ptsr mask and costheta mask) self.fmask = d['win'] + 'ymask.fits' self.famask = d['win'] + 'ymask_a' + str(self.ascale) + 'deg.fits' if self.ascale == 0.0: self.famask = self.fmask # yalm ttag = '' if self.tausig: ttag = '_tausig' self.fyalm = [ d['ysz'] + 'alm/' + self.ytype + '_' + self.ymask + ttag + '_' + x + '.pkl' for x in ids ] # real clyy self.fclyy = d['ysz'] + 'aps/' + self.ytype + '_' + self.ymask + '.dat'
def fname(self, qtag, mlist, etag, doreal): #set directory d = prjlib.data_directory() ids = prjlib.rlz_index(doreal=doreal) # delensing internal tag ltag = 'le' + str(self.elmin) + '-' + str(self.elmax) + '_lk' + str( self.klmin) + '-' + str(self.klmax) ttag = ltag + '_' + self.kfltr + '_' + qtag + '_' + '-'.join( mlist.keys()) + '_' + etag #alm of lensing template B-modes self.falm, self.fwlm, self.cl = {}, {}, {} for k in self.klist: self.falm[k] = [ d['del'] + 'alm/alm_' + k + '_' + ttag + '_' + x + '.pkl' for x in ids ] self.cl[k] = [ d['del'] + 'aps/rlz/cl_' + k + '_' + ttag + '_' + x + '.dat' for x in ids ] self.gtag = '_ideal' # correlation coeff of templates self.frho = d['del'] + 'aps/rho_' + '-'.join(self.klist) + '_' + ttag
def init_compy(ids, **kwargs): d = prjlib.data_directory() cy = compy(**kwargs) compy.filename(cy, ids) return cy
def __init__(self, qtag, ytag, ids): d = prjlib.data_directory() xaps = d['xcor'] + '/aps/' xtag = qtag + '_' + ytag self.xl = [xaps + '/rlz/xl_' + xtag + '_' + x + '.dat' for x in ids] self.xcov = xaps + '/xcov_' + xtag + '.dat'
def init_qobj(stag, doreal, **kwargs): # setup parameters for lensing reconstruction (see cmblensplus/utils/quad_func.py) d = prjlib.data_directory() ids = prjlib.rlz_index(doreal=doreal) qobj = quad_func.reconstruction(d['root'], ids, stag=stag, run=[], **kwargs) return qobj
def __init__( self, glob, qobj, lmin=8, lmax=2007, add_cmb=['TT'], add_gal=np.arange(6), add_cib=True ): #lmax = 2007 #For now, set by the lmax in Byenoghee's spectra #lmin = 8 #For now, set by the lmin in Byenoghee's spectra # construct list of mass tracers to be combined self.klist_cmb = {} self.klist_gal = {} self.klist_cib = {} kid = 0 for k in add_cmb: self.klist_cmb[k] = kid kid += 1 for z in add_gal: self.klist_gal['g'+str(z)] = kid kid += 1 if add_cib: self.klist_cib['cib'] = kid self.klist = { **self.klist_cmb, **self.klist_gal, **self.klist_cib } self.klist_ext = { **self.klist_gal, **self.klist_cib } print(self.klist) self.lmin = lmin self.lmax = lmax self.nkap = len(self.klist) self.nlkk = {} for k, n in self.klist_cmb.items(): self.nlkk[n] = np.loadtxt( qobj.f[k].al, unpack=True )[1][:lmax+1] #set directory d = prjlib.data_directory() ids = prjlib.rlz_index( doreal=glob.doreal ) # cls self.fspec = '/global/project/projectdirs/sobs/delensing/multitracer_forBBgroup/spectra_of_tracers/' # kappa alm of each mass tracer self.fklm = {} for k in self.klist: self.fklm[k] = [ d['del'] + 'mass/' + k + '_' + str(i) + '.pkl' for i in ids ] # kappa alm of combined mass tracer qtag = glob.stag + qobj.ltag self.fcklm = [ d['del'] + 'mass/comb_' + qtag + '_' + '-'.join(self.klist.keys()) + '_' + str(i) + '.pkl' for i in ids ]
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_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
def __init__(self,doreal=False,telescope='la',ntype='base',freq='145',snmin=0,snmax=100,overwrite=False,verbose=True): self.telescope = str.upper(telescope) self.ntype = ntype self.band = int(freq) self.doreal = doreal self.rlz = np.linspace(snmin,snmax,snmax-snmin+1,dtype=np.int) self.overwrite = overwrite self.verbose = verbose if 'base' in ntype: self.mode = 'baseline' elif 'goal' in ntype: self.mode = 'goal' elif ntype == '': self.mode = 'signal' print('signal calculation') else: sys.exit('unknown noise level') if 'roll' in ntype: self.roll = int(ntype[ntype.find('roll')+4:]) else: self.roll = 0 self.nside, self.npix = prjlib.mapres(telescope) # set directory d = prjlib.data_directory() d_map = d['cmb'] + 'map/' # map filename ids = prjlib.rlz_index(doreal=doreal) if ntype == '': #cmb signal map if telescope == 'id': # use LAT signal sim self.fmap = [d_map+'/cmb_uKCMB_la145_nside'+str(self.nside)+'_'+x+'.fits' for x in ids] else: self.fmap = [d_map+'/cmb_uKCMB_'+telescope+freq+'_nside'+str(self.nside)+'_'+x+'.fits' for x in ids] else: #cmb noise map self.fmap = [d_map+'/noise_uKCMB_'+telescope+freq+'_'+ntype+'_nside'+str(self.nside)+'_'+x+'.fits' for x in ids]
def interface(run=[], kwargs_ov={}, kwargs_cmb={}, kwargs_qrec={}, ep=1e-30): if kwargs_cmb['t'] != 'la': sys.exit('only la is supported') # Define parameters, filenames for input CMB p = prjlib.analysis_init(**kwargs_cmb) # Load pre-computed w-factor which is used for correction normalization of spectrum wn = prjlib.wfac(p.telescope) # Compute filtering if p.fltr == 'none': # for none-filtered alm # Load "observed" aps containing signal, noise, and some residual. # This aps will be used for normalization calculation ocl = prjlib.loadocl(p.fcmb.scl['o'], lTmin=p.lTmin, lTmax=p.lTmax) # CMB alm will be multiplied by 1/ifl before reconstruction process ifl = ocl #p.lcl[0:3,:] elif p.fltr == 'cinv': # for C^-1 wiener-filtered alm pc = prjlib.analysis_init(t=p.telescope, freq='com', fltr='none', ntype=p.ntype) # Compute aps appropriate for C^-1 filtering case. ocl, ifl = quad_filter(p.fcmb.scl, pc.fcmb.scl, p.lmax, p.lcl, lTmin=p.lTmin, lTmax=p.lTmax) ocl[ocl <= 0.] = 1e30 ifl[ifl <= 0.] = 1e30 wn[:] = wn[0] else: sys.exit('unknown filtering') if 'iso' in p.ntype: #fullsky case wn[:] = 1. d = prjlib.data_directory() ids = prjlib.rlz_index(doreal=p.doreal) qobj = quad_func.reconstruction(d['root'], ids, rlz=p.rlz, stag=p.stag, run=run, wn=wn, lcl=p.lcl, ocl=ocl, ifl=ifl, falm=p.fcmb.alms['o'], **kwargs_ov, **kwargs_qrec) # Aps of reconstructed phi if 'aps' in run: aps(p.fltr, qobj, p.rlz, p.fpalm, wn) # Cinv kappa if 'kcinv' in run: compute_kcninv(qobj.f, p.rlz, p.fltr, p.kk[:qobj.olmax + 1], p.fpalm, Snmin=p.snmin, Snmax=p.snmax, qlist=qobj.qlist, **kwargs_ov)