def allpowersTEB(mapT, mapE, mapB, binFile = None): fT = fftTools.fftFromLiteMap(mapT) fE = fftTools.fftFromLiteMap(mapE) fB = fftTools.fftFromLiteMap(mapB) #for now no cross spectra in this routine, can be addded if necessary. TT_power,TE_power,ET_power,TB_power,BT_power,EE_power,EB_power,BE_power,BB_power=fftPol.fourierTEBtoPowerTEB(fT,fE,fB,fT.copy(),fE.copy(), fB.copy()) l_Lo,l_Up,lbin,cl_TT,j,k = statsTools.aveBinInAnnuli(TT_power, binFile)#, './binningTest') l_Lo,l_Up,lbin,cl_TE,j,k = statsTools.aveBinInAnnuli(TE_power, binFile)#, './binningTest') l_Lo,l_Up,lbin,cl_TB,j,k = statsTools.aveBinInAnnuli(TB_power, binFile)#, './binningTest') l_Lo,l_Up,lbin,cl_EE,j,k = statsTools.aveBinInAnnuli(EE_power, binFile)#, './binningTest') l_Lo,l_Up,lbin,cl_EB,j,k = statsTools.aveBinInAnnuli(EB_power, binFile)#, './binningTest') l_Lo,l_Up,lbin,cl_BB,j,k = statsTools.aveBinInAnnuli(BB_power, binFile)#, './binningTest') #this will be what we leave in after the unblinding...... print 'got here e' output = {'lbin':lbin, \ 'cl_TT':cl_TT, \ 'cl_TE':cl_TE, \ 'cl_EE':cl_EE, \ 'cl_EB':cl_EB, \ 'cl_BB':cl_BB} return output
def quickPower(inmap, inmap2=None, window=None, useFlipperRoutine=False, applySlepianTaper=False, nanToNum=True, binFile=None): if binFile == None: binFileToUse = 'binningTest' else: binFileToUse = binFile temp = inmap.copy() if inmap2 == None: temp2 = inmap.copy() else: temp2 = inmap2.copy() if window != None: temp.data *= window.data / sqrt(numpy.mean(window.data**2)) temp2.data *= window.data / sqrt(numpy.mean(window.data**2)) # print "correcting for window" if nanToNum: temp.data = numpy.nan_to_num(temp.data) temp2.data = numpy.nan_to_num(temp2.data) power2D = fftTools.powerFromLiteMap(temp, liteMap2=temp2, applySlepianTaper=applySlepianTaper) if useFlipperRoutine: llower, lupper, lbin, clbin_0, clbin_N, binweight = power2D.binInAnnuli( binFileToUse, nearestIntegerBinning=True) else: llower, lupper, lbin, clbin_0, clbin_N, binweight = statsTools.aveBinInAnnuli( power2D, binFileToUse) output = { 'lbin': lbin, 'clbin': clbin_0, 'dlbin': lbin * (lbin + 1) * clbin_0 / 2 / numpy.pi } # return (lbin, clbin_0) return output
def allpowers(T_map, Q_map, U_map, T_map2 = None, Q_map2 = None, U_map2 = None , \ window = None, beamFile = None, flipQ = False, \ method = 'pure', binFile = None) : T_map_local = T_map.copy() Q_map_local = Q_map.copy() U_map_local = U_map.copy() T_map_local.data = numpy.nan_to_num(T_map_local.data) Q_map_local.data = numpy.nan_to_num(Q_map_local.data) U_map_local.data = numpy.nan_to_num(U_map_local.data) if T_map2 != None: T_map2_local = T_map2.copy() Q_map2_local = Q_map2.copy() U_map2_local = U_map2.copy() else: T_map2_local = T_map.copy() Q_map2_local = Q_map.copy() U_map2_local = U_map.copy() T_map2_local.data = numpy.nan_to_num(T_map2_local.data) Q_map2_local.data = numpy.nan_to_num(Q_map2_local.data) U_map2_local.data = numpy.nan_to_num(U_map2_local.data) print 'got here' if flipQ: print 'note: flipping sign of Q map' Q_map_local.data *= -1. if window != None: T_map_local.data *= window.data / sqrt(numpy.mean(window.data**2)) Q_map_local.data *= 1 / sqrt(numpy.mean(window.data**2)) U_map_local.data *= 1 / sqrt(numpy.mean(window.data**2)) T_map2_local.data *= window.data / sqrt(numpy.mean(window.data**2)) Q_map2_local.data *= 1 / sqrt(numpy.mean(window.data**2)) U_map2_local.data *= 1 / sqrt(numpy.mean(window.data**2)) else: window = T_map.copy() window.data[:] = 1. modLMap, angLMap = fftPol.makeEllandAngCoordinate(T_map_local, bufferFactor=1) print 'got here a' fT, fE, fB = fftPol.TQUtoPureTEB(T_map_local, Q_map_local, U_map_local, window, modLMap, angLMap, method=method) print 'got here b' fT2, fE2, fB2 = fftPol.TQUtoPureTEB(T_map2_local, Q_map2_local, U_map2_local, window, modLMap, angLMap, method=method) if beamFile != None: beamdata = numpy.loadtxt(beamFile) ell, f_ell = numpy.transpose(beamdata)[0:2, :] t = mapTools.makeTemplate(ell, f_ell, fT) fT.kMap /= t fE.kMap /= t fB.kMap /= t fT2.kMap /= t fE2.kMap /= t fB2.kMap /= t # print 'got here' # pdb.set_trace() print 'got here c' TT_power, TE_power, ET_power, TB_power, BT_power, EE_power, EB_power, BE_power, BB_power = fftPol.fourierTEBtoPowerTEB( fT, fE, fB, fT2, fE2, fB2) print 'got here d' l_Lo, l_Up, lbin, cl_TT, j, k = statsTools.aveBinInAnnuli( TT_power, binFile) #, './binningTest') l_Lo, l_Up, lbin, cl_TE, j, k = statsTools.aveBinInAnnuli( TE_power, binFile) #, './binningTest') l_Lo, l_Up, lbin, cl_TB, j, k = statsTools.aveBinInAnnuli( TB_power, binFile) #, './binningTest') l_Lo, l_Up, lbin, cl_EE, j, k = statsTools.aveBinInAnnuli( EE_power, binFile) #, './binningTest') l_Lo, l_Up, lbin, cl_EB, j, k = statsTools.aveBinInAnnuli( EB_power, binFile) #, './binningTest') l_Lo, l_Up, lbin, cl_BB, j, k = statsTools.aveBinInAnnuli( BB_power, binFile) #, './binningTest') #this will be what we leave in after the unblinding...... print 'got here e' output = {'lbin':lbin, \ 'cl_TT':cl_TT, \ 'cl_TE':cl_TE, \ 'cl_EE':cl_EE, \ 'cl_EB':cl_EB, \ 'cl_BB':cl_BB} # output = {'lbin':lbin, \ # 'cl_TT':cl_TT, \ # 'cl_TE':cl_TE, \ # 'cl_EE':cl_EE} return output