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 lccmetric 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.004,0.084,0.004)
bins
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 [9]:
LCcmetric(dat[0],dat[1])
Out[9]:
In [10]:
%%time
BT_DLCc = BallTree(dat,metric='pyfunc',func=LCcmetric,leaf_size=5)
with open('BTDdatsLCc.pkl', 'w') as f:
pickle.dump(BT_DLCc,f)
In [11]:
with open('BTDdatsLCc.pkl') as f:
BTDLCc = pickle.load(f)
BTDLCc
Out[11]:
In [12]:
%%time
start_time=time.time()
counts_DD=BTDLCc.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('BTDcDDLCc.pkl', 'w') as f:
pickle.dump(counts_DD,f)
In [13]:
with open('BTDcDDLCc.pkl') as f:
counts_DD = pickle.load(f)
counts_DD
Out[13]:
In [14]:
DD=np.diff(counts_DD)
In [15]:
DD
Out[15]:
In [16]:
plt.plot(bins[1:len(bins)],DD,'ro-')
Out[16]:
BallTree.two_point_correlation works almost 10 times faster! with leaf_size=5 Going with it to the random catalog
In [17]:
# Getting back the objects:
with open('rDR7200kLCsrarf.pkl') as f: # Python 3: open(..., 'rb')
datR = pickle.load(f)
datR
Out[17]:
In [18]:
%%time
BT_RLCc = BallTree(datR,metric='pyfunc',func=LCcmetric,leaf_size=5)
with open('BTR200kdatsLCc.pkl', 'w') as f:
pickle.dump(BT_RLCc,f)
In [19]:
with open('BTR200kdatsLCc.pkl') as f:
BTRLCc = pickle.load(f)
BTRLCc
Out[19]:
In [20]:
%%time
start_time=time.time()
counts_RR=BTRLCc.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('BTR200kcRRLCc.pkl', 'w') as f:
pickle.dump(counts_RR,f)
In [21]:
with open('BTR200kcRRLCc.pkl') as f:
counts_RR = pickle.load(f)
counts_RR
Out[21]:
In [22]:
RR=np.diff(counts_RR)
In [23]:
RR
Out[23]:
In [24]:
plt.plot(bins[1:len(bins)],RR,'bo-')
Out[24]:
In [25]:
RR_zero = (RR == 0)
RR[RR_zero] = 1
In [26]:
%%time
start_time=time.time()
counts_DR=BTRLCc.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('BTR200kcDRLCc.pkl', 'w') as f:
pickle.dump(counts_DR,f)
In [27]:
with open('BTR200kcDRLCc.pkl') as f:
counts_DR = pickle.load(f)
counts_DR
Out[27]:
In [28]:
DR=np.diff(counts_DR)
In [29]:
DR
Out[29]:
In [30]:
corrells=(4.0 * DD - 4.0 * DR + RR) / RR
In [31]:
corrells
Out[31]:
In [32]:
plt.plot(bins[1:len(bins)],corrells,'go-')
Out[32]:
In [33]:
plt.plot(bins[1:len(bins)],bins[1:len(bins)]*bins[1:len(bins)]*corrells*(c*1e-5)**2,'go-')
Out[33]:
In [34]:
plt.plot(bins[2:len(bins)],bins[2:len(bins)]*bins[2:len(bins)]*corrells[1:len(bins)]*(c*1e-5)**2,'go-')
Out[34]:
In [35]:
plt.plot(bins[2:len(bins)],corrells[1:len(bins)],'go-')
Out[35]:
In [36]:
plt.plot(bins[2:len(bins)],corrells[1:len(bins)],'go-')
plt.savefig("correl2xlsLCc.pdf")
In [37]:
plt.plot(bins[2:len(bins)]*c/1e5,corrells[1:len(bins)],'bo-')
plt.savefig("correl2x1lsLCc.pdf")
In [38]:
plt.yscale('log')
plt.plot(bins[1:len(bins)]*c/1e5,corrells,'bo-')
plt.savefig("correllsfiglogLCc.pdf")
In [39]:
plt.yscale('log')
plt.plot(bins[2:len(bins)]*c/1e5,corrells[1:len(bins)],'ro-')
plt.savefig("correllslog2xLCc.pdf")
In [40]:
plt.yscale('log')
plt.xscale('log')
plt.plot(bins[1:len(bins)]*c/1e5,corrells,'bo-')
plt.savefig("correllsloglogLCc.pdf")
In [ ]: