def wtfromDDoDR(fbase,fend='.ang'): """ Quick hack, fill in options later. """ fDD = fbase+'.DRopt1'+fend fDR = fbase+'.DRopt2'+fend fRR = fbase+'.DRopt3'+fend DRfac = ximisc.getDRfactoronly(fbase,fend) t, DDg = np.loadtxt(fDD,skiprows=2,unpack=True) tchk, DRg = np.loadtxt(fDR,skiprows=2,unpack=True) assert (t==tchk).all() wt = 2.*DDg/DRg/DRfac - 1. return wtheta(wtfname=fbase,twlist= [t, wt])
def wpfromDDoDR(fbase,dfacr=1,periodicopt=0,DRfacinfo=None,rpimax=80.,testing=0,icovfname=None): """ This function computes wp from DRopt[1-2] files. DRfacinfo is used to pass [DRfac, fixRR] (dont get it from file headers in this case) That feature is necessary for computing covariance matrices from bootstrap, where that factor should be fixed by total N and/or S, it does not vary from bootstrap region to region. """ if(dfacr != 1): print 'dfacr not 1 is not coded up yet!' sys.exit(1) if(periodicopt == 1): # periodic box. print 'did not code up periodic yet!' sys.exit(1) else: fDD = fbase+'.DRopt1' fDR = fbase+'.DRopt2' rpg, rpig, DDg = np.loadtxt(fDD,skiprows=3,unpack=True) rpg, rpig, DRg = np.loadtxt(fDR,skiprows=3,unpack=True) if DRfacinfo is None: DRfac = ximisc.getDRfactoronly(fbase) else: try: DRfac = DRfacinfo[0] except: DRfac = DRfacinfo print 'using DRfac',DRfac nrpibins = len(np.where(rpg == rpg[0])[0]) nrpbins = len(np.where(rpig == rpig[0])[0]) if nrpibins*nrpbins != len(DDg): return None xi = (2.*DDg/DRg/DRfac - 1.) rpi1d = rpig.reshape(nrpbins,nrpibins)[0] ## check that it's linearly spaced, get drpi drpi = rpi1d[1]-rpi1d[0] chk = rpi1d[1:] - rpi1d[:-1] - drpi aaa = np.where(np.fabs(chk) > 1.0e-5)[0] if(len(aaa) > 0): print 'error!' sys.exit(1) assert np.fabs(rpi1d[0]-drpi*0.5) < 1e-3 rp1d = rpg.reshape(nrpbins,nrpibins)[:,0] mywp = np.zeros(len(rp1d),dtype='float') wpi = 0 for rpval in rp1d: if(testing==1): print 'inside testing' xx = np.where(rpg == rpval)[0] assert len(xx) == nrpibins xicurr = xi[xx] assert (rpig[xx] == rpi1d).all() assert np.fabs(rpi1d[0]-drpi*0.5) < 1e-3 ## ok, we're sure rpigrid is sane. xx = np.where((rpg == rpval) & (rpig < rpimax))[0] mywp[wpi] = (xi[xx]).sum()*drpi*2. wpi += 1 return wp(wpfname=fDR,icovfname=icovfname,rpwplist=[rp1d,mywp])