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
import scipy.special as sp
from astroML.decorators import pickle_results
from scipy import integrate
import pymangle
from scipy.optimize import curve_fit
#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]:
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")
In [30]:
plt.hist(z)
Out[30]:
In [31]:
help(plt.hist)
In [32]:
np.histogram(z)
Out[32]:
In [33]:
help(np.histogram)
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 [ ]: