Correlation function 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 aptestmetricdt import *
from aptestmetricdz import *
from scipy.spatial import distance as d
from apcat 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

Read the data file (taken from http://cosmo.nyu.edu/~eak306/SDSS-LRG.html ) converted to ascii with comoving distance etc. in V01 reading from pkl files for faster read


In [2]:
with open('dd2ddr72v06cdist.pkl') as f:
    dd2d=pickle.load(f)

In [3]:
with open('rr2ddr72v06cdist.pkl') as f:
    rr2d=pickle.load(f)

In [4]:
with open('dr2ddr72v06cdist.pkl') as f:
    dr2d=pickle.load(f)

In [5]:
corrells=(dd2d+rr2d-2.0*dr2d)/rr2d

In [6]:
corrells


Out[6]:
array([[ 2.08273679, -0.06591932, -1.14525488, -1.49923222, -1.74361248,
        -1.81418446, -1.90115591, -1.94329043, -1.93130228, -1.96064259],
       [ 0.20180514, -0.94522815, -1.34635828, -1.58844515, -1.7528935 ,
        -1.84438752, -1.86257547, -1.9439332 , -1.99009407, -1.94829146],
       [-1.09749238, -1.48234452, -1.64234357, -1.75344742, -1.83019763,
        -1.88547473, -1.92958533, -1.940775  , -1.95535063, -1.9629588 ],
       [-1.62892483, -1.70176401, -1.76263555, -1.84966414, -1.87139241,
        -1.91879916, -1.90796703, -1.96632612, -1.95794984, -1.94585536],
       [-1.71551518, -1.91806287, -1.86999609, -1.90800839, -1.92515012,
        -1.93386969, -1.96487487, -1.95405297, -1.97032435, -1.96087146],
       [-1.81904322, -1.94790171, -2.        , -1.96932249, -1.91842475,
        -1.98101775, -1.98521938, -1.97618539, -1.95892852, -2.01410874],
       [-1.8138236 , -1.90877811, -1.93966404, -1.98406259, -1.95253807,
        -1.95867436, -1.96679456, -2.01126218, -1.99885932, -1.99369292],
       [-1.9927308 , -1.97658099, -1.91586737, -1.96813381, -1.98416011,
        -1.98639893, -1.99997964, -1.99746813, -1.98126505, -1.97767361],
       [-1.96406473, -1.92609437, -1.99171257, -1.94687523, -1.9823819 ,
        -1.97786533, -2.02323228, -1.98559114, -1.99172681, -2.00881064],
       [-1.92470024, -1.99537152, -1.99419303, -1.97261023, -1.9673841 ,
        -1.98801505, -2.02412735, -2.01394008, -2.01956817, -2.04963448]])

In [7]:
plt.contour(corrells)


Out[7]:
<matplotlib.contour.QuadContourSet at 0x11535f4d0>

In [8]:
dzbin=zdthbin=np.arange(0.002,0.022,0.002)

In [9]:
plt.contour(dzbin,zdthbin,corrells)


Out[9]:
<matplotlib.contour.QuadContourSet at 0x115401e10>

In [10]:
ztotal = np.concatenate([np.fliplr(corrells),corrells],axis=1)
ztotal = np.concatenate([np.flipud(ztotal),ztotal],axis=0)
xtotal = np.concatenate([-dzbin[::-1],zdthbin],axis=0)
ytotal = np.concatenate([-zdthbin[::-1],zdthbin],axis=0)

plt.figure()
plt.contour(xtotal,ytotal,ztotal)
#plt.savefig("../plots/anisotropic2pcfdzzdth.pdf")
plt.show()



In [11]:
def musq(y,dz,zdth):
    return 1.0/(1.0+y**2*(dz/zdth[:,None])**2)

In [12]:
def f(y,dz,zdth,beta,gamma):
    musqv=musq(y,dz,zdth)
    return 1.0+2.0*(1.0-gamma*musqv)/(3-gamma)*beta+(3.0-6.0*gamma*musqv+gamma*(2.0+gamma)*musqv**2)*beta**2/((3.0-gamma)*(5.0-gamma))

In [13]:
def xi(dzzdth,Kz,y,beta,gamma):
    dz=dzzdth
    zdth=dzzdth
    musqv=musq(y,dz,zdth)
    fv=f(y,dz,zdth,beta,gamma)
    ans=Kz*musqv**(gamma/2.0)*fv/(dz)**gamma
    return ans.ravel()

In [14]:
def xibetaf(dzzdth,Kz,y,gamma):
    beta=1.0
    return xi(dzzdth,Kz,y,beta,gamma)

In [17]:
ans=curve_fit(xibetaf,dzbin,corrells.ravel())


/Users/rohin/anaconda/lib/python2.7/site-packages/scipy/optimize/minpack.py:715: OptimizeWarning: Covariance of the parameters could not be estimated
  category=OptimizeWarning)

In [18]:
ans


Out[18]:
(array([ -2.18821015e+00,  -4.09555399e-06,  -1.86888735e-01]),
 array([[ inf,  inf,  inf],
        [ inf,  inf,  inf],
        [ inf,  inf,  inf]]))

In [19]:
sol=ans[0]

In [22]:
def xi2d(dzzdth,Kz,y,beta,gamma):
    dz=dzzdth
    zdth=dzzdth
    musqv=musq(y,dz,zdth)
    fv=f(y,dz,zdth,beta,gamma)
    ans=Kz*musqv**(gamma/2.0)*fv/(dz)**gamma
    return ans
def xibetaf2d(dzzdth,Kz,y,gamma):
    beta=1.0
    return xi2d(dzzdth,Kz,y,beta,gamma)

In [23]:
plt.contour(xibetaf2d(dzbin,*sol))


Out[23]:
<matplotlib.contour.QuadContourSet at 0x1156344d0>

In [24]:
plt.contour(corrells)


Out[24]:
<matplotlib.contour.QuadContourSet at 0x115c5d810>

In [38]:
correlshr4=correlshr[0:4,0:4]

In [44]:
ans=curve_fit(xibetaf,dzbin[0:4],correlshr4.ravel())

In [45]:
ans


Out[45]:
(array([ -4.06968573e+02,  -3.50070469e-04,  -1.20602269e+00]),
 array([[  1.67403380e+07,  -4.15679477e+06,   8.19183149e+03],
        [ -4.15679477e+06,   4.89494847e+06,  -1.83765822e+03],
        [  8.19183149e+03,  -1.83765822e+03,   4.02991815e+00]]))

In [ ]:


In [ ]:


In [39]:
dzbin[0:4]


Out[39]:
array([ 0.002,  0.004,  0.006,  0.008])