In [5]:
## an esay way to calculate the two-point correlation function
## a simple test on the Planck cold cores
import pandas
import matplotlib.pyplot as plt
import numpy as np
from astroML.correlation import bootstrap_two_point_angular
from astroML.correlation import bootstrap_two_point
aa = pandas.read_fwf('pgcc.dat', delimiter=' ')   
aa = aa.values
ra = aa[:,4]      
dec = aa[:,5] 
plt.plot(ra,dec,'ro')
Out[5]:
[<matplotlib.lines.Line2D at 0x1a2f691fd0>]
In [18]:
bins = np.linspace(0,1,60)     
X = np.array([ra, dec])   
myx = np.transpose(X)
corr, dcorr = bootstrap_two_point(myx, bins=bins, method='landy-szalay', Nbootstrap=10)  
#print(corr)
#print(dcorr)
plt.errorbar(0.5*(bins[1:]+bins[:-1]), corr, yerr=dcorr, ecolor='r')
plt.plot(0.5*(bins[1:]+bins[:-1]), corr,'ro')
Out[18]:
[<matplotlib.lines.Line2D at 0x1a32200e48>]
In [51]:
corr, dcorr, myboot = bootstrap_two_point_angular(ra.astype(float), dec.astype(float), bins=bins, method='landy-szalay', Nbootstraps=10)

plt.errorbar(0.5*(bins[1:]+bins[:-1]), corr, yerr=dcorr, ecolor='r')
plt.plot(0.5*(bins[1:]+bins[:-1]), corr,'ro')

print('finished')
finished