Correlation function and BAO peaks of DR72 SDSS VAGC Catalog

First import all the modules such as healpy and astropy needed for analyzing the structure


In [1]:
import healpix_util as hu
import astropy as ap
import numpy as np
from astropy.io import fits
from astropy.table import Table
import astropy.io.ascii as ascii
from astropy.io import fits
from astropy.constants import c
import matplotlib.pyplot as plt
import math as m
from math import pi
#from scipy.constants import c
import scipy.special as sp
from astroML.decorators import pickle_results
from scipy import integrate
import warnings
from sklearn.neighbors import BallTree
import pickle
import multiprocessing as mp
import time
#from lccmetric import *
from progressbar import *
from tqdm import *
from functools import partial
import pymangle
from scipy.optimize import curve_fit
#from astroML.datasets import fetch_sdss_specgals
#from astroML.correlation import bootstrap_two_point_angular
%matplotlib inline

In [2]:
Ez = lambda x: 1/m.sqrt(0.3*(1+x)**3+0.7)

np.vectorize(Ez)
#Calculate comoving distance of a data point using the Redshift - This definition is based on the cosmology model we take. Here the distance for E-dS universe is considered. Also note that c/H0 ratio is cancelled in the equations and hence not taken.

def DC_LCDM(z):
    return integrate.quad(Ez, 0, z)[0]
DC_LCDM=np.vectorize(DC_LCDM)

In [3]:
def DC_LC(z):
    return np.log(1.0+z)

In [4]:
DC_LCDM(np.arange(0,1.0,0.1))


Out[4]:
array([ 0.        ,  0.09770697,  0.19070068,  0.27888554,  0.36227807,
        0.44098433,  0.5151762 ,  0.58506966,  0.65090662,  0.71294076])

In [5]:
DC_LC(np.arange(0,1.0,0.1))


Out[5]:
array([ 0.        ,  0.09531018,  0.18232156,  0.26236426,  0.33647224,
        0.40546511,  0.47000363,  0.53062825,  0.58778666,  0.64185389])

In [ ]:
def flatdistLCDM (z1, z2, theta):
    s1=DC_LCDM(z1)
    s2=DC_LCDM(z2)
    return np.sqrt(s1**2+s2**2-2.0*s1*s2*np.cos(theta/180.0*pi))

In [ ]:
flatdistLCDM(0,np.arange(0,1.0,0.1),0)

In [ ]:
def flatdistLC (z1, z2, theta):
    s1=DC_LC(z1)
    s2=DC_LC(z2)
    return np.sqrt(s1**2+s2**2-2.0*s1*s2*np.cos(theta*pi/180.0))

In [ ]:
flatdistLC(0,np.arange(0,1.0,0.1),0)

In [6]:
def flatdist(z1,z2,theta,func):
    s1=func(z1)
    s2=func(z2)
    return np.sqrt(s1**2+s2**2-2.0*s1*s2*np.cos(theta*pi/180.0))

In [10]:
def flatdist1(z1,z2,func):
    s1=func(z1)
    s2=func(z2)
    return np.sqrt(s1**2+s2**2-2.0*s1*s2*0.0)

In [7]:
def flatdist2(z1,z2,func):
    s1=func(z1)
    s2=func(z2)
    return np.sqrt(s1**2+s2**2-2.0*s1*s2*0.5)

In [8]:
zt=np.arange(0,1.0,0.1)

In [12]:
flatdist1(0,zt,DC_LCDM)


Out[12]:
array([ 0.        ,  0.09770697,  0.19070068,  0.27888554,  0.36227807,
        0.44098433,  0.5151762 ,  0.58506966,  0.65090662,  0.71294076])

In [13]:
flatdist2(0,zt,DC_LCDM)


Out[13]:
array([ 0.        ,  0.09770697,  0.19070068,  0.27888554,  0.36227807,
        0.44098433,  0.5151762 ,  0.58506966,  0.65090662,  0.71294076])

In [14]:
flatdist1(0.5,zt,DC_LCDM)


Out[14]:
array([ 0.44098433,  0.45167891,  0.4804518 ,  0.52177038,  0.57071235,
        0.62364603,  0.67813988,  0.73264841,  0.786223  ,  0.83830287])

In [15]:
flatdist2(0.5,zt,DC_LCDM)


Out[15]:
array([ 0.44098433,  0.40115657,  0.38306386,  0.38634204,  0.40737407,
        0.44098433,  0.48237855,  0.52798403,  0.57541897,  0.62318216])

In [ ]:


In [27]:
def closeddist(z1,z2,theta,func):
        s1=np.sin(func(z1)*0.007)
        s2=np.sin(func(z2)*0.007)
        c1=np.cos(func(z1)*0.007)
        c2=np.cos(func(z2)*0.007)
        res= np.sqrt(s1*s1+s2*s2-2.0*s1*s2*c1*c2*np.cos(theta*pi/180.0)-s1*s1*s2*s2*np.sqrt(1.0+(np.cos(theta*pi/180.0))**2))
        return res/0.007

In [28]:
closeddist(0,zt,0,DC_LC)


Out[28]:
array([ 0.        ,  0.00995033,  0.01980263,  0.0295588 ,  0.03922071,
        0.04879016,  0.05826891,  0.06765865,  0.07696104,  0.08617769,
        0.09531017,  0.10436001,  0.11332867,  0.12221762,  0.13102824,
        0.13976192,  0.14841998,  0.15700372,  0.1655144 ,  0.17395326,
        0.18232151,  0.1906203 ,  0.19885079,  0.2070141 ,  0.2151113 ,
        0.22314346,  0.23111162,  0.23901679,  0.24685996,  0.25464208,
        0.26236412,  0.27002698,  0.27763156,  0.28517875,  0.29266941,
        0.30010437,  0.30748446,  0.31481049,  0.32208323,  0.32930346,
        0.33647193,  0.34358937,  0.35065652,  0.35767407,  0.36464272,
        0.37156314,  0.37843599,  0.38526193,  0.3920416 ,  0.3987756 ,
        0.40546456,  0.41210908,  0.41870974,  0.42526711,  0.43178176,
        0.43825424,  0.4446851 ,  0.45107487,  0.45742407,  0.4637332 ,
        0.47000278,  0.4762333 ,  0.48242523,  0.48857906,  0.49469525,
        0.50077426,  0.50681654,  0.51282253,  0.51879265,  0.52472735,
        0.53062703,  0.53649211,  0.54232299,  0.54812006,  0.55388373,
        0.55961436,  0.56531233,  0.57097803,  0.5766118 ,  0.58221401,
        0.58778501,  0.59332514,  0.59883475,  0.60431416,  0.60976372,
        0.61518374,  0.62057454,  0.62593643,  0.63126972,  0.63657472,
        0.64185173,  0.64710103,  0.65232292,  0.65751768,  0.6626856 ,
        0.66782694,  0.67294198,  0.678031  ,  0.68309424,  0.68813198])

In [29]:
def opendist(z1,z2,theta,func):
        s1=np.sinh(func(z1)*0.007)
        s2=np.sinh(func(z2)*0.007)
        c1=np.cosh(func(z1)*0.007)
        c2=np.cosh(func(z2)*0.007)
        res= np.sqrt(s1*s1+s2*s2-2.0*s1*s2*c1*c2*np.cos(theta*pi/180.0)-s1*s1*s2*s2*np.sqrt(1.0+(np.cos(theta*pi/180.0))**2))
        return res/0.007

In [ ]:
flatdist(z1,zt,theta[0],DC_LCDM)

In [ ]:
np.cos

In [ ]:
flatdist(z1,zt,theta[6],DC_LCDM)

In [ ]:
flatdist(z1,zt,theta[6],DC_LC)

In [ ]:


In [ ]:


In [ ]:


In [16]:
z1=0.0
zt=np.arange(0,1.0,0.01)
theta=np.arange(0,190.0,10.0)

In [17]:
plt.plot(zt,flatdist(z1,zt,theta[0],DC_LCDM))
plt.plot(zt,flatdist(z1,zt,theta[6],DC_LCDM))
plt.plot(zt,flatdist(z1,zt,theta[12],DC_LCDM))
plt.plot(zt,flatdist(z1,zt,theta[18],DC_LCDM))
plt.show()



In [18]:
plt.plot(zt,flatdist(z1,zt,theta[0],DC_LC))
plt.plot(zt,flatdist(z1,zt,theta[6],DC_LC))
plt.plot(zt,flatdist(z1,zt,theta[12],DC_LC))
plt.plot(zt,flatdist(z1,zt,theta[18],DC_LC))
plt.show()



In [31]:
plt.plot(zt,flatdist(z1,zt,theta[0],DC_LCDM),'r')
plt.plot(zt,flatdist(z1,zt,theta[0],DC_LC),'g')
plt.plot(zt,closeddist(z1,zt,theta[0],DC_LC),'b')
plt.plot(zt,opendist(z1,zt,theta[0],DC_LC),'y')
plt.show()



In [20]:
plt.plot(zt,flatdist(0.5,zt,theta[0],DC_LCDM))
plt.plot(zt,flatdist(0.5,zt,theta[6],DC_LCDM))
plt.plot(zt,flatdist(0.5,zt,theta[12],DC_LCDM))
plt.plot(zt,flatdist(0.5,zt,theta[18],DC_LCDM))
plt.show()



In [21]:
plt.plot(zt,flatdist(0.5,zt,theta[0],DC_LC))
plt.plot(zt,flatdist(0.5,zt,theta[6],DC_LC))
plt.plot(zt,flatdist(0.5,zt,theta[12],DC_LC))
plt.plot(zt,flatdist(0.5,zt,theta[18],DC_LC))
plt.show()



In [36]:
plt.plot(zt,flatdist(0.5,zt,theta[6],DC_LCDM),'r')
plt.plot(zt,flatdist(0.5,zt,theta[6],DC_LC),'g')
plt.plot(zt,closeddist(0.5,zt,theta[6],DC_LC),'b')
plt.plot(zt,opendist(0.5,zt,theta[6],DC_LC),'y')
plt.show()



In [24]:
plt.plot(zt,flatdist(1.0,zt,theta[0],DC_LC))
plt.plot(zt,flatdist(1.0,zt,theta[6],DC_LC))
plt.plot(zt,flatdist(1.0,zt,theta[12],DC_LC))
plt.plot(zt,flatdist(1.0,zt,theta[18],DC_LC))
plt.show()



In [25]:
plt.plot(zt,flatdist(1.0,zt,theta[0],DC_LCDM))
plt.plot(zt,flatdist(1.0,zt,theta[6],DC_LCDM))
plt.plot(zt,flatdist(1.0,zt,theta[12],DC_LCDM))
plt.plot(zt,flatdist(1.0,zt,theta[18],DC_LCDM))
plt.show()



In [39]:
plt.plot(zt,flatdist(1.0,zt,theta[6],DC_LCDM),'r')
plt.plot(zt,flatdist(1.0,zt,theta[6],DC_LC),'g')
plt.plot(zt,closeddist(1.0,zt,theta[6],DC_LC),'b')
plt.plot(zt,opendist(1.0,zt,theta[6],DC_LC),'y')
plt.show()



In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:
flatdist(z1,zt,30.0,DC_LC)

In [ ]:
flatdist(z1,zt,0.0,DC_LC)

In [ ]:


In [ ]:


In [ ]:


In [ ]:
bins=np.arange(0.,0.08,0.005)

In [ ]:
print bins

In [ ]:
binMpc=c*1e-5*bins[1:len(bins)]

In [ ]:
print binMpc

In [ ]:
DDf=np.array([  376599,  1245978,  2826185,  5151737,  8156128, 11846922,
       16171658, 20996832, 26338279, 32090647, 38244493, 44703147,
       51450171, 58468581, 65667922])

In [ ]:
RRf=np.array([   643435,   4041756,  10512085,  19769200,  31628364,  45946557,
        62534839,  81156182, 101645162, 123804352, 147416610, 172291247,
       198247385, 225034691, 252578087])

In [ ]:
DRf=np.array([   295060,   1994482,   5218449,   9842717,  15798756,  23014872,
        31354659,  40802390,  51199047,  62501581,  74502664,  87208020,
       100471995, 114144670, 128180280])

In [ ]:
correlf=(4.0 * DDf - 4.0 * DRf + RRf) / RRf

In [ ]:
correlf

In [ ]:
DDc=np.array([  430556,  1114599,  2525859,  4682258,  7580242, 11210594,
       15494184, 20333206, 25595524, 31256250, 37268677, 43632001,
       50352286, 57359810, 64622022])

In [ ]:
RRc=np.array([   740302,   3503169,   9364047,  18228452,  29683412,  43369250,
        59250681,  77493322,  98000981, 120263531, 143859910, 167930727,
       192506956, 218264153, 245484297])

In [ ]:
DRc=np.array([   254634,   1719873,   4644253,   9066109,  14768425,  21645680,
        29640929,  38908451,  49347999,  60683031,  72811227,  85150370,
        97809112, 111106279, 125306147])

In [ ]:
correlc=(4.0 * DDc - 4.0 * DRc + RRc) / RRc

In [ ]:
correlc

In [ ]:
DDo=np.array([  331281,  1116305,  2527931,  4684655,  7583290, 11213608,
       15496093, 20336243, 25596801, 31258220, 37270412, 43632843,
       50353792, 57360863, 64623361])

In [ ]:
RRo=np.array([   547656,   3511813,   9374865,  18238861,  29691691,  43377917,
        59259542,  77500037,  98013097, 120268860, 143866480, 167933473,
       192509954, 218269183, 245488607])

In [ ]:
DRo=np.array([   259445,   1724093,   4650120,   9071135,  14773645,  21649996,
        29645220,  38913722,  49352896,  60686351,  72814042,  85152932,
        97810839, 111107554, 125309680])

In [ ]:
correlo=(4.0 * DDo - 4.0 * DRo + RRo) / RRo

In [ ]:
correlo

In [ ]:
DDs=np.array([  328694,  1029545,  2291282,  4147862,  6554042,  9497129,
       12989300, 16908377, 21224962, 25940421, 30956138, 36318577,
       41861964, 47699516, 53698417])

In [ ]:
RRs=np.array([   524864,   3256023,   8479597,  15957280,  25557294,  37154783,
        50626355,  65797017,  82516733, 100664495, 120087370, 140636145,
       162143809, 184495136, 207523156])

In [ ]:
DRs=np.array([   236152,   1599524,   4188580,   7905907,  12705700,  18520232,
        25272714,  32915799,  41374438,  50587003,  60461246,  70878589,
        81876261,  93286095, 105014199])

In [ ]:
correls=(4.0 * DDs - 4.0 * DRs + RRs) / RRs

In [ ]:
correls

In [ ]:
corthl=(binMpc/10.0)**(-1.8)
print corthl

In [ ]:
def powlaw(x, a, b):
    return (x/a)**b

In [ ]:
popt, pcov = curve_fit(powlaw, binMpc[0:5], correls[0:5])

In [ ]:
popt

In [ ]:
pcov

In [ ]:


In [ ]:


In [ ]:
plt.figure()
plt.xlabel('Comoving Distance ($s$) in $h^{-1}$ Mpc')
plt.ylabel('$\\xi (s)$')
plt.title('Comparison of Correlation functions ($\\xi (s)$)')
#plt.plot(binMpc,corthl,'m.--',label='Linear')
plt.plot(binMpc, powlaw(binMpc,*popt),'m.--',label='Linear')
plt.plot(binMpc,correls,'ko-',label='$\Lambda$ CDM')
plt.plot(binMpc,correlo,'r^-',label='Milne LC')
plt.plot(binMpc,correlc,'gs-',label='Closed LC')
plt.plot(binMpc,correlf,'bd-',label='Flat LC')
plt.legend()
plt.savefig("correlcomp.pdf")
plt.show()

In [ ]:
plt.figure()
plt.xlabel('Comoving Distance ($s$) in $h^{-1}$ Mpc')
plt.ylabel('$\\xi (s)$')
plt.title('Comparison of Correlation functions ($\\xi (s)$)')
plt.yscale('log')
#plt.plot(binMpc,corthl,'m.--',label='Linear')
#plt.plot(binMpc, powlaw(binMpc,*popt),'m.--',label='Linear')
plt.plot(binMpc,correls,'ko-',label='$\Lambda$ CDM')
#plt.plot(binMpc,correlo,'r^-',label='Milne LC')
plt.plot(binMpc,correlc,'gs-',label='Closed LC')
plt.plot(binMpc,correlf,'bd-',label='Flat LC')
plt.legend()
#plt.savefig("correlcompylog.pdf")
plt.show()

In [ ]:
plt.figure()
plt.xlabel('Comoving Distance ($s$) in $h^{-1}$ Mpc')
plt.ylabel('$\\xi (s)$')
plt.title('Comparison of Correlation functions ($\\xi (s)$)')
plt.yscale('log')
plt.xscale('log')
#plt.plot(binMpc,corthl,'m.--',label='Linear')
plt.plot(binMpc, powlaw(binMpc,*popt),'m.--',label='Linear')
plt.plot(binMpc,correls,'ko-',label='$\Lambda$ CDM')
plt.plot(binMpc,correlo,'r^-',label='Milne LC')
plt.plot(binMpc,correlc,'gs-',label='Closed LC')
plt.plot(binMpc,correlf,'bd-',label='Flat LC')
plt.legend()
plt.savefig("correlcompxylog.pdf")
plt.show()

In [ ]: