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 lco07metric 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
In [2]:
# Getting back the objects:
with open('datsLCf.pkl') as f: # Python 3: open(..., 'rb')
dat = pickle.load(f)
dat
Out[2]:
In [3]:
bins=np.arange(0.,0.08,0.005)
In [4]:
print bins
In [5]:
Nbins=len(bins)
In [6]:
Nbins
Out[6]:
In [7]:
binsq=(bins*0.007)**2
In [8]:
binsq
Out[8]:
In [10]:
LCometric07(dat[0],dat[1])
Out[10]:
In [11]:
%%time
BT_DLCo = BallTree(dat,metric='pyfunc',func=LCometric07,leaf_size=5)
with open('BTDdatsLCo07.pkl', 'w') as f:
pickle.dump(BT_DLCo,f)
In [12]:
with open('BTDdatsLCo07.pkl') as f:
BTDLCo = pickle.load(f)
BTDLCo
Out[12]:
In [13]:
%%time
start_time=time.time()
counts_DD=BTDLCo.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('BTDcDDLCo07.pkl', 'w') as f:
pickle.dump(counts_DD,f)
In [14]:
with open('BTDcDDLCo07.pkl') as f:
counts_DD = pickle.load(f)
counts_DD
Out[14]:
In [15]:
DD=np.diff(counts_DD)
In [16]:
DD
Out[16]:
In [17]:
plt.plot(bins[1:len(bins)],DD,'ro-')
Out[17]:
BallTree.two_point_correlation works almost 10 times faster! with leaf_size=5 Going with it to the random catalog
In [18]:
# Getting back the objects:
with open('rDR7200kLCsrarf.pkl') as f: # Python 3: open(..., 'rb')
datR = pickle.load(f)
datR
Out[18]:
In [19]:
%%time
BT_RLCo = BallTree(datR,metric='pyfunc',func=LCometric07,leaf_size=5)
with open('BTR200kdatsLCo07.pkl', 'w') as f:
pickle.dump(BT_RLCo,f)
In [20]:
with open('BTR200kdatsLCo07.pkl') as f:
BTRLCo = pickle.load(f)
BTRLCo
Out[20]:
In [21]:
%%time
start_time=time.time()
counts_RR=BTRLCo.two_point_correlation(datR,binsq)
print counts_RR
end_time=time.time()
tottime=end_time-start_time
print "Total run time:"
print tottime
with open('BTR200kcRRLCo07.pkl', 'w') as f:
pickle.dump(counts_RR,f)
In [22]:
with open('BTR200kcRRLCo07.pkl') as f:
counts_RR = pickle.load(f)
counts_RR
Out[22]:
In [23]:
RR=np.diff(counts_RR)
In [24]:
RR
Out[24]:
In [25]:
plt.plot(bins[1:len(bins)],RR,'bo-')
Out[25]:
In [26]:
RR_zero = (RR == 0)
RR[RR_zero] = 1
In [27]:
%%time
start_time=time.time()
counts_DR=BTRLCo.two_point_correlation(dat,binsq)
print counts_DR
end_time=time.time()
tottime=end_time-start_time
print "Total run time:"
print tottime
with open('BTR200kcDRLCo07.pkl', 'w') as f:
pickle.dump(counts_DR,f)
In [28]:
with open('BTR200kcDRLCo07.pkl') as f:
counts_DR = pickle.load(f)
counts_DR
Out[28]:
In [42]:
DR=np.diff(counts_DR)
In [43]:
DR
Out[43]:
In [44]:
corrells=(4.0 * DD - 4.0 * DR + RR) / RR
In [45]:
corrells
Out[45]:
In [33]:
plt.plot(bins[1:len(bins)],corrells,'go-')
Out[33]:
In [34]:
plt.plot(bins[1:len(bins)],bins[1:len(bins)]*bins[1:len(bins)]*corrells*(c*1e-5)**2,'go-')
Out[34]:
In [35]:
plt.plot(bins[2:len(bins)],bins[2:len(bins)]*bins[2:len(bins)]*corrells[1:len(bins)]*(c*1e-5)**2,'go-')
Out[35]:
In [36]:
plt.plot(bins[2:len(bins)],corrells[1:len(bins)],'go-')
Out[36]:
In [37]:
plt.plot(bins[2:len(bins)],corrells[1:len(bins)],'go-')
plt.savefig("correl2xlsLCo07.pdf")
In [38]:
plt.plot(bins[2:len(bins)]*c/1e5,corrells[1:len(bins)],'bo-')
plt.savefig("correl2x1lsLCo07.pdf")
In [39]:
plt.yscale('log')
plt.plot(bins[1:len(bins)]*c/1e5,corrells,'bo-')
plt.savefig("correllsfiglogLCo07.pdf")
In [40]:
plt.yscale('log')
plt.plot(bins[2:len(bins)]*c/1e5,corrells[1:len(bins)],'ro-')
plt.savefig("correllslog2xLCo07.pdf")
In [41]:
plt.yscale('log')
plt.xscale('log')
plt.plot(bins[1:len(bins)]*c/1e5,corrells,'bo-')
plt.savefig("correllsloglogLCo07.pdf")