Correlation function of DR12G SDSS 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
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 [109]:
fdat=pyfits.open("./input/galaxy_DR12v5_CMASS_North.fits")

In [110]:
fdata=fdat[1].data

In [111]:
fdata['Z']


Out[111]:
array([ 0.54252994,  0.39968154,  0.53770244, ...,  0.44825909,
        0.47320512,  0.48506573], dtype=float32)

In [112]:
z=fdata['Z']
ra=fdata['RA']
dec=fdata['DEC']

In [113]:
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 [114]:
dr12gcmn = open("./output/dr12gcmnsrarf.dat",'w')
dr12gcmn.write("z\t ra\t dec\t s\t rar\t decr \n")

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

In [46]:
dr12gcmndat=ascii.read("./output/dr12gcmnsrarf.dat")

In [47]:
NSIDE=512
dr12gcmnpix=hu.HealPix("ring",NSIDE)

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

for i in range(0,len(dr12gcmndat)):
    pixdata.write("%f\t" %dr12gcmndat['z'][i])
    pixdata.write("%d\n" %dr12gcmnpix.eq2pix(dr12gcmndat['ra'][i],dr12gcmndat['dec'][i]))
pixdata.close()

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

In [50]:
hpixdata


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

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



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



In [53]:
fdat=pyfits.open("./input/galaxy_DR12v5_CMASS_South.fits")

In [54]:
fdata=fdat[1].data

In [55]:
fdata['Z']


Out[55]:
array([ 0.30140063,  0.45887196,  0.57938349, ...,  0.66893709,
        0.57584679,  0.54110092], dtype=float32)

In [56]:
z=fdata['Z']
ra=fdata['RA']
dec=fdata['DEC']

In [57]:
dr12gcms = open("./output/dr12gcmssrarf.dat",'w')
dr12gcms.write("z\t ra\t dec\t s\t rar\t decr \n")

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

In [58]:
dr12gcmsdat=ascii.read("./output/dr12gcmssrarf.dat")

In [59]:
NSIDE=512
dr12gcmspix=hu.HealPix("ring",NSIDE)

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

for i in range(0,len(dr12gcmsdat)):
    pixdata.write("%f\t" %dr12gcmsdat['z'][i])
    pixdata.write("%d\n" %dr12gcmspix.eq2pix(dr12gcmndat['ra'][i],dr12gcmsdat['dec'][i]))
pixdata.close()

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

In [62]:
hpixdata


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

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



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



In [65]:
len(z)


Out[65]:
230831

In [66]:
len(dr12gcmndat['z'])


Out[66]:
618806

In [67]:
np.mean(dr12gcmndat['z'])


Out[67]:
0.54591399110706751

In [68]:
fdat=pyfits.open("./input/galaxy_DR12v5_LOWZ_North.fits")

In [69]:
fdata=fdat[1].data

In [70]:
fdata['Z']


Out[70]:
array([ 0.34588838,  0.33261034,  0.33253074, ...,  0.26743358,
        0.15310054,  0.20853609], dtype=float32)

In [71]:
z=fdata['Z']
ra=fdata['RA']
dec=fdata['DEC']

In [72]:
dr12gln = open("./output/dr12glnsrarf.dat",'w')
dr12gln.write("z\t ra\t dec\t s\t rar\t decr \n")

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

In [73]:
dr12glndat=ascii.read("./output/dr12glnsrarf.dat")

In [74]:
NSIDE=512
dr12glnpix=hu.HealPix("ring",NSIDE)

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

for i in range(0,len(dr12glndat)):
    pixdata.write("%f\t" %dr12glndat['z'][i])
    pixdata.write("%d\n" %dr12glnpix.eq2pix(dr12glndat['ra'][i],dr12glndat['dec'][i]))
pixdata.close()

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

In [77]:
hpixdata


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

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



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



In [80]:
len(z)


Out[80]:
317780

In [81]:
fdat=pyfits.open("./input/galaxy_DR12v5_LOWZ_South.fits")

In [82]:
fdata=fdat[1].data

In [83]:
fdata['Z']


Out[83]:
array([ 0.41110829,  0.19472548,  0.28664541, ...,  0.54110092,
        0.21810117,  0.10835505], dtype=float32)

In [84]:
z=fdata['Z']
ra=fdata['RA']
dec=fdata['DEC']

In [85]:
dr12gls = open("./output/dr12glssrarf.dat",'w')
dr12gls.write("z\t ra\t dec\t s\t rar\t decr \n")

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

In [86]:
dr12glsdat=ascii.read("./output/dr12glssrarf.dat")

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

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

for i in range(0,len(dr12glsdat)):
    pixdata.write("%f\t" %dr12glsdat['z'][i])
    pixdata.write("%d\n" %dr12glspix.eq2pix(dr12glsdat['ra'][i],dr12glsdat['dec'][i]))
pixdata.close()

In [89]:
pixdata = ascii.read("./output/pixdatadr12gls.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/dr12glsmoll.pdf")



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



In [93]:
len(z)


Out[93]:
145264

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

In [96]:
dr12gcmn=ascii.read("./output/dr12gcmnsrarf.dat")

In [97]:
z=dr12gcmn['z']
ra=dr12gcmn['ra']
dec=dr12gcmn['dec']

In [98]:
dr12gcmn = open("./output/dr12gcmnsrarfLC.dat",'w')
dr12gcmn.write("z\t ra\t dec\t s\t rar\t decr \n")

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

In [99]:
dr12gcms=ascii.read("./output/dr12gcmssrarf.dat")

In [100]:
z=dr12gcms['z']
ra=dr12gcms['ra']
dec=dr12gcms['dec']

In [101]:
dr12gcms = open("./output/dr12gcmssrarfLC.dat",'w')
dr12gcms.write("z\t ra\t dec\t s\t rar\t decr \n")

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

In [102]:
dr12glndat=ascii.read("./output/dr12glnsrarf.dat")

In [104]:
z=dr12glndat['z']
ra=dr12glndat['ra']
dec=dr12glndat['dec']

In [105]:
dr12gln = open("./output/dr12glnsrarfLC.dat",'w')
dr12gln.write("z\t ra\t dec\t s\t rar\t decr \n")

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

In [106]:
dr12glsdat=ascii.read("./output/dr12glssrarf.dat")

In [107]:
z=dr12glsdat['z']
ra=dr12glsdat['ra']
dec=dr12glsdat['dec']

In [108]:
dr12gls = open("./output/dr12glssrarfLC.dat",'w')
dr12gls.write("z\t ra\t dec\t s\t rar\t decr \n")

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

In [ ]: