Пример #1
0
	def __init__(self,file='MICE_matterpower',dir='',bias=1.8,mun=0,beta=0.4,sfog=0,amc=0.0,sigt=6.,sigr=10.,mult=1.,sigs=15.,gam=-1.7):
		dir = 'BAOtemplates/'
		self.f0 = loadtxt(dir+'xi0'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
		self.f2 = loadtxt(dir+'xi2'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
		self.f4 = loadtxt(dir+'xi4'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
		self.f0sm = loadtxt(dir+'xi0sm'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
		self.f2sm = loadtxt(dir+'xi2sm'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
		self.f4sm = loadtxt(dir+'xi4sm'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
		from Cosmo import distance
		if file == 'Challenge_matterpower':
			d = distance(.31,.69)
		if file == 'MICE_matterpower' or file == 'Pk_MICEcosmology_z0_Plin_Pnowig':
			d = distance(.25,.75)
		self.d = d
		self.beta = beta
		self.bias = bias
		self.gam = gam
Пример #2
0
def xi0dfile_dewig(r,file='Challenge_matterpower',dir='',sig=8.,max=51,ns=.95,sigz=0,pw='n'):
	from scipy.integrate import quad
	from Cosmo import distance
	#f = open('/Users/ashleyr/BOSS/spec/camb_MWcos.dat')
	#print dir
	mult = 1.
	dir = 'powerspectra/'
	if file=='Challenge_matterpower' or file == 'TSPT_out':
		om = 0.31
		lam = 0.69
		h = .676
		nindex = .963
		ombhh = .022
	if file == 'MICE_matterpower':
		om = 0.25
		lam = .75
		h = .7
		ombhh = .044*0.7*.7	
		nindex = .949

	f = open(dir+file+'.dat').readlines()

	s = simulate(omega=om,lamda=lam,h=h,nindex=nindex,ombhh=ombhh)
	k0 = float(f[0].split()[0])
	k1 = float(f[1].split()[0])
	ldk = log(k1)-log(k0)
	#print ldk
	xi0 = 0
	xism0 = 0
	#print max
	dmk = r/10.
	k = float(f[0].split()[0])
	if file == 'camb_Nacc':
		norm = 1.
	else:
		norm = float(f[0].split()[1])/s.Psmooth(k,0)*mult
	#print norm
	b = 2.
	if sigz != 0:
		z = .8
		d = distance(.25,.75)
		sigzc = d.cHz(z)*sigz
	for i in range(0,len(f)-1):
		k = float(f[i].split()[0])
		pk = float(f[i].split()[1])*mult
		pksm = s.Psmooth(k,0)*norm
		dpk = pk-pksm
		damp = exp(-.5*k*k*sig**2.)
		pk0 = (dpk*damp+pksm)
		pksm0 = pksm
		dk = ldk*k
		xi0 += dk*k*k*pk0*sph_jn(0,k*r)*exp(-1.*dmk*k**2.)
		xism0 += dk*k*k*pksm0*sph_jn(0,k*r)*exp(-1.*dmk*k**2.)
	return xi0/(2.*pi*pi),xism0/(2.*pi*pi)
Пример #3
0
def createSourcesrd_ari(sample, tile, date, ii, zmin=.5, zmax=1.1, datadir=''):
    '''
    prepare sv files for paircounts
    '''
    #from healpix import healpix,radec2thphi
    from random import random
    from Cosmo import distance
    d = distance(
        om, 1. - om
    )  #cosmology assumed in final BOSS analyses, make sure this conforms to current
    #h = healpix()
    file = sample + tile + '_' + date

    fr = fitsio.read(datadir + file + '_' + str(ii) + '_clustering.ran.fits')
    wz = (fr['Z'] > zmin) & (fr['Z'] < zmax)

    zl = fr[wz]['Z']

    cdl = np.zeros(len(zl))
    for i in range(0, len(zl)):
        cdl[i] = d.dc(zl[i])
    sral = np.sin(np.radians(fr[wz]['RA']))
    cral = np.cos(np.radians(fr[wz]['RA']))
    sdecl = np.sin(np.radians(fr[wz]['DEC']))
    cdecl = np.cos(np.radians(fr[wz]['DEC']))
    wl = np.ones(len(cdl))
    print(str(len(cdl)) + ' random objects going out for paircounts')
    zw = '_zm' + str(zmin) + 'zx' + str(zmax)
    gf = 'g' + file + zw
    rf = 'r' + file + str(ii) + zw
    fdo = open(dirpcadw + rf + 'pcadw.dat', 'w')
    for i in range(0, len(cdl)):
        fdo.write(
            str(sral[i]) + ' ' + str(cral[i]) + ' ' + str(sdecl[i]) + ' ' +
            str(cdecl[i]) + ' ' + str(cdl[i]) + ' ' + str(wl[i]) + '\n')

    fdo.close()
    fo = open('dopc' + rf + '.sh', 'w')
    fo.write('#!/bin/bash\n')
    fo.write('./pp2pt_Dmufb ' + gf + ' ' + rf + ' \n')
    fo.write('./pp2pt_Dmufb ' + rf + ' ' + rf + ' \n')
    fo.close()

    return rf
Пример #4
0
def plotvolz():
	pp = PdfPages('volz.pdf')
	from Cosmo import distance
	d = distance(.3,.7)
	vl = []
	zl = []
	dz = .01
	z = .01
	while z < 10:
		v = pi*(d.dc(z)/1000.)**3.
		vl.append(v)
		zl.append(z)
		z += dz	
	#plt.loglog(zl,vl)
	plt.plot(zl,vl)
	plt.ylim(1.,1000)
	plt.yscale('log')
	plt.xlabel('Maximum Redshift')
	plt.ylabel(r'Volume for 3/4 of sky (Gpc$h^{-1}$)$^3$')
	pp.savefig()
	pp.close()
	return True	
Пример #5
0
def pk3elldfile_dewig(file='Challenge_matterpower',
                      beta=0.4,
                      sigt=3.0,
                      sigr=3.0,
                      sfog=3.5,
                      mun=1.,
                      sigs=15.,
                      ns=.963,
                      sigz=0,
                      pw='y'):
    '''
    returns arrays for k, p0,2,4 multipoles for BAO and no BAO
    file is input linear P(k)
    
    mun = 0 for pre rec and 1 for post-rec with RSD removal (controls effect of smoothing scaling on RSD)
    beta is fiducial f/b
    sfog: the streaming velocity parameter, often denoted Sigma_s
    sigz: for redshift uncertainties, ignore for most cases
    sigt: transverse BAO damping, Sigma_\perp
    sigr: radial BAO damping, Sigma_||
    sigs: smoothing scale used in reconstruction (irrelevant if mun = 0)
    ns: varying ns used in no BAO P(k); best results often come from using one that is slightly different than linear P(k) one (probably could be fixed with EH.py)
    
    '''
    from scipy.integrate import quad
    from Cosmo import distance
    mult = 1.
    dir = 'powerspectra/'
    if file == 'Challenge_matterpower' or file == 'TSPT_out':
        om = 0.31
        #lam = 1
        h = .676
        nindex = ns
        ombhh = .022
    if file == 'MICE_matterpower':
        om = 0.25
        #lam = .75
        h = .7
        ombhh = .044 * 0.7 * .7
        nindex = .949
    if file == 'DESI':
        from cosmoprimo.fiducial import DESI
        from cosmoprimo import PowerSpectrumBAOFilter
        cosmo = DESI()
        pkz = cosmo.get_fourier().pk_interpolator()
        pk = pkz.to_1d(z=0)
        kl = np.loadtxt(dir + 'Challenge_matterpower.dat').transpose()[
            0]  #this k spacing is known to work well
        pkv = pk(kl)
        pknow = PowerSpectrumBAOFilter(
            pk, engine='wallish2018').smooth_pk_interpolator()
        pksmv = pknow(kl)
    if file != 'DESI':
        f = np.loadtxt(dir + file + '.dat').transpose()
    if pw == 'y':
        fo = open(
            'P02' + file + 'beta' + str(beta) + 'sigs' + str(sfog) + 'sigxy' +
            str(sigt) + 'sigz' + str(sigr) + 'Sk' + str(sigs) + '.dat', 'w')
        fo.write('# k P0 P2 P4 Psmooth0 Psmooth2 Psmooth4 Plin Plinsmooth\n')
    if file != 'Pk_MICEcosmology_z0_Plin_Pnowig' and file != 'DESI':
        s = simulate(omega=om, lamda=1 - om, h=h, nindex=nindex, ombhh=ombhh)
    elif file == 'Pk_MICEcosmology_z0_Plin_Pnowig':
        mult = 8. * pi**3.
    pl2 = []
    pl4 = []
    beta0 = 0.4
    for i in range(0, 100):
        pl2.append(P2(i / 100. + .005))
    for i in range(0, 100):
        pl4.append(P4(i / 100. + .005))
    mul = []
    anipolyl = []
    for i in range(0, 100):
        mu = i / 100. + .005
        mul.append(mu)
    b = 2.
    ff = beta * b
    if sigz != 0:
        z = .8
        d = distance(.25, .75)
        sigzc = d.cHz(z) * sigz

    norm = 1
    if file != 'DESI':
        kl = f[0]
        pml = f[1]
        norm = pml[0] / s.Psmooth(kl[0], 0)
    p0l = []
    p2l = []
    p4l = []
    psm0l = []
    psm2l = []
    psm4l = []

    for i in range(0, len(kl)):
        k = kl[i]
        if file != 'DESI':
            pk = pml[i] * mult
        else:
            pk = pkv[i]
        pk0 = 0
        pk2 = 0
        pk4 = 0
        pksm0 = 0
        pksm2 = 0
        pksm4 = 0
        if file == 'Pk_MICEcosmology_z0_Plin_Pnowig':
            pksm = float(f[i].split()[2]) * mult
        elif file == 'DESI':
            pksm = pksmv[i]
        else:
            pksm = s.Psmooth(k, 0) * norm
        dpk = pk - pksm
        for m in range(0, 100):
            #mu = (1.-mul[m])
            mu = mul[m]

            if mun == 'n':
                mu = (1. - mul[m])
            if sfog > 0:
                F = 1. / (1. + k**2. * mu**2. * sfog**2. / 2.)**2.
            else:
                F = (1. + k**2. * sfog**2. / 2.)**2. / (
                    1. + k**2. * (1. - mu)**2. * sfog**2. / 2.)**2.
            if mun == 'b':
                mus2 = mu**2.
                F = (1. + beta * mus2 *
                     (1. - exp(-0.5 * (k * sigs)**2.)))**2. * 1. / (
                         1. + k**2. * mu**2. * (sfog)**2. / 2.)**2.
            #C *doesn't include damping*
            S = mun * exp(-0.5 * (k * sigs)**2.)
            C = (1. + beta * mu * mu * (1. - S)) * 1. / (1. + k**2. * mu**2. *
                                                         (sfog)**2. / 2.)
            sigv2 = (1 - mu**2.) * sigt**2. / 4. + mu**2. * sigr**2. / 4.
            damp = exp(-1. * k * k * sigv2)
            if sigz != 0:
                C = C * exp(-0.5 * k * k * mu * mu * sigzc * sigzc)
            pkmu = C**2. * (dpk * damp**2. + pksm)
            pkmusm = C**2. * pksm
            pk0 += pkmu
            pk2 += pkmu * pl2[m]
            pk4 += pkmu * pl4[m]
            pksm0 += pkmusm
            pksm2 += pkmusm * pl2[m]
            pksm4 += pkmusm * pl4[m]
        pk0 = pk0 / 100.
        pk2 = 5. * pk2 / 100.
        pk4 = 9. * pk4 / 100.
        pksm0 = pksm0 / 100.
        pksm2 = 5. * pksm2 / 100.
        pksm4 = 9. * pksm4 / 100.
        p0l.append(pk0)
        p2l.append(pk2)
        p4l.append(pk4)
        psm0l.append(pksm0)
        psm2l.append(pksm2)
        psm4l.append(pksm4)
        print(pk0, pksm0, dpk)

        if pw == 'y':
            fo.write(
                str(k) + ' ' + str(pk0) + ' ' + str(pk2) + ' ' + str(pk4) +
                ' ' + str(pksm0) + ' ' + str(pksm2) + ' ' + str(pksm4) + ' ' +
                str(pk) + ' ' + str(pksm) + '\n')

    if pw == 'y':
        fo.close()
        from matplotlib import pyplot as plt
        from numpy import loadtxt as load
        d = load('P02' + file + 'beta' + str(beta) + 'sigs' + str(sfog) +
                 'sigxy' + str(sigt) + 'sigz' + str(sigr) + 'Sk' + str(sigs) +
                 '.dat').transpose()
        plt.xlim(0, .5)
        plt.plot(d[0], d[-2] / d[-1])
        plt.plot(d[0], np.ones(len(d[0])), '--')
        plt.show()
    p0l = np.array(p0l)
    p2l = np.array(p2l)
    p4l = np.array(p4l)
    psm0l = np.array(psm0l)
    psm2l = np.array(psm2l)
    psm4l = np.array(psm4l)
    return kl, p0l, p2l, p4l, psm0l, psm2l, psm4l
Пример #6
0
def xi3elldfile_dewig(r,file='Challenge_matterpower',dir='',beta=0.4,sigt=3.0,sigr=3.0,sfog=3.5,max=51,mun=1.,sigs=15.,ns=.95,sigz=0,pw='n'):
	from scipy.integrate import quad
	from Cosmo import distance
	#f = open('/Users/ashleyr/BOSS/spec/camb_MWcos.dat')
	#print dir
	mult = 1.
	dir = 'powerspectra/'
	if file=='Challenge_matterpower' or file == 'TSPT_out':
		om = 0.31
		lam = 0.69
		h = .676
		nindex = .963
		ombhh = .022
	if file == 'MICE_matterpower':
		om = 0.25
		lam = .75
		h = .7
		ombhh = .044*0.7*.7	
		nindex = .949

	f = open(dir+file+'.dat').readlines()
	if pw == 'y':
		fo = open('P02'+file+'beta'+str(beta)+'sigs'+str(sfog)+'sigxy'+str(sigt)+'sigz'+str(sigr)+'Sk'+str(sigs)+'.dat','w')
		fo.write('# k P0 P2 P4 Psmooth\n')
	if file != 'Pk_MICEcosmology_z0_Plin_Pnowig':
		s = simulate(omega=om,lamda=lam,h=h,nindex=nindex,ombhh=ombhh)
	else:
		mult = 8.*pi**3.	
	pl2 = []
	pl4 = []
	beta0 = 0.4
	for i in range(0,100):
		pl2.append(P2(i/100.+.005))
	for i in range(0,100):
		pl4.append(P4(i/100.+.005))
	mul = []
	anipolyl = []
	for i in range(0,100):
		mu = i/100.+.005
		mul.append(mu)		
		anipoly = (1.+beta*mu**2.)**2.
		anipoly2 = (1.+beta*mu**2.)**2.*pl2[i]
		anipoly4 = (1.+beta*mu**2.)**2.*pl4[i]
		anipolyl.append((anipoly,anipoly2,anipoly4))
	k0 = float(f[0].split()[0])
	k1 = float(f[1].split()[0])
	ldk = log(k1)-log(k0)
	#print ldk
	xi0 = 0
	xi2 = 0
	xi4 = 0
	xism0 = 0
	xism2 = 0
	xism4 = 0
	#print max
	dmk = r/10.
	k = float(f[0].split()[0])
	if file == 'camb_Nacc' or file == 'Pk_MICEcosmology_z0_Plin_Pnowig':
		norm = 1.
	else:
		norm = float(f[0].split()[1])/s.Psmooth(k,0)*mult
	#print norm
	b = 2.
	ff =beta*b
	if sigz != 0:
		z = .8
		d = distance(.25,.75)
		sigzc = d.cHz(z)*sigz
	for i in range(0,len(f)-1):
		k = float(f[i].split()[0])
		pk = float(f[i].split()[1])*mult
		pk0 = 0
		pk2 = 0
		pk4 = 0
		pksm0 = 0
		pksm2 = 0
		pksm4 = 0
		if file == 'Pk_MICEcosmology_z0_Plin_Pnowig':
			pksm = float(f[i].split()[2])*mult
		else:	
			pksm = s.Psmooth(k,0)*norm
		dpk = pk-pksm
		for m in range(0,100):
			#mu = (1.-mul[m])			
			mu = mul[m]

			if mun == 'n':
				mu = (1.-mul[m])
			if sfog > 0:
				F = 1./(1.+k**2.*mu**2.*sfog**2./2.)**2.
			else:
				F = (1.+k**2.*sfog**2./2.)**2./(1.+k**2.*(1.-mu)**2.*sfog**2./2.)**2.
			if mun == 'b':
				mus2 = mu**2.
				F = (1.+beta*mus2*(1.-exp(-0.5*(k*sigs)**2.)))**2.*1./(1.+k**2.*mu**2.*(sfog)**2./2.)**2.
			#C *doesn't include damping*
			S = mun*exp(-0.5*(k*sigs)**2.)
			C = (1.+beta*mu*mu*(1.-S))*1./(1.+k**2.*mu**2.*(sfog)**2./2.)
			sigv2 = (1-mu**2.)*sigt**2./4.+mu**2.*sigr**2./4.
			damp = exp(-1.*k*k*sigv2)
			if sigz != 0:
				C = C*exp(-0.5*k*k*mu*mu*sigzc*sigzc)	
			#damp1 = exp(-0.25*k**2.*mu**2.*sigr**2.*(1.+ff)**2.)
			#damp2 = exp(-0.25*k**2.*(1.-mu**2.)*sigt**2.)
			#damp3 = 1./b*S*exp(-0.5*k**2.*sigt*sigr)
			#damp4 = (1.-exp(-0.25*k**2.*mu**2.*(2.*ff+ff**2.)*sigt*sigr))
			#damp = damp1*damp2+damp3*damp4 	
			
			anipoly = anipolyl[m]
			pk0 += C**2.*(dpk*damp**2.+pksm)
			pk2 += (dpk*damp**2.+pksm)*pl2[m]*C**2.
			pk4 += (dpk*damp**2.+pksm)*pl4[m]*C**2.
			pksm0 += pksm*C**2.
			pksm2 += pksm*pl2[m]*C**2.
			pksm4 += pksm*pl4[m]*C**2.
		pk0 = pk0/100.
		pk2 = 5.*pk2/100.
		pk4 = 9.*pk4/100.
		pksm0 = pksm0/100.
		pksm2 = 5.*pksm2/100.
		pksm4 = 9.*pksm4/100.
		if pw == 'y':
			fo.write(str(k)+' '+str(pk0)+' '+str(pk2)+' '+str(pk4)+' '+str(pksm0)+' '+str(pksm2)+' '+str(pksm4)+' '+str(pk)+' '+str(pksm)+'\n')
		dk = ldk*k
		xi0 += dk*k*k*pk0*sph_jn(0,k*r)*exp(-1.*dmk*k**2.)
		xi2 += dk*k*k*pk2*sph_jn(2,k*r)*exp(-1.*dmk*k**2.)
		xi4 += dk*k*k*pk4*sph_jn(4,k*r)*exp(-1.*dmk*k**2.)
		xism0 += dk*k*k*pksm0*sph_jn(0,k*r)*exp(-1.*dmk*k**2.)
		xism2 += dk*k*k*pksm2*sph_jn(2,k*r)*exp(-1.*dmk*k**2.)
		xism4 += dk*k*k*pksm4*sph_jn(4,k*r)*exp(-1.*dmk*k**2.)
	if pw == 'y':
		fo.close()
		from matplotlib import pyplot as plt
		from numpy import loadtxt as load
		d = load('P02'+file+'beta'+str(beta)+'sigs'+str(sfog)+'sigxy'+str(sigt)+'sigz'+str(sigr)+'Sk'+str(sigs)+'.dat').transpose()
		plt.xlim(0,.3)
		plt.plot(d[0],d[-2]/d[-1])
		plt.show()
	return xi0/(2.*pi*pi),-1.*xi2/(2.*pi*pi),xi4/(2.*pi*pi),xism0/(2.*pi*pi),-1.*xism2/(2.*pi*pi),xism4/(2.*pi*pi)
Пример #7
0
def mkxifile_zerrconv(z=0.8,sigz=0.029,sp=1.,bias=1.8,rmin=10.,rmax=300,rsd='',muww='muw',a='',v='y',gam=-1.7,file='MICE_matterpower',dir='',mun=0,beta=0.4,sfog=0,amc=0.0,sigt=6.,sigr=10.,mult=1.,sigs=15.,mumin=0,mumax=1):
	#Santi used zspec=0.45 to 1.2
	from random import gauss
	dir = '/Users/ashleyross/DR12/'
	if file == 'MICE_matterpower':
		dir = '/Users/ashleyross/DESY1/'
	f0 = loadtxt(dir+'xi0'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
	f2 = loadtxt(dir+'xi2'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
	f4 = loadtxt(dir+'xi4'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
	f0sm = loadtxt(dir+'xi0sm'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
	f2sm = loadtxt(dir+'xi2sm'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
	f4sm = loadtxt(dir+'xi4sm'+file+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigs)+str(mun)+'.dat').transpose()
	spf = 1.
	r = rmin
	from Cosmo import distance
	if file == 'Challenge_matterpower':
		d = distance(.31,.69)
	if file == 'MICE_matterpower':
		d = distance(.25,.75)
	ff = d.omz(z)**.557
	betad = ff/bias
	betaf = betad/beta	
	zmin = z-sigz*(1.+z)*5.*sqrt(2.)
	zmax = z+sigz*(1.+z)*5.*sqrt(2.)
	#zmin = z-.15
	#zmax = z+.2
	nz = 4000
	dz = (zmax-zmin)/float(nz)
	d0 = d.dc(z)
	dzl = []
	rzl = []
	wl = []
	for i in range(0,nz):
		zb = zmin + dz/2.+dz*i
		#print zb
		dzl.append(d.dc(zb)-d0)
		rzl.append(d.dc(zb)/d0)
		#rzl.append(1.)
		wl.append(1./(sqrt(2.)*sigz*(1.+z)*sqrt(2.*pi))*exp(-.5*((zb-z)/(sqrt(2.)*sigz*(1.+z)))**2.))
	print(sum(wl)*dz)
	sumw = sum(wl)
	#print wl
	#fmuw = loadtxt('/Users/ashleyross/DESY1/FdaHvsmu_z0.61.0_zerr0.03_10e3n2.6_b1.5.dat').transpose()
	fmuw = loadtxt('/Users/ashleyross/DESY1/FmuobsdaHvsmu_z0.61.0_zerr0.03_10e3n2.6_b1.5.dat').transpose()
	#muwt = sum(fmuw[1])
	muwt = 0
	#for i in range(0, len(fmuw[1])):
	#	if i > int(mumin*100) and i < int(mumax*100):
	for i in range(int(100*mumin),int(100*mumax)):	
		if muww == 'muw':
			muwt += fmuw[1][i]
		else:
			muwt += 1.
				
	muw = ''
	if mumin != 0:
		muw += 'mumin'+str(mumin)
	if mumax != 1:
		muw += 'mumax'+str(mumax)
	fo = open('xizconv'+muww+file+muw+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigz)+rsd+'sp'+str(sp)+'.dat','w')
	nzs = 10000
	while r < rmax:
		sumxi = 0
		sumxin = 0
		mmin = int(100*mumin)
		mmax = int(100*mumax)
		for m in range(mmin,mmax):
			mu = .005+0.01*m
			summ = 0
			summn = 0
			rt = sqrt(1.-mu**2.)*r
			rr = mu*r
			for i in range(0,nz):
				#dzt = gauss(0,sigz*(1.+z))-gauss(0,sigz*(1.+z))
				#indz = int((z+dzt-zmin)/dz)
				#if indz >= 0 and indz < nz: 
				rrp = rr + dzl[i]
				#if abs(rrp) < rr:
				#	print rrp,rr,r
				#rtp = rt*rzl[i]
				rtp = rt
				rp = sqrt(rrp**2.+rtp**2.)
				mup = abs(rrp/rp)
				if rp >= 10. and rp < 299:
					indd = int((rp-10.)/spf)
					indu = indd + 1
					fac = (rp-10.)/spf-indd
					if fac > 1 or fac < 0:
						print(fac,rp,spf,indd)
					xi0 = (f0[1][indu]*fac+(1.-fac)*f0[1][indd])*(1.+2/3.*betad+.2*betad**2.)/(1.+2/3.*beta+.2*beta**2.)
					xi2 = (f2[1][indu]*fac+(1.-fac)*f2[1][indd])*(4/3.*betad+4/7.*betad**2.)/(4/3.*beta+4/7.*beta**2.)
					xi4 = (f4[1][indu]*fac+(1.-fac)*f4[1][indd])*(betad/beta)**2.					
					xi0n = f0sm[1][indu]*fac+(1.-fac)*f0sm[1][indd]*(1.+2/3.*betad+.2*betad**2.)/(1.+2/3.*beta+.2*beta**2.)
					xi2n = (f2sm[1][indu]*fac+(1.-fac)*f2sm[1][indd])*(4/3.*betad+4/7.*betad**2.)/(4/3.*beta+4/7.*beta**2.)
					xi4n = (f4sm[1][indu]*fac+(1.-fac)*f4sm[1][indd])*(betad/beta)**2.					
				else:
					if rp < 10.:
						xi0,xi2,xi4 = wmod3(rp,mup,f0[1][0],10.,gam=gam)
						xi0n,xi2n,xi4n = wmod3(rp,mup,f0sm[1][0],10.,gam=gam)
						#xi2 = f2[1][0]
						#xi4 = f4[1][0]
						#xi2n = f2sm[1][0]
						#xi4n = f4sm[1][0]

					if rp >= 300:
						xi0 = f0[1][-1]*(1.+2/3.*betad+.2*betad**2.)/(1.+2/3.*beta+.2*beta**2.)
						xi2 = f2[1][-1]*(4/3.*betad+4/7.*betad**2.)/(4/3.*beta+4/7.*beta**2.)
						xi4 = f4[1][-1]*(betad/beta)**2.					
						xi0n = f0sm[1][-1]*(1.+2/3.*betad+.2*betad**2.)/(1.+2/3.*beta+.2*beta**2.)
						xi2n = f2sm[1][-1]*(4/3.*betad+4/7.*betad**2.)/(4/3.*beta+4/7.*beta**2.)
						xi4n = f4sm[1][-1]*(betad/beta)**2.					
					
						xi0,xi2,xi4 = 0,0,0	
						xi0n,xi2n,xi4n = 0,0,0
				if rsd == 'norsd':
					xi2,xi4,xi2n,xi4n = 0,0,0,0
				xip = xi0+P2(mup)*xi2+P4(mup)*xi4
				xipn = xi0n+P2(mup)*xi2n+P4(mup)*xi4n
				#if xip > 10:
				#	print xip,rp,indd,indu,f4[1][indu],f4[1][indd],P4(mup),mup
				summ += xip*wl[i]
				summn += xipn*wl[i]
			xi = summ/sumw#/float(nzs)#
			xin = summn/sumw#/float(nzs)#
			if muww == 'muw':
				sumxi += xi*fmuw[1][m]
				sumxin += xin*fmuw[1][m]
			else:
				sumxi += xi
				sumxin += xin
		sumxi = sumxi/muwt
		sumxin = sumxin/muwt		
		fo.write(str(r)+' '+str(sumxi)+' '+str(sumxin)+'\n')		
		print(r,sumxi,sumxin)
		r += sp	 
	fo.close()
# 	from matplotlib import pyplot as plt
# 	from numpy import loadtxt as load
# 	d = load('xizconvmuw'+file+muw+str(beta)+str(sfog)+str(sigt)+str(sigr)+str(sigz)+'sp'+str(sp)+'.dat').transpose()
# 	dd = load('xiavemuw'+muw+'SM.dat').transpose()
# 	plt.plot(d[0],d[0]**2.*d[1]*1.3,'k-',dd[0],dd[0]**2.*dd[1],'r-')
# 	plt.show()
# 	plt.plot(d[0]/.97,d[0]**2.*d[1]*1.3,'k-',dd[0],dd[0]**2.*dd[1],'r-')
# 	plt.show()		
	return True
Пример #8
0
from Cosmo import distance

d = distance(.25, .75)

print d.Dgn(0.65), d.Dgn(0.75), d.Dgn(0.85), d.Dgn(0.95)

## bias_bf is the bias parameter of the sample, for dark matter, you use bias_bf = 1
## w_full is the final w you want

import numpy as np

dir = '/home/nil/Dropbox/w_model_code/'

full_fname = dir + 'outbin_1.txt'
amean = 0.75
bias = 1.8
beta = 0.4

#f = Omegam_a( amean )**0.55
ff = d.omz(amean)**.557
betad = ff / bias
betaf = betad / beta

theta, w0, w2, w4 = np.loadtxt(full_fname, usecols=(0, 1, 2, 3), unpack=True)

b2_term = w0
bf_term = ff * (2 / 3. * w0 + 4 / 3. * w2)
f2_term = ff**2 * (1 / 5. * w0 + 4 / 7. * w2 + 8 / 35. * w4)

w_full = betaf**2 * b2_term + betaf * bf_term + f2_term
Пример #9
0
def xibaoSM(mn,c,rmin=50,rmax=200.,bs=5,md=1.,m=1.,mb='',v='n',p='',nbar=.002,fsky=.035,Bp=.4,mom='muw',nm='muwSA',covmd='s',N=63,mumin=0,mumax=1):
	from baofit_pubtest import doxi_isolike
	from Cosmo import distance
	d = distance(.31,.69)
	vol = fsky*4.*pi/3.*(d.dc(1.)**3.-d.dc(.6)**3.)
	muw = ''
	if mumin != 0:
		muw += 'mumin'+str(mumin)
	if mumax != 1.:
		muw += 'mumax'+str(mumax)	

	if nm == 'avemuwSM':
		dw = load('xiave'+mom+muw+'SM.dat').transpose()
	if nm == 'muwSA':	
		dw = load('ximuwSM/xi'+mom+muw+'SA'+str(mn)+'c'+c+'.dat').transpose()
	if nm == 'lampave':
		dw = load('xiSM'+nm+'mu'+str(mumin)+str(mumax)+str(bs)+'.dat').transpose()
	if nm == 'Y1':
		munm = ''
		if mumin != 0:
			munm += 'mum'+str(mumin)
		if mumax != 1:
			munm += 'mux'+str(mumax)
		dw = load('xi0gY1redBAO_mean_z_bpz_VFmz0.6xz1.0fcos'+munm+'5st0.dat').transpose()		
	dd = dw[1]
	rl = dw[0]
	mn = str(mn)
	if covmd == 'th':
		cov = load('covxiSM5.dat')
	if covmd == 's':
		cov = load('covxi'+mom+muw+'SM.dat')
	if covmd == 'lamp':
		cov = load('covSMlamp1.4.1'+'mu'+str(mumin)+str(mumax)+str(bs)+'.dat')	
	cov = cov*m	
	if md != 1:
		for i in range(0,len(cov)):
			cov[i][i] = cov[i][i]*md
	if p == 'dp':
		for i in range(0,len(cov)):
			np = nbar*vol*nbar*5.*4.*pi*rl[i]**2.
			cov[i][i] = cov[i][i]+2./np
				
	mdi = 1
	if mb == 'nobao':
		mdi = 2
	#mod = load('xizconv'+mom+'MICE_matterpower'+muw+'0.406.010.00.029sp1.0.dat').transpose()[mdi]
	mod = load('xizconvcMICE_matterpower'+muw+'0.4010.010.0combzsiglsp1.0.dat').transpose()[mdi]
	#mod = load('xizconvmuwPkMICE0.43.06.010.00.029sp1.0.dat').transpose()[mdi]
	Nmock = 8*N
	Nbin = (rmax-rmin)/5.
	chifac = (Nmock-Nbin-1)/(float(Nmock)-2.)
	chil = doxi_isolike(dd,cov,mod,rl,rmin=rmin,rmax=rmax,v=v,wo=mn+c+mb,Bp=Bp,chi2fac=chifac)
	fo = open('ximuwSM/BAOxichilSM'+nm+mn+c+mb+p+str(md)+str(m)+covmd+str(Bp)+muw+'.dat','w')
	for i in range(0,len(chil)):
		a = .8+.001*i+.0005
		fo.write(str(a)+' '+str(chil[i])+'\n')
	fo.close()
	from baofit import sigreg_c12
	a = sigreg_c12('ximuwSM/BAOxichilSM'+nm+mn+c+mb+p+str(md)+str(m)+covmd+str(Bp)+muw)
	#print a
	return a
Пример #10
0
'''
Add new results to BOSS DR12 BAO likelihood
'''
from math import *
import numpy as np
from Cosmo import distance  #this is other python in LSSanalysis
#directory with DR12 DM/HZ likelihood
dirDR12 = '/Users/ashleyross/Downloads/ALAM_ET_AL_2016_consensus_and_individual_Gaussian_constraints/COMBINEDDR12_BAO_consensus_dM_Hz/'

zl = [0.38, 0.38, 0.51, 0.51, 0.61, 0.61]
ml = [1512.39, 81.2087, 1975.22, 90.9029, 2306.68, 98.9647]
covt = np.loadtxt(dirDR12 + 'BAO_consensus_covtot_dM_Hz.txt')
d = distance(.31, .69, h=0.676)


def testcosmo(alphat, alphar, z):
    '''
	The purpose of this is to confirm that Cosmo.py reproduces the alpha_perp/|| -> DM/H conversion
	alphat is the transverse alpha (alpha_perp), alphar is the radial alpha (alpha_||) 
	'''

    print(d.dc(z) * alphat)
    print(d.Hz(z) / alphar * 100.)
    '''
	comparison with file with ROSS in name and Ross et al. 2017 gives matches all to within 0.05%; should be good enough
	'''


#def converttoalph():
fidl = np.zeros(len(ml))
mtl = np.array(ml)