Correlation function of DR12Q SDSS Catalog bins

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


In [80]:
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
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 pymangle
import cython_metric
import lcdmmetric
import pyfits
#from astroML.datasets import fetch_sdss_specgals
#from astroML.correlation import bootstrap_two_point_angular
%matplotlib inline

In [81]:
fdat=ascii.read("./output/DR12Qbin1.dat")

In [82]:
fdat


Out[82]:
<Table length=48309>
zrardecr
float64float64float64
1.3603589.3e-05-0.035487
1.1345440.0006820.243272
0.8353250.000758-0.142169
0.7527290.000782-0.099872
0.8962210.000918-0.082249
0.8820330.0011990.042834
0.7022840.0012990.240805
1.3016110.0014250.021841
0.7042290.0015390.236405
0.8402210.0016910.339623
.........
0.7612276.2819470.510654
0.8648656.282053-0.055125
0.8549216.2820820.454166
0.7522176.2825730.223546
0.8130336.282579-0.087908
1.1720966.282584-0.027623
0.9793256.2826650.288813
0.7865096.2827440.260439
0.8358736.282770.15974
1.1972536.2830720.369546

In [83]:
z=fdat['z']
ra=fdat['rar']
dec=fdat['decr']

In [84]:
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 [85]:
dr12qbin1 = open("./output/dr12qbin1srarf.dat",'w')
dr12qbin1.write("z\t rar\t decr\t s\n")

for i in range(0,len(z)):
    dr12qbin1.write("%f\t " %z[i])
    dr12qbin1.write("%f\t %f\t " %(ra[i],dec[i]))
    dr12qbin1.write("%f\n " %DC_LCDM(z[i]))
dr12qbin1.close()

In [86]:
dr12qbin1dat=ascii.read("./output/dr12qbin1srarf.dat")

In [87]:
NSIDE=512
dr12qbin1pix=hu.HealPix("ring",NSIDE)

In [88]:
pixdata = open("./output/pixdatadr12qbin1.dat",'w')
pixdata.write("z\t pix \n")

for i in range(0,len(dr12qbin1dat)):
    pixdata.write("%f\t" %dr12qbin1dat['z'][i])
    pixdata.write("%d\n" %dr12qbin1pix.eq2pix(dr12qbin1dat['rar'][i]*180.0/pi,dr12qbin1dat['decr'][i]*180.0/pi))
pixdata.close()

In [89]:
pixdata = ascii.read("./output/pixdatadr12qbin1.dat")
hpixdata=np.array(np.zeros(hu.nside2npix(NSIDE)))
for j in range(len(pixdata)):
    hpixdata[pixdata[j]['pix']]+=1

In [90]:
hpixdata


Out[90]:
array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

In [91]:
hu.mollview(hpixdata,rot=180)
plt.savefig("./plots/dr12qbin1moll.pdf")



In [92]:
hu.orthview(hpixdata)
plt.savefig("./plots/dr12qbin1orth.pdf")



In [93]:
fdat=ascii.read("./output/DR12Qbin2.dat")

In [94]:
fdat


Out[94]:
<Table length=42650>
zrardecr
float64float64float64
1.6188467.1e-050.084296
1.5761340.0001490.605257
1.7101030.0001570.266244
1.8335630.0002390.19133
2.0014120.0003730.150584
2.08920.000401-0.096075
1.6405170.00042-0.075666
2.0046530.0004880.529287
1.5456140.0005130.105756
1.6154990.000626-0.178954
.........
1.8698096.2821730.574029
1.6051746.2821740.534793
2.0787326.2822160.587197
1.8524526.2823930.301937
1.7003086.2824340.289916
1.7628586.2824880.189745
1.6399776.2825480.424658
1.6219096.282646-0.073565
1.5694096.282703-0.077083
1.8492216.282820.033848

In [95]:
z=fdat['z']
ra=fdat['rar']
dec=fdat['decr']

In [96]:
dr12qbin2 = open("./output/dr12qbin2srarf.dat",'w')
dr12qbin2.write("z\t rar\t decr\t s\n")

for i in range(0,len(z)):
    dr12qbin2.write("%f\t " %z[i])
    dr12qbin2.write("%f\t %f\t " %(ra[i],dec[i]))
    dr12qbin2.write("%f\n " %DC_LCDM(z[i]))
dr12qbin2.close()

In [97]:
dr12qbin2dat=ascii.read("./output/dr12qbin2srarf.dat")

In [98]:
NSIDE=512
dr12qbin2pix=hu.HealPix("ring",NSIDE)

In [99]:
pixdata = open("./output/pixdatadr12qbin2.dat",'w')
pixdata.write("z\t pix \n")

for i in range(0,len(dr12qbin2dat)):
    pixdata.write("%f\t" %dr12qbin2dat['z'][i])
    pixdata.write("%d\n" %dr12qbin2pix.eq2pix(dr12qbin2dat['rar'][i]*180.0/pi,dr12qbin2dat['decr'][i]*180.0/pi))
pixdata.close()

In [100]:
pixdata = ascii.read("./output/pixdatadr12qbin2.dat")
hpixdata=np.array(np.zeros(hu.nside2npix(NSIDE)))
for j in range(len(pixdata)):
    hpixdata[pixdata[j]['pix']]+=1

In [101]:
hpixdata


Out[101]:
array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

In [102]:
hu.mollview(hpixdata,rot=180)
plt.savefig("./plots/dr12qbin2moll.pdf")



In [103]:
hu.orthview(hpixdata)
plt.savefig("./plots/dr12qbin2orth.pdf")



In [ ]:


In [104]:
fdat=ascii.read("./output/DR12Qbin3.dat")

In [105]:
fdat


Out[105]:
<Table length=139641>
zrardecr
float64float64float64
2.3090973.3e-050.31021
2.4979414.8e-050.261357
2.3326550.0001-0.023126
2.3732990.0001190.532663
2.5423030.000128-0.130654
2.1645590.000141-0.004206
2.5434710.000160.204148
2.6510570.0001710.385902
2.3541480.0002310.021868
2.1647610.0002570.533554
.........
2.7595956.2830470.565462
2.7337736.2830680.087709
2.5520776.283114-0.147293
2.3983046.283120.049193
2.1813016.283140.519839
2.4391796.283143-0.171497
2.1877776.2831640.152742
2.4155086.2831660.176571
2.4510156.283170.505355
2.3976676.2831840.606452

In [106]:
z=fdat['z']
ra=fdat['rar']
dec=fdat['decr']

In [107]:
dr12qbin3 = open("./output/dr12qbin3srarf.dat",'w')
dr12qbin3.write("z\t rar\t decr\t s\n")

for i in range(0,len(z)):
    dr12qbin3.write("%f\t " %z[i])
    dr12qbin3.write("%f\t %f\t " %(ra[i],dec[i]))
    dr12qbin3.write("%f\n " %DC_LCDM(z[i]))
dr12qbin3.close()

In [108]:
dr12qbin3dat=ascii.read("./output/dr12qbin3srarf.dat")

In [109]:
NSIDE=512
dr12qbin3pix=hu.HealPix("ring",NSIDE)

In [110]:
pixdata = open("./output/pixdatadr12qbin3.dat",'w')
pixdata.write("z\t pix \n")

for i in range(0,len(dr12qbin3dat)):
    pixdata.write("%f\t" %dr12qbin3dat['z'][i])
    pixdata.write("%d\n" %dr12qbin3pix.eq2pix(dr12qbin3dat['rar'][i]*180.0/pi,dr12qbin3dat['decr'][i]*180.0/pi))
pixdata.close()

In [111]:
pixdata = ascii.read("./output/pixdatadr12qbin3.dat")
hpixdata=np.array(np.zeros(hu.nside2npix(NSIDE)))
for j in range(len(pixdata)):
    hpixdata[pixdata[j]['pix']]+=1

In [112]:
hpixdata


Out[112]:
array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

In [113]:
hu.mollview(hpixdata,rot=180)
plt.savefig("./plots/dr12qbin3moll.pdf")



In [114]:
hu.orthview(hpixdata)
plt.savefig("./plots/dr12qbin3orth.pdf")



In [115]:
fdat=ascii.read("./output/DR12Qbin4.dat")

In [116]:
fdat


Out[116]:
<Table length=42945>
zrardecr
float64float64float64
3.0888390.0001030.34928
2.9064480.0002520.280095
2.8793720.000361-0.004858
3.0090770.0003780.239244
3.1237950.0004280.594248
3.2503610.000465-0.120452
2.8281290.0005440.204236
3.0899680.0008970.398611
3.2786930.0009110.556924
3.228430.0010240.026139
.........
2.9745646.2820250.069631
3.1289226.2822210.212078
3.182616.2824880.390924
2.815916.282607-0.061368
2.9769776.2827510.199639
3.4212836.2828240.528812
3.1289516.282996-0.02931
3.1669116.2830330.624115
3.0647496.2830850.007521
3.1133916.2831730.605993

In [117]:
z=fdat['z']
ra=fdat['rar']
dec=fdat['decr']

In [118]:
dr12qbin4 = open("./output/dr12qbin4srarf.dat",'w')
dr12qbin4.write("z\t rar\t decr\t s\n")

for i in range(0,len(z)):
    dr12qbin4.write("%f\t " %z[i])
    dr12qbin4.write("%f\t %f\t " %(ra[i],dec[i]))
    dr12qbin4.write("%f\n " %DC_LCDM(z[i]))
dr12qbin4.close()

In [119]:
dr12qbin4dat=ascii.read("./output/dr12qbin4srarf.dat")

In [120]:
NSIDE=512
dr12qbin4pix=hu.HealPix("ring",NSIDE)

In [121]:
pixdata = open("./output/pixdatadr12qbin4.dat",'w')
pixdata.write("z\t pix \n")

for i in range(0,len(dr12qbin4dat)):
    pixdata.write("%f\t" %dr12qbin4dat['z'][i])
    pixdata.write("%d\n" %dr12qbin4pix.eq2pix(dr12qbin4dat['rar'][i]*180.0/pi,dr12qbin4dat['decr'][i]*180.0/pi))
pixdata.close()

In [122]:
pixdata = ascii.read("./output/pixdatadr12qbin4.dat")
hpixdata=np.array(np.zeros(hu.nside2npix(NSIDE)))
for j in range(len(pixdata)):
    hpixdata[pixdata[j]['pix']]+=1

In [123]:
hpixdata


Out[123]:
array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

In [124]:
hu.mollview(hpixdata,rot=180)
plt.savefig("./plots/dr12qbin4moll.pdf")



In [125]:
hu.orthview(hpixdata)
plt.savefig("./plots/dr12qbin4orth.pdf")



In [126]:
def DC_LC(z):
    return np.log(1+z)

In [127]:
dr12qbin1=ascii.read("./output/dr12qbin1srarf.dat")

In [128]:
z=dr12qbin1['z']
ra=dr12qbin1['rar']
dec=dr12qbin1['decr']

In [129]:
dr12qbin1 = open("./output/dr12qbin1srarfLC.dat",'w')
dr12qbin1.write("z\t rar\t decr\t s\n")

for i in range(0,len(z)):
    dr12qbin1.write("%f\t " %z[i])
    dr12qbin1.write("%f\t %f\t " %(ra[i],dec[i]))
    dr12qbin1.write("%f\n " %DC_LC(z[i]))
dr12qbin1.close()

In [130]:
dr12qbin2=ascii.read("./output/dr12qbin2srarf.dat")

In [131]:
z=dr12qbin2['z']
ra=dr12qbin2['rar']
dec=dr12qbin2['decr']

In [132]:
dr12qbin2 = open("./output/dr12qbin2srarfLC.dat",'w')
dr12qbin2.write("z\t rar\t decr\t s\n")

for i in range(0,len(z)):
    dr12qbin2.write("%f\t " %z[i])
    dr12qbin2.write("%f\t %f\t " %(ra[i],dec[i]))
    dr12qbin2.write("%f\n " %DC_LC(z[i]))
dr12qbin2.close()

In [133]:
dr12qbin3=ascii.read("./output/dr12qbin3srarf.dat")

In [134]:
z=dr12qbin3['z']
ra=dr12qbin3['rar']
dec=dr12qbin3['decr']

In [135]:
dr12qbin3 = open("./output/dr12qbin3srarfLC.dat",'w')
dr12qbin3.write("z\t rar\t decr\t s\n")

for i in range(0,len(z)):
    dr12qbin3.write("%f\t " %z[i])
    dr12qbin3.write("%f\t %f\t " %(ra[i],dec[i]))
    dr12qbin3.write("%f\n " %DC_LC(z[i]))
dr12qbin3.close()

In [136]:
dr12qbin4=ascii.read("./output/dr12qbin4srarf.dat")

In [137]:
z=dr12qbin4['z']
ra=dr12qbin4['rar']
dec=dr12qbin4['decr']

In [138]:
dr12qbin4 = open("./output/dr12qbin4srarfLC.dat",'w')
dr12qbin4.write("z\t rar\t decr\t s\n")

for i in range(0,len(z)):
    dr12qbin4.write("%f\t " %z[i])
    dr12qbin4.write("%f\t %f\t " %(ra[i],dec[i]))
    dr12qbin4.write("%f\n " %DC_LC(z[i]))
dr12qbin4.close()

In [ ]: