First import all the modules such as healpy and astropy needed for analyzing the structure
In [98]:
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
import scipy.special as sp
from astroML.decorators import pickle_results
from scipy import integrate
import pymangle
from scipy.optimize import curve_fit
from scipy.constants import pi
import pickle
import pymangle
#from astroML.datasets import fetch_sdss_specgals
#from astroML.correlation import bootstrap_two_point_angular
%matplotlib inline
Read the ply data file mangle polygons
In [2]:
dat=fits.open("./input/DR12Q.fits")
In [3]:
dat=dat[1].data
In [4]:
z=dat['Z_PIPE']
In [5]:
z
Out[5]:
In [6]:
len(z)
Out[6]:
In [7]:
np.histogram(z)
Out[7]:
In [8]:
plt.hist(z)
Out[8]:
In [10]:
print min(z)
print max(z)
In [16]:
bin1=dat[(dat['Z_PIPE']<1.39829586) & (dat['Z_PIPE']>=6.96677249e-01)]
In [15]:
len(dat)
Out[15]:
In [17]:
len(bin1)
Out[17]:
In [18]:
z=bin1['Z_PIPE']
In [19]:
ra=bin1['RA']
In [20]:
dec=bin1['DEC']
In [22]:
from scipy.constants import pi
In [23]:
dr12Qz1f = open("./output/DR12Qbin1.dat",'w')
dr12Qz1f.write("z\t rar\t decr \n")
for i in range(0,len(z)):
dr12Qz1f.write("%f\t " %z[i])
dr12Qz1f.write("%f\t %f\n " %(ra[i]*pi/180.0,dec[i]*pi/180.0))
dr12Qz1f.close()
In [122]:
bin1=ascii.read("./output/DR12Qbin1.dat")
In [123]:
z=bin1['z']
rar=bin1['rar']
decr=bin1['decr']
In [124]:
dat1=np.array([z,rar,decr])
In [125]:
dat1
Out[125]:
In [126]:
dat1=dat1.transpose()
In [127]:
dat1
Out[127]:
In [128]:
# Getting back the objects:
with open('./output/DR12Qbin1.pkl','w') as f: # Python 3: open(..., 'rb')
pickle.dump(dat1,f)
dat1
Out[128]:
In [129]:
# Getting back the objects:
with open('./output/DR12Qbin1.pkl') as f: # Python 3: open(..., 'rb')
dat1 = pickle.load(f)
dat1
Out[129]:
In [130]:
len(dat1)
Out[130]:
In [131]:
len(dat1)
Out[131]:
In [ ]:
In [132]:
bin1
Out[132]:
In [ ]:
In [26]:
bin2=dat[(dat['Z_PIPE']<2.09991448) & (dat['Z_PIPE']>=1.39829586)]
In [27]:
len(bin2)
Out[27]:
In [28]:
z=bin2['Z_PIPE']
In [29]:
ra=bin2['RA']
In [30]:
dec=bin2['DEC']
In [31]:
dr12Qz2f = open("./output/DR12Qbin2.dat",'w')
dr12Qz2f.write("z\t rar\t decr \n")
for i in range(0,len(z)):
dr12Qz2f.write("%f\t " %z[i])
dr12Qz2f.write("%f\t %f\n " %(ra[i]*pi/180.0,dec[i]*pi/180.0))
dr12Qz2f.close()
In [34]:
bin2=ascii.read("./output/DR12Qbin2.dat")
In [35]:
bin2
Out[35]:
In [ ]:
In [73]:
bin2=ascii.read("./output/DR12Qbin2.dat")
In [74]:
z=bin2['z']
rar=bin2['rar']
decr=bin2['decr']
In [75]:
dat2=np.array([z,rar,decr])
In [76]:
dat2
Out[76]:
In [77]:
dat2=dat2.transpose()
In [78]:
dat2
Out[78]:
In [120]:
len(dat2)
Out[120]:
In [79]:
# Getting back the objects:
with open('./output/DR12Qbin2.pkl','w') as f: # Python 3: open(..., 'rb')
pickle.dump(dat2,f)
dat2
Out[79]:
In [80]:
# Getting back the objects:
with open('./output/DR12Qbin2.pkl') as f: # Python 3: open(..., 'rb')
dat = pickle.load(f)
dat
Out[80]:
In [36]:
bin3=dat[(dat['Z_PIPE']<2.80153309) & (dat['Z_PIPE']>=2.09991448)]
In [37]:
len(bin3)
Out[37]:
In [38]:
z=bin3['Z_PIPE']
In [39]:
ra=bin3['RA']
In [40]:
dec=bin3['DEC']
In [41]:
dr12Qz3f = open("./output/DR12Qbin3.dat",'w')
dr12Qz3f.write("z\t rar\t decr \n")
for i in range(0,len(z)):
dr12Qz3f.write("%f\t " %z[i])
dr12Qz3f.write("%f\t %f\n " %(ra[i]*pi/180.0,dec[i]*pi/180.0))
dr12Qz3f.close()
In [42]:
bin3=ascii.read("./output/DR12Qbin3.dat")
In [43]:
bin3
Out[43]:
In [81]:
bin3=ascii.read("./output/DR12Qbin3.dat")
In [82]:
z=bin3['z']
rar=bin3['rar']
decr=bin3['decr']
In [83]:
dat3=np.array([z,rar,decr])
In [84]:
dat3
Out[84]:
In [85]:
dat3=dat3.transpose()
In [86]:
dat3
Out[86]:
In [87]:
# Getting back the objects:
with open('./output/DR12Qbin3.pkl','w') as f: # Python 3: open(..., 'rb')
pickle.dump(dat3,f)
dat3
Out[87]:
In [88]:
# Getting back the objects:
with open('./output/DR12Qbin3.pkl') as f: # Python 3: open(..., 'rb')
dat = pickle.load(f)
dat
Out[88]:
In [44]:
bin4=dat[(dat['Z_PIPE']<3.50315170) & (dat['Z_PIPE']>=2.80153309)]
In [45]:
len(bin4)
Out[45]:
In [46]:
z=bin4['Z_PIPE']
In [47]:
ra=bin4['RA']
In [48]:
dec=bin4['DEC']
In [49]:
dr12Qz4f = open("./output/DR12Qbin4.dat",'w')
dr12Qz4f.write("z\t rar\t decr \n")
for i in range(0,len(z)):
dr12Qz4f.write("%f\t " %z[i])
dr12Qz4f.write("%f\t %f\n " %(ra[i]*pi/180.0,dec[i]*pi/180.0))
dr12Qz4f.close()
In [50]:
bin4=ascii.read("./output/DR12Qbin4.dat")
In [51]:
bin4
Out[51]:
In [90]:
bin4=ascii.read("./output/DR12Qbin4.dat")
In [91]:
z=bin4['z']
rar=bin4['rar']
decr=bin4['decr']
In [92]:
dat4=np.array([z,rar,decr])
In [93]:
dat4
Out[93]:
In [94]:
dat4=dat4.transpose()
In [95]:
dat4
Out[95]:
In [96]:
# Getting back the objects:
with open('./output/DR12Qbin4.pkl','w') as f: # Python 3: open(..., 'rb')
pickle.dump(dat4,f)
dat4
Out[96]:
In [97]:
# Getting back the objects:
with open('./output/DR12Qbin4.pkl') as f: # Python 3: open(..., 'rb')
dat = pickle.load(f)
dat
Out[97]:
In [99]:
mangle=pymangle.Mangle("./input/boss_geometry_2014_05_28.ply")
In [133]:
%%time
rar,decr=mangle.genrand(len(dat1))
In [134]:
rar
Out[134]:
In [135]:
decr
Out[135]:
In [136]:
len(rar)
Out[136]:
In [137]:
z=bin1['z']
In [138]:
len(z)
Out[138]:
In [139]:
z
Out[139]:
In [148]:
fdata = open("./output/randDR12Qbin1.dat",'w')
fdata.write("z\t rar\t decr \n")
for i in range(0,len(rar)):
fdata.write("%f\t" %z[i])
fdata.write(("%f\t %f\n " %(rar[i]*pi/180.0,decr[i]*pi/180.0)))
fdata.close()
In [149]:
fd=ascii.read("./output/randDR12Qbin1.dat")
In [150]:
fd
Out[150]:
In [151]:
bin1=ascii.read("./output/randDR12Qbin1.dat")
In [152]:
z=bin1['z']
rar=bin1['rar']
decr=bin1['decr']
In [153]:
dat1=np.array([z,rar,decr])
In [154]:
dat1
Out[154]:
In [155]:
dat1=dat1.transpose()
In [156]:
dat1
Out[156]:
In [157]:
# Getting back the objects:
with open('./output/randDR12Qbin1.pkl','w') as f: # Python 3: open(..., 'rb')
pickle.dump(dat1,f)
dat1
Out[157]:
In [158]:
# Getting back the objects:
with open('./output/randDR12Qbin1.pkl') as f: # Python 3: open(..., 'rb')
dat1 = pickle.load(f)
dat1
Out[158]:
In [159]:
len(dat1)
Out[159]:
In [235]:
dat1[:,0]
Out[235]:
In [236]:
z1=np.mean(dat1[:,0])
print z1
In [160]:
%%time
rar,decr=mangle.genrand(len(dat2))
In [161]:
rar
Out[161]:
In [162]:
decr
Out[162]:
In [163]:
len(rar)
Out[163]:
In [164]:
z=bin2['z']
In [165]:
len(z)
Out[165]:
In [166]:
z
Out[166]:
In [167]:
fdata = open("./output/randDR12Qbin2.dat",'w')
fdata.write("z\t rar\t decr \n")
for i in range(0,len(rar)):
fdata.write("%f\t" %z[i])
fdata.write(("%f\t %f\n " %(rar[i]*pi/180.0,decr[i]*pi/180.0)))
fdata.close()
In [168]:
fd=ascii.read("./output/randDR12Qbin2.dat")
In [169]:
fd
Out[169]:
In [170]:
bin2=ascii.read("./output/randDR12Qbin2.dat")
In [171]:
z=bin2['z']
rar=bin2['rar']
decr=bin2['decr']
In [172]:
dat2=np.array([z,rar,decr])
In [173]:
dat2
Out[173]:
In [174]:
dat2=dat2.transpose()
In [175]:
dat2
Out[175]:
In [176]:
# Getting back the objects:
with open('./output/randDR12Qbin2.pkl','w') as f: # Python 3: open(..., 'rb')
pickle.dump(dat2,f)
dat2
Out[176]:
In [177]:
# Getting back the objects:
with open('./output/randDR12Qbin2.pkl') as f: # Python 3: open(..., 'rb')
dat2 = pickle.load(f)
dat2
Out[177]:
In [178]:
len(dat2)
Out[178]:
In [233]:
dat2[:,0]
Out[233]:
In [234]:
z2=np.mean(dat2[:,0])
print z2
In [179]:
%%time
rar,decr=mangle.genrand(len(dat3))
In [180]:
rar
Out[180]:
In [181]:
decr
Out[181]:
In [182]:
len(rar)
Out[182]:
In [183]:
z=bin3['z']
In [184]:
len(z)
Out[184]:
In [185]:
z
Out[185]:
In [ ]:
In [186]:
fdata = open("./output/randDR12Qbin3.dat",'w')
fdata.write("z\t rar\t decr \n")
for i in range(0,len(rar)):
fdata.write("%f\t" %z[i])
fdata.write(("%f\t %f\n " %(rar[i]*pi/180.0,decr[i]*pi/180.0)))
fdata.close()
In [187]:
fd=ascii.read("./output/randDR12Qbin3.dat")
In [188]:
fd
Out[188]:
In [170]:
bin3=ascii.read("./output/randDR12Qbin3.dat")
In [189]:
z=bin3['z']
rar=bin3['rar']
decr=bin3['decr']
In [190]:
dat3=np.array([z,rar,decr])
In [191]:
dat3
Out[191]:
In [192]:
dat3=dat3.transpose()
In [193]:
dat3
Out[193]:
In [194]:
# Getting back the objects:
with open('./output/randDR12Qbin3.pkl','w') as f: # Python 3: open(..., 'rb')
pickle.dump(dat3,f)
dat3
Out[194]:
In [195]:
# Getting back the objects:
with open('./output/randDR12Qbin3.pkl') as f: # Python 3: open(..., 'rb')
dat3 = pickle.load(f)
dat3
Out[195]:
In [196]:
len(dat3)
Out[196]:
In [231]:
dat3[:,0]
Out[231]:
In [232]:
z3=np.mean(dat3[:,0])
print z3
In [200]:
%%time
rar,decr=mangle.genrand(len(dat4))
In [201]:
rar
Out[201]:
In [202]:
decr
Out[202]:
In [203]:
len(rar)
Out[203]:
In [206]:
z=bin4['z']
In [207]:
len(z)
Out[207]:
In [208]:
z
Out[208]:
In [ ]:
In [209]:
fdata = open("./output/randDR12Qbin4.dat",'w')
fdata.write("z\t rar\t decr \n")
for i in range(0,len(rar)):
fdata.write("%f\t" %z[i])
fdata.write(("%f\t %f\n " %(rar[i]*pi/180.0,decr[i]*pi/180.0)))
fdata.close()
In [210]:
fd=ascii.read("./output/randDR12Qbin4.dat")
In [211]:
fd
Out[211]:
In [212]:
bin4=ascii.read("./output/randDR12Qbin4.dat")
In [214]:
z=bin4['z']
rar=bin4['rar']
decr=bin4['decr']
In [215]:
dat4=np.array([z,rar,decr])
In [216]:
dat4
Out[216]:
In [217]:
dat4=dat4.transpose()
In [218]:
dat4
Out[218]:
In [219]:
# Getting back the objects:
with open('./output/randDR12Qbin4.pkl','w') as f: # Python 3: open(..., 'rb')
pickle.dump(dat4,f)
dat4
Out[219]:
In [220]:
# Getting back the objects:
with open('./output/randDR12Qbin4.pkl') as f: # Python 3: open(..., 'rb')
dat4 = pickle.load(f)
dat4
Out[220]:
In [221]:
len(dat4)
Out[221]:
In [225]:
np.mean(dat4[0:])
Out[225]:
In [228]:
dat4[:,0]
Out[228]:
In [230]:
z4=np.mean(dat4[:,0])
print z4
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [46]:
z>=6.96677249e-01 and z<1.39829586
In [51]:
np.argwhere(z>=6.96677249e-01)
Out[51]:
In [52]:
z11=np.argwhere(z<1.39829586)
z12=np.argwhere(z>=6.96677249e-01)
In [62]:
len(z11)
Out[62]:
In [64]:
z11v=z[z11]
In [65]:
z11v
Out[65]:
In [66]:
len(z11v)
Out[66]:
In [70]:
z1ind=np.argwhere(z11v>=6.96677249e-01)
z1=z11v[z1ind]
In [71]:
len(z[z1ind])
Out[71]:
In [72]:
z1
Out[72]:
In [41]:
plt.plot(np.histogram(z)[1][1:],np.histogram(z)[0])
Out[41]:
In [42]:
plt.hist(z)
Out[42]:
In [ ]:
In [7]:
mangle=pymangle.Mangle("./input/boss_geometry_2014_05_28.ply")
In [8]:
%%time
rar,decr=mangle.genrand(len(z))
In [9]:
rar
Out[9]:
In [10]:
decr
Out[10]:
In [11]:
len(rar)
Out[11]:
In [12]:
print len(z)
print len(decr)
In [13]:
fdata = open("./output/randDR12Q.dat",'w')
fdata.write("z\t ra\t dec \n")
for i in range(0,len(rar)-1):
fdata.write("%f\t" %z[i])
fdata.write("%f\t" %rar[i])
fdata.write("%f\n" %decr[i])
fdata.close()
In [14]:
fd=ascii.read("./output/randDR12Q.dat")
In [15]:
fd
Out[15]:
In [16]:
NSIDE=512
rdr12qhpix=hu.HealPix("ring",NSIDE)
In [18]:
pixdata = open("./output/pixranddr12Q.dat",'w')
pixdata.write("z\t pix \n")
for i in range(0,len(rar)-1):
pixdata.write("%f\t" %z[i])
pixdata.write("%d\n" %rdr12qhpix.eq2pix(rar[i],decr[i]))
pixdata.close()
In [19]:
pixdata = ascii.read("./output/pixranddr12Q.dat")
hpixdata=np.array(np.zeros(hu.nside2npix(NSIDE)))
for j in range(len(pixdata)):
hpixdata[pixdata[j]['pix']]+=1
In [20]:
hpixdata
Out[20]:
In [21]:
hu.mollview(hpixdata,rot=180)
plt.savefig("randDR12Qm.pdf")
In [22]:
hu.orthview(hpixdata)
plt.savefig("rand12Q.pdf")
In [23]:
print min(rar)
print max(rar)
print min(decr)
print max(decr)
In [24]:
NSIDE=512
dr12qhpix=hu.HealPix("ring",NSIDE)
In [25]:
ra=dat['RA']
dec=dat['DEC']
In [27]:
pixdata = open("./output/pixdr12Q.dat",'w')
pixdata.write("z\t pix \n")
for i in range(0,len(ra)-1):
pixdata.write("%f\t" %z[i])
pixdata.write("%d\n" %dr12qhpix.eq2pix(ra[i],dec[i]))
pixdata.close()
In [26]:
pixdata = ascii.read("./output/pixdr12Q.dat")
hpixdata=np.array(np.zeros(hu.nside2npix(NSIDE)))
for j in range(len(pixdata)):
hpixdata[pixdata[j]['pix']]+=1
In [27]:
hpixdata
Out[27]:
In [28]:
hu.mollview(hpixdata,rot=180)
plt.savefig("DR12Qmollview.pdf")
In [29]:
hu.orthview(hpixdata)
plt.savefig("DR12Qorth.pdf")