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 cython_metric import *
from lcdmmetric import *
from lcck0metric import *
from progressbar import *
from tqdm import *
from functools import partial
import pymangle
#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]:
data=ascii.read("./output/dr12gcmssrarfLC.dat")
In [3]:
data
Out[3]:
In [4]:
data.remove_column('z')
data.remove_column('ra')
data.remove_column('dec')
In [5]:
data
Out[5]:
In [6]:
rs=np.array(data['s'])
rrar=np.array(data['rar'])
rdecr=np.array(data['decr'])
In [7]:
dat=np.array([rs,rrar,rdecr])
In [8]:
dat
Out[8]:
In [9]:
dat.reshape(3,len(data))
Out[9]:
In [10]:
dat=dat.transpose()
In [11]:
dat
Out[11]:
In [12]:
# Saving the objects:
with open('dr12gcmsLC.pkl', 'w') as f: # Python 3: open(..., 'wb')
pickle.dump(dat, f)
In [2]:
# Getting back the objects:
with open('../pkl/dr12gcmsLC.pkl') as f: # Python 3: open(..., 'rb')
dat = pickle.load(f)
dat
Out[2]:
In [3]:
LCDMmetricsq(dat[0],dat[1])
Out[3]:
In [4]:
%%time
BT_D = BallTree(dat,metric='pyfunc',func=LCDMmetricsq)
with open('../pkl/BTDdr12gcmssLCf.pkl', 'w') as f:
pickle.dump(BT_D,f)
In [5]:
with open('../pkl/BTDdr12gcmssLCf.pkl') as f:
BTD = pickle.load(f)
BTD
Out[5]:
In [6]:
bins=np.arange(0.004,0.084,0.004)
bins
Out[6]:
In [7]:
binsq=bins**2
binsq
Out[7]:
In [8]:
%%time
start_time=time.time()
counts_DD=BTD.two_point_correlation(dat,binsq)
print counts_DD
end_time=time.time()
tottime=end_time-start_time
print "Total run time:"
print tottime
with open('../pkl/BTDdr12gcmssDDLCf.pkl', 'w') as f:
pickle.dump(counts_DD,f)
with open('../pkl/BTDdr12gcmssDDLCf.pkl') as f:
counts_DD = pickle.load(f)
counts_DD
In [9]:
counts_DD
Out[9]:
In [10]:
DD=np.diff(counts_DD)
In [11]:
DD
Out[11]:
In [12]:
plt.plot(bins[1:len(bins)],DD,'bo-')
Out[12]:
In [30]:
RR_zero = (RR == 0)
RR[RR_zero] = 1
In [ ]:
In [ ]:
In [ ]: