DR12Q random catalog creation

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]:
array([ 2.30909729,  2.49794078,  1.61884606, ...,  2.45101476,
        3.11339068,  2.39766693], dtype=float32)

In [6]:
len(z)


Out[6]:
297301

In [7]:
np.histogram(z)


Out[7]:
(array([ 14382,  48309,  42650, 139641,  42945,   7698,   1116,    271,
           175,    114]),
 array([ -4.94136522e-03,   6.96677249e-01,   1.39829586e+00,
          2.09991448e+00,   2.80153309e+00,   3.50315170e+00,
          4.20477032e+00,   4.90638893e+00,   5.60800755e+00,
          6.30962616e+00,   7.01124477e+00]))

In [8]:
plt.hist(z)


Out[8]:
(array([  1.43820000e+04,   4.83090000e+04,   4.26500000e+04,
          1.39641000e+05,   4.29450000e+04,   7.69800000e+03,
          1.11600000e+03,   2.71000000e+02,   1.75000000e+02,
          1.14000000e+02]),
 array([ -4.94136522e-03,   6.96677249e-01,   1.39829586e+00,
          2.09991448e+00,   2.80153309e+00,   3.50315170e+00,
          4.20477032e+00,   4.90638893e+00,   5.60800755e+00,
          6.30962616e+00,   7.01124477e+00]),
 <a list of 10 Patch objects>)

In [10]:
print min(z)
print max(z)


-0.00494137
7.01124

In [16]:
bin1=dat[(dat['Z_PIPE']<1.39829586) & (dat['Z_PIPE']>=6.96677249e-01)]

In [15]:
len(dat)


Out[15]:
297301

In [17]:
len(bin1)


Out[17]:
48309

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]:
array([[  1.36035800e+00,   1.13454400e+00,   8.35325000e-01, ...,
          7.86509000e-01,   8.35873000e-01,   1.19725300e+00],
       [  9.30000000e-05,   6.82000000e-04,   7.58000000e-04, ...,
          6.28274400e+00,   6.28277000e+00,   6.28307200e+00],
       [ -3.54870000e-02,   2.43272000e-01,  -1.42169000e-01, ...,
          2.60439000e-01,   1.59740000e-01,   3.69546000e-01]])

In [126]:
dat1=dat1.transpose()

In [127]:
dat1


Out[127]:
array([[  1.36035800e+00,   9.30000000e-05,  -3.54870000e-02],
       [  1.13454400e+00,   6.82000000e-04,   2.43272000e-01],
       [  8.35325000e-01,   7.58000000e-04,  -1.42169000e-01],
       ..., 
       [  7.86509000e-01,   6.28274400e+00,   2.60439000e-01],
       [  8.35873000e-01,   6.28277000e+00,   1.59740000e-01],
       [  1.19725300e+00,   6.28307200e+00,   3.69546000e-01]])

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]:
array([[  1.36035800e+00,   9.30000000e-05,  -3.54870000e-02],
       [  1.13454400e+00,   6.82000000e-04,   2.43272000e-01],
       [  8.35325000e-01,   7.58000000e-04,  -1.42169000e-01],
       ..., 
       [  7.86509000e-01,   6.28274400e+00,   2.60439000e-01],
       [  8.35873000e-01,   6.28277000e+00,   1.59740000e-01],
       [  1.19725300e+00,   6.28307200e+00,   3.69546000e-01]])

In [129]:
# Getting back the objects:
with open('./output/DR12Qbin1.pkl') as f:  # Python 3: open(..., 'rb')
    dat1 = pickle.load(f)
dat1


Out[129]:
array([[  1.36035800e+00,   9.30000000e-05,  -3.54870000e-02],
       [  1.13454400e+00,   6.82000000e-04,   2.43272000e-01],
       [  8.35325000e-01,   7.58000000e-04,  -1.42169000e-01],
       ..., 
       [  7.86509000e-01,   6.28274400e+00,   2.60439000e-01],
       [  8.35873000e-01,   6.28277000e+00,   1.59740000e-01],
       [  1.19725300e+00,   6.28307200e+00,   3.69546000e-01]])

In [130]:
len(dat1)


Out[130]:
48309

In [131]:
len(dat1)


Out[131]:
48309

In [ ]:


In [132]:
bin1


Out[132]:
<Table length=48309>
zrardecr
float64float64float64
1.3603589.3e-05-0.035487
1.1345440.0006820.243272
0.8353250.000758-0.142169
0.7527290.000782-0.099872
0.8962210.000918-0.082249
0.8820330.0011990.042834
0.7022840.0012990.240805
1.3016110.0014250.021841
0.7042290.0015390.236405
0.8402210.0016910.339623
.........
0.7612276.2819470.510654
0.8648656.282053-0.055125
0.8549216.2820820.454166
0.7522176.2825730.223546
0.8130336.282579-0.087908
1.1720966.282584-0.027623
0.9793256.2826650.288813
0.7865096.2827440.260439
0.8358736.282770.15974
1.1972536.2830720.369546

In [ ]:


In [26]:
bin2=dat[(dat['Z_PIPE']<2.09991448) & (dat['Z_PIPE']>=1.39829586)]

In [27]:
len(bin2)


Out[27]:
42650

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]:
<Table length=42650>
zrardecr
float64float64float64
1.6188467.1e-050.084296
1.5761340.0001490.605257
1.7101030.0001570.266244
1.8335630.0002390.19133
2.0014120.0003730.150584
2.08920.000401-0.096075
1.6405170.00042-0.075666
2.0046530.0004880.529287
1.5456140.0005130.105756
1.6154990.000626-0.178954
.........
1.8698096.2821730.574029
1.6051746.2821740.534793
2.0787326.2822160.587197
1.8524526.2823930.301937
1.7003086.2824340.289916
1.7628586.2824880.189745
1.6399776.2825480.424658
1.6219096.282646-0.073565
1.5694096.282703-0.077083
1.8492216.282820.033848

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]:
array([[  1.61884600e+00,   1.57613400e+00,   1.71010300e+00, ...,
          1.62190900e+00,   1.56940900e+00,   1.84922100e+00],
       [  7.10000000e-05,   1.49000000e-04,   1.57000000e-04, ...,
          6.28264600e+00,   6.28270300e+00,   6.28282000e+00],
       [  8.42960000e-02,   6.05257000e-01,   2.66244000e-01, ...,
         -7.35650000e-02,  -7.70830000e-02,   3.38480000e-02]])

In [77]:
dat2=dat2.transpose()

In [78]:
dat2


Out[78]:
array([[  1.61884600e+00,   7.10000000e-05,   8.42960000e-02],
       [  1.57613400e+00,   1.49000000e-04,   6.05257000e-01],
       [  1.71010300e+00,   1.57000000e-04,   2.66244000e-01],
       ..., 
       [  1.62190900e+00,   6.28264600e+00,  -7.35650000e-02],
       [  1.56940900e+00,   6.28270300e+00,  -7.70830000e-02],
       [  1.84922100e+00,   6.28282000e+00,   3.38480000e-02]])

In [120]:
len(dat2)


Out[120]:
42650

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]:
array([[  1.61884600e+00,   7.10000000e-05,   8.42960000e-02],
       [  1.57613400e+00,   1.49000000e-04,   6.05257000e-01],
       [  1.71010300e+00,   1.57000000e-04,   2.66244000e-01],
       ..., 
       [  1.62190900e+00,   6.28264600e+00,  -7.35650000e-02],
       [  1.56940900e+00,   6.28270300e+00,  -7.70830000e-02],
       [  1.84922100e+00,   6.28282000e+00,   3.38480000e-02]])

In [80]:
# Getting back the objects:
with open('./output/DR12Qbin2.pkl') as f:  # Python 3: open(..., 'rb')
    dat = pickle.load(f)
dat


Out[80]:
array([[  1.61884600e+00,   7.10000000e-05,   8.42960000e-02],
       [  1.57613400e+00,   1.49000000e-04,   6.05257000e-01],
       [  1.71010300e+00,   1.57000000e-04,   2.66244000e-01],
       ..., 
       [  1.62190900e+00,   6.28264600e+00,  -7.35650000e-02],
       [  1.56940900e+00,   6.28270300e+00,  -7.70830000e-02],
       [  1.84922100e+00,   6.28282000e+00,   3.38480000e-02]])

In [36]:
bin3=dat[(dat['Z_PIPE']<2.80153309) & (dat['Z_PIPE']>=2.09991448)]

In [37]:
len(bin3)


Out[37]:
139641

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]:
<Table length=139641>
zrardecr
float64float64float64
2.3090973.3e-050.31021
2.4979414.8e-050.261357
2.3326550.0001-0.023126
2.3732990.0001190.532663
2.5423030.000128-0.130654
2.1645590.000141-0.004206
2.5434710.000160.204148
2.6510570.0001710.385902
2.3541480.0002310.021868
2.1647610.0002570.533554
.........
2.7595956.2830470.565462
2.7337736.2830680.087709
2.5520776.283114-0.147293
2.3983046.283120.049193
2.1813016.283140.519839
2.4391796.283143-0.171497
2.1877776.2831640.152742
2.4155086.2831660.176571
2.4510156.283170.505355
2.3976676.2831840.606452

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]:
array([[  2.30909700e+00,   2.49794100e+00,   2.33265500e+00, ...,
          2.41550800e+00,   2.45101500e+00,   2.39766700e+00],
       [  3.30000000e-05,   4.80000000e-05,   1.00000000e-04, ...,
          6.28316600e+00,   6.28317000e+00,   6.28318400e+00],
       [  3.10210000e-01,   2.61357000e-01,  -2.31260000e-02, ...,
          1.76571000e-01,   5.05355000e-01,   6.06452000e-01]])

In [85]:
dat3=dat3.transpose()

In [86]:
dat3


Out[86]:
array([[  2.30909700e+00,   3.30000000e-05,   3.10210000e-01],
       [  2.49794100e+00,   4.80000000e-05,   2.61357000e-01],
       [  2.33265500e+00,   1.00000000e-04,  -2.31260000e-02],
       ..., 
       [  2.41550800e+00,   6.28316600e+00,   1.76571000e-01],
       [  2.45101500e+00,   6.28317000e+00,   5.05355000e-01],
       [  2.39766700e+00,   6.28318400e+00,   6.06452000e-01]])

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]:
array([[  2.30909700e+00,   3.30000000e-05,   3.10210000e-01],
       [  2.49794100e+00,   4.80000000e-05,   2.61357000e-01],
       [  2.33265500e+00,   1.00000000e-04,  -2.31260000e-02],
       ..., 
       [  2.41550800e+00,   6.28316600e+00,   1.76571000e-01],
       [  2.45101500e+00,   6.28317000e+00,   5.05355000e-01],
       [  2.39766700e+00,   6.28318400e+00,   6.06452000e-01]])

In [88]:
# Getting back the objects:
with open('./output/DR12Qbin3.pkl') as f:  # Python 3: open(..., 'rb')
    dat = pickle.load(f)
dat


Out[88]:
array([[  2.30909700e+00,   3.30000000e-05,   3.10210000e-01],
       [  2.49794100e+00,   4.80000000e-05,   2.61357000e-01],
       [  2.33265500e+00,   1.00000000e-04,  -2.31260000e-02],
       ..., 
       [  2.41550800e+00,   6.28316600e+00,   1.76571000e-01],
       [  2.45101500e+00,   6.28317000e+00,   5.05355000e-01],
       [  2.39766700e+00,   6.28318400e+00,   6.06452000e-01]])

In [44]:
bin4=dat[(dat['Z_PIPE']<3.50315170) & (dat['Z_PIPE']>=2.80153309)]

In [45]:
len(bin4)


Out[45]:
42945

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]:
<Table length=42945>
zrardecr
float64float64float64
3.0888390.0001030.34928
2.9064480.0002520.280095
2.8793720.000361-0.004858
3.0090770.0003780.239244
3.1237950.0004280.594248
3.2503610.000465-0.120452
2.8281290.0005440.204236
3.0899680.0008970.398611
3.2786930.0009110.556924
3.228430.0010240.026139
.........
2.9745646.2820250.069631
3.1289226.2822210.212078
3.182616.2824880.390924
2.815916.282607-0.061368
2.9769776.2827510.199639
3.4212836.2828240.528812
3.1289516.282996-0.02931
3.1669116.2830330.624115
3.0647496.2830850.007521
3.1133916.2831730.605993

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]:
array([[  3.08883900e+00,   2.90644800e+00,   2.87937200e+00, ...,
          3.16691100e+00,   3.06474900e+00,   3.11339100e+00],
       [  1.03000000e-04,   2.52000000e-04,   3.61000000e-04, ...,
          6.28303300e+00,   6.28308500e+00,   6.28317300e+00],
       [  3.49280000e-01,   2.80095000e-01,  -4.85800000e-03, ...,
          6.24115000e-01,   7.52100000e-03,   6.05993000e-01]])

In [94]:
dat4=dat4.transpose()

In [95]:
dat4


Out[95]:
array([[  3.08883900e+00,   1.03000000e-04,   3.49280000e-01],
       [  2.90644800e+00,   2.52000000e-04,   2.80095000e-01],
       [  2.87937200e+00,   3.61000000e-04,  -4.85800000e-03],
       ..., 
       [  3.16691100e+00,   6.28303300e+00,   6.24115000e-01],
       [  3.06474900e+00,   6.28308500e+00,   7.52100000e-03],
       [  3.11339100e+00,   6.28317300e+00,   6.05993000e-01]])

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]:
array([[  3.08883900e+00,   1.03000000e-04,   3.49280000e-01],
       [  2.90644800e+00,   2.52000000e-04,   2.80095000e-01],
       [  2.87937200e+00,   3.61000000e-04,  -4.85800000e-03],
       ..., 
       [  3.16691100e+00,   6.28303300e+00,   6.24115000e-01],
       [  3.06474900e+00,   6.28308500e+00,   7.52100000e-03],
       [  3.11339100e+00,   6.28317300e+00,   6.05993000e-01]])

In [97]:
# Getting back the objects:
with open('./output/DR12Qbin4.pkl') as f:  # Python 3: open(..., 'rb')
    dat = pickle.load(f)
dat


Out[97]:
array([[  3.08883900e+00,   1.03000000e-04,   3.49280000e-01],
       [  2.90644800e+00,   2.52000000e-04,   2.80095000e-01],
       [  2.87937200e+00,   3.61000000e-04,  -4.85800000e-03],
       ..., 
       [  3.16691100e+00,   6.28303300e+00,   6.24115000e-01],
       [  3.06474900e+00,   6.28308500e+00,   7.52100000e-03],
       [  3.11339100e+00,   6.28317300e+00,   6.05993000e-01]])

In [99]:
mangle=pymangle.Mangle("./input/boss_geometry_2014_05_28.ply")

In [133]:
%%time
rar,decr=mangle.genrand(len(dat1))


CPU times: user 146 ms, sys: 1.5 ms, total: 148 ms
Wall time: 147 ms

In [134]:
rar


Out[134]:
array([ 244.60063,  3.4907028,  340.43799, ...,  170.79402,  29.954694,
        197.62726], dtype=float128)

In [135]:
decr


Out[135]:
array([ 29.496631,  35.246276,  10.567022, ...,  27.517911, -7.0798175,
        35.490503], dtype=float128)

In [136]:
len(rar)


Out[136]:
48309

In [137]:
z=bin1['z']

In [138]:
len(z)


Out[138]:
48309

In [139]:
z


Out[139]:
<Column name='z' dtype='float64' length=48309>
1.360358
1.134544
0.835325
0.752729
0.896221
0.882033
0.702284
1.301611
0.704229
0.840221
0.908785
0.793805
...
0.865574
0.738804
0.761227
0.864865
0.854921
0.752217
0.813033
1.172096
0.979325
0.786509
0.835873
1.197253

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]:
<Table length=48309>
zrardecr
float64float64float64
1.3603584.2690860.514813
1.1345440.0609240.615164
0.8353255.9417640.184429
0.7527292.0444950.732866
0.8962210.732539-0.028812
0.8820333.173271.120221
0.7022846.090820.118695
1.3016113.2008350.256571
0.7042293.3334060.297478
0.8402213.8680560.296897
.........
0.7612273.922021.062586
0.8648650.1978290.517763
0.8549213.3007420.360668
0.7522172.7208280.202376
0.8130333.4141450.918999
1.1720962.8681060.627862
0.9793256.2630830.42093
0.7865092.9809180.480278
0.8358730.522808-0.123566
1.1972533.4492460.619426

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]:
array([[ 1.360358,  1.134544,  0.835325, ...,  0.786509,  0.835873,
         1.197253],
       [ 4.269086,  0.060924,  5.941764, ...,  2.980918,  0.522808,
         3.449246],
       [ 0.514813,  0.615164,  0.184429, ...,  0.480278, -0.123566,
         0.619426]])

In [155]:
dat1=dat1.transpose()

In [156]:
dat1


Out[156]:
array([[ 1.360358,  4.269086,  0.514813],
       [ 1.134544,  0.060924,  0.615164],
       [ 0.835325,  5.941764,  0.184429],
       ..., 
       [ 0.786509,  2.980918,  0.480278],
       [ 0.835873,  0.522808, -0.123566],
       [ 1.197253,  3.449246,  0.619426]])

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]:
array([[ 1.360358,  4.269086,  0.514813],
       [ 1.134544,  0.060924,  0.615164],
       [ 0.835325,  5.941764,  0.184429],
       ..., 
       [ 0.786509,  2.980918,  0.480278],
       [ 0.835873,  0.522808, -0.123566],
       [ 1.197253,  3.449246,  0.619426]])

In [158]:
# Getting back the objects:
with open('./output/randDR12Qbin1.pkl') as f:  # Python 3: open(..., 'rb')
    dat1 = pickle.load(f)
dat1


Out[158]:
array([[ 1.360358,  4.269086,  0.514813],
       [ 1.134544,  0.060924,  0.615164],
       [ 0.835325,  5.941764,  0.184429],
       ..., 
       [ 0.786509,  2.980918,  0.480278],
       [ 0.835873,  0.522808, -0.123566],
       [ 1.197253,  3.449246,  0.619426]])

In [159]:
len(dat1)


Out[159]:
48309

In [235]:
dat1[:,0]


Out[235]:
array([ 1.360358,  1.134544,  0.835325, ...,  0.786509,  0.835873,
        1.197253])

In [236]:
z1=np.mean(dat1[:,0])
print z1


0.957640720611

In [160]:
%%time
rar,decr=mangle.genrand(len(dat2))


CPU times: user 146 ms, sys: 1.57 ms, total: 147 ms
Wall time: 147 ms

In [161]:
rar


Out[161]:
array([ 187.54879,  174.8315,  226.52937, ...,  199.90006,  24.570883,
        152.36008], dtype=float128)

In [162]:
decr


Out[162]:
array([ 17.03004,  54.236363,  6.3119358, ...,  9.8931565,  2.0275094,
        15.830989], dtype=float128)

In [163]:
len(rar)


Out[163]:
42650

In [164]:
z=bin2['z']

In [165]:
len(z)


Out[165]:
42650

In [166]:
z


Out[166]:
<Column name='z' dtype='float64' length=42650>
1.618846
1.576134
1.710103
1.833563
2.001412
2.0892
1.640517
2.004653
1.545614
1.615499
1.435563
1.976213
...
1.717248
1.758497
1.869809
1.605174
2.078732
1.852452
1.700308
1.762858
1.639977
1.621909
1.569409
1.849221

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]:
<Table length=42650>
zrardecr
float64float64float64
1.6188463.2733440.29723
1.5761343.0513850.946603
1.7101033.9536830.110164
1.8335632.7649830.255697
2.0014123.7024570.504963
2.08922.7584080.674666
1.6405173.0918230.245293
2.0046533.1512950.708954
1.5456143.7892850.980275
1.6154993.6574120.825689
.........
1.8698092.7170111.082111
1.6051743.6950280.021013
2.0787326.2534930.266181
1.8524520.5705810.452779
1.7003083.6824070.599498
1.7628583.8490290.210922
1.6399773.1868020.135185
1.6219093.4889140.172668
1.5694090.4288430.035387
1.8492212.6591850.276303

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]:
array([[ 1.618846,  1.576134,  1.710103, ...,  1.621909,  1.569409,
         1.849221],
       [ 3.273344,  3.051385,  3.953683, ...,  3.488914,  0.428843,
         2.659185],
       [ 0.29723 ,  0.946603,  0.110164, ...,  0.172668,  0.035387,
         0.276303]])

In [174]:
dat2=dat2.transpose()

In [175]:
dat2


Out[175]:
array([[ 1.618846,  3.273344,  0.29723 ],
       [ 1.576134,  3.051385,  0.946603],
       [ 1.710103,  3.953683,  0.110164],
       ..., 
       [ 1.621909,  3.488914,  0.172668],
       [ 1.569409,  0.428843,  0.035387],
       [ 1.849221,  2.659185,  0.276303]])

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]:
array([[ 1.618846,  3.273344,  0.29723 ],
       [ 1.576134,  3.051385,  0.946603],
       [ 1.710103,  3.953683,  0.110164],
       ..., 
       [ 1.621909,  3.488914,  0.172668],
       [ 1.569409,  0.428843,  0.035387],
       [ 1.849221,  2.659185,  0.276303]])

In [177]:
# Getting back the objects:
with open('./output/randDR12Qbin2.pkl') as f:  # Python 3: open(..., 'rb')
    dat2 = pickle.load(f)
dat2


Out[177]:
array([[ 1.618846,  3.273344,  0.29723 ],
       [ 1.576134,  3.051385,  0.946603],
       [ 1.710103,  3.953683,  0.110164],
       ..., 
       [ 1.621909,  3.488914,  0.172668],
       [ 1.569409,  0.428843,  0.035387],
       [ 1.849221,  2.659185,  0.276303]])

In [178]:
len(dat2)


Out[178]:
42650

In [233]:
dat2[:,0]


Out[233]:
array([ 1.618846,  1.576134,  1.710103, ...,  1.621909,  1.569409,
        1.849221])

In [234]:
z2=np.mean(dat2[:,0])
print z2


1.76960169147

In [179]:
%%time
rar,decr=mangle.genrand(len(dat3))


CPU times: user 415 ms, sys: 2.8 ms, total: 418 ms
Wall time: 418 ms

In [180]:
rar


Out[180]:
array([ 219.16857,  247.39444,  228.08203, ...,  348.78554,  8.0626544,
        209.37297], dtype=float128)

In [181]:
decr


Out[181]:
array([ 51.972382,  49.430065,  43.056694, ...,  18.618568,  22.657612,
        17.468624], dtype=float128)

In [182]:
len(rar)


Out[182]:
139641

In [183]:
z=bin3['z']

In [184]:
len(z)


Out[184]:
139641

In [185]:
z


Out[185]:
<Column name='z' dtype='float64' length=139641>
2.309097
2.497941
2.332655
2.373299
2.542303
2.164559
2.543471
2.651057
2.354148
2.164761
2.271441
2.180127
...
2.3247
2.272273
2.759595
2.733773
2.552077
2.398304
2.181301
2.439179
2.187777
2.415508
2.451015
2.397667

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]:
<Table length=139641>
zrardecr
float64float64float64
2.3090973.8252130.907089
2.4979414.3178470.862717
2.3326553.9807820.751481
2.3732993.0471160.402239
2.5423030.2505590.403021
2.1645595.9020570.208055
2.5434716.179960.373863
2.6510572.7331071.114213
2.3541482.8943480.150544
2.1647610.1633540.34185
.........
2.7595954.242071.029525
2.7337733.4989520.152141
2.5520772.1370450.646528
2.3983042.9145080.615876
2.1813010.1199950.286168
2.4391793.28874-0.03044
2.1877770.166733-0.138122
2.4155086.0874560.324955
2.4510150.140720.39545
2.3976673.6542480.304885

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]:
array([[  2.30909700e+00,   2.49794100e+00,   2.33265500e+00, ...,
          2.41550800e+00,   2.45101500e+00,   2.39766700e+00],
       [  3.30000000e-05,   4.80000000e-05,   1.00000000e-04, ...,
          6.28316600e+00,   6.28317000e+00,   6.28318400e+00],
       [  3.10210000e-01,   2.61357000e-01,  -2.31260000e-02, ...,
          1.76571000e-01,   5.05355000e-01,   6.06452000e-01]])

In [192]:
dat3=dat3.transpose()

In [193]:
dat3


Out[193]:
array([[  2.30909700e+00,   3.30000000e-05,   3.10210000e-01],
       [  2.49794100e+00,   4.80000000e-05,   2.61357000e-01],
       [  2.33265500e+00,   1.00000000e-04,  -2.31260000e-02],
       ..., 
       [  2.41550800e+00,   6.28316600e+00,   1.76571000e-01],
       [  2.45101500e+00,   6.28317000e+00,   5.05355000e-01],
       [  2.39766700e+00,   6.28318400e+00,   6.06452000e-01]])

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]:
array([[  2.30909700e+00,   3.30000000e-05,   3.10210000e-01],
       [  2.49794100e+00,   4.80000000e-05,   2.61357000e-01],
       [  2.33265500e+00,   1.00000000e-04,  -2.31260000e-02],
       ..., 
       [  2.41550800e+00,   6.28316600e+00,   1.76571000e-01],
       [  2.45101500e+00,   6.28317000e+00,   5.05355000e-01],
       [  2.39766700e+00,   6.28318400e+00,   6.06452000e-01]])

In [195]:
# Getting back the objects:
with open('./output/randDR12Qbin3.pkl') as f:  # Python 3: open(..., 'rb')
    dat3 = pickle.load(f)
dat3


Out[195]:
array([[  2.30909700e+00,   3.30000000e-05,   3.10210000e-01],
       [  2.49794100e+00,   4.80000000e-05,   2.61357000e-01],
       [  2.33265500e+00,   1.00000000e-04,  -2.31260000e-02],
       ..., 
       [  2.41550800e+00,   6.28316600e+00,   1.76571000e-01],
       [  2.45101500e+00,   6.28317000e+00,   5.05355000e-01],
       [  2.39766700e+00,   6.28318400e+00,   6.06452000e-01]])

In [196]:
len(dat3)


Out[196]:
139641

In [231]:
dat3[:,0]


Out[231]:
array([ 2.309097,  2.497941,  2.332655, ...,  2.415508,  2.451015,
        2.397667])

In [232]:
z3=np.mean(dat3[:,0])
print z3


2.41105691717

In [200]:
%%time
rar,decr=mangle.genrand(len(dat4))


CPU times: user 138 ms, sys: 1.54 ms, total: 140 ms
Wall time: 140 ms

In [201]:
rar


Out[201]:
array([ 201.08922,  329.24997,  131.66923, ...,  5.6569609,  356.88081,
        328.56472], dtype=float128)

In [202]:
decr


Out[202]:
array([ 30.181739,  1.4083831,  11.099657, ...,  4.9097444,  22.540363,
        2.4910029], dtype=float128)

In [203]:
len(rar)


Out[203]:
42945

In [206]:
z=bin4['z']

In [207]:
len(z)


Out[207]:
42945

In [208]:
z


Out[208]:
<Column name='z' dtype='float64' length=42945>
3.088839
2.906448
2.879372
3.009077
3.123795
3.250361
2.828129
3.089968
3.278693
3.22843
3.48995
3.027761
...
3.058009
3.340463
2.974564
3.128922
3.18261
2.81591
2.976977
3.421283
3.128951
3.166911
3.064749
3.113391

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]:
<Table length=42945>
zrardecr
float64float64float64
3.0888393.5096690.526771
2.9064485.7464960.024581
2.8793722.2980620.193726
3.0090774.1337020.273621
3.1237952.8315090.48065
3.2503612.9383040.510374
2.8281295.630599-0.059139
3.0899683.0482570.673365
3.2786933.2463620.259751
3.228433.2733150.911471
.........
2.9745642.5139160.219169
3.1289222.8504640.704095
3.182612.8351070.564101
2.815916.2331260.127182
2.9769772.1578780.067073
3.4212833.0564510.485489
3.1289513.2156740.730304
3.1669110.0987330.085691
3.0647496.2287450.393404
3.1133915.7345360.043476

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]:
array([[ 3.088839,  2.906448,  2.879372, ...,  3.166911,  3.064749,
         3.113391],
       [ 3.509669,  5.746496,  2.298062, ...,  0.098733,  6.228745,
         5.734536],
       [ 0.526771,  0.024581,  0.193726, ...,  0.085691,  0.393404,
         0.043476]])

In [217]:
dat4=dat4.transpose()

In [218]:
dat4


Out[218]:
array([[ 3.088839,  3.509669,  0.526771],
       [ 2.906448,  5.746496,  0.024581],
       [ 2.879372,  2.298062,  0.193726],
       ..., 
       [ 3.166911,  0.098733,  0.085691],
       [ 3.064749,  6.228745,  0.393404],
       [ 3.113391,  5.734536,  0.043476]])

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]:
array([[ 3.088839,  3.509669,  0.526771],
       [ 2.906448,  5.746496,  0.024581],
       [ 2.879372,  2.298062,  0.193726],
       ..., 
       [ 3.166911,  0.098733,  0.085691],
       [ 3.064749,  6.228745,  0.393404],
       [ 3.113391,  5.734536,  0.043476]])

In [220]:
# Getting back the objects:
with open('./output/randDR12Qbin4.pkl') as f:  # Python 3: open(..., 'rb')
    dat4 = pickle.load(f)
dat4


Out[220]:
array([[ 3.088839,  3.509669,  0.526771],
       [ 2.906448,  5.746496,  0.024581],
       [ 2.879372,  2.298062,  0.193726],
       ..., 
       [ 3.166911,  0.098733,  0.085691],
       [ 3.064749,  6.228745,  0.393404],
       [ 3.113391,  5.734536,  0.043476]])

In [221]:
len(dat4)


Out[221]:
42945

In [225]:
np.mean(dat4[0:])


Out[225]:
2.1992691680521599

In [228]:
dat4[:,0]


Out[228]:
array([ 3.088839,  2.906448,  2.879372, ...,  3.166911,  3.064749,
        3.113391])

In [230]:
z4=np.mean(dat4[:,0])
print z4


3.07002500165

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [46]:
z>=6.96677249e-01 and z<1.39829586


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-46-fd2ee321d7c4> in <module>()
----> 1 z>=6.96677249e-01 and z<1.39829586

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

In [51]:
np.argwhere(z>=6.96677249e-01)


Out[51]:
array([[     0],
       [     1],
       [     2],
       ..., 
       [297298],
       [297299],
       [297300]])

In [52]:
z11=np.argwhere(z<1.39829586)
z12=np.argwhere(z>=6.96677249e-01)

In [62]:
len(z11)


Out[62]:
62691

In [64]:
z11v=z[z11]

In [65]:
z11v


Out[65]:
array([[ 1.36035752],
       [ 0.67536956],
       [ 1.13454401],
       ..., 
       [ 0.78650928],
       [ 0.83587337],
       [ 1.19725287]], dtype=float32)

In [66]:
len(z11v)


Out[66]:
62691

In [70]:
z1ind=np.argwhere(z11v>=6.96677249e-01)
z1=z11v[z1ind]

In [71]:
len(z[z1ind])


Out[71]:
48309

In [72]:
z1


Out[72]:
array([[[ 1.36035752],
        [ 1.36035752]],

       [[ 1.13454401],
        [ 1.36035752]],

       [[ 0.8353247 ],
        [ 1.36035752]],

       ..., 
       [[ 0.78650928],
        [ 1.36035752]],

       [[ 0.83587337],
        [ 1.36035752]],

       [[ 1.19725287],
        [ 1.36035752]]], dtype=float32)

In [41]:
plt.plot(np.histogram(z)[1][1:],np.histogram(z)[0])


Out[41]:
[<matplotlib.lines.Line2D at 0x13781ad90>]

In [42]:
plt.hist(z)


Out[42]:
(array([  1.43820000e+04,   4.83090000e+04,   4.26500000e+04,
          1.39641000e+05,   4.29450000e+04,   7.69800000e+03,
          1.11600000e+03,   2.71000000e+02,   1.75000000e+02,
          1.14000000e+02]),
 array([ -4.94136522e-03,   6.96677249e-01,   1.39829586e+00,
          2.09991448e+00,   2.80153309e+00,   3.50315170e+00,
          4.20477032e+00,   4.90638893e+00,   5.60800755e+00,
          6.30962616e+00,   7.01124477e+00]),
 <a list of 10 Patch objects>)

In [ ]:


In [7]:
mangle=pymangle.Mangle("./input/boss_geometry_2014_05_28.ply")

In [8]:
%%time
rar,decr=mangle.genrand(len(z))


CPU times: user 1.12 s, sys: 4.41 ms, total: 1.13 s
Wall time: 1.14 s

In [9]:
rar


Out[9]:
array([ 200.46421,  16.276615,  217.50623, ...,  140.52798,  5.9646122,
        152.62438], dtype=float128)

In [10]:
decr


Out[10]:
array([ 38.475609,  6.1485714,  27.729229, ...,  43.966504,  29.114936,
        40.696016], dtype=float128)

In [11]:
len(rar)


Out[11]:
297301

In [12]:
print len(z)
print len(decr)


297301
297301

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]:
<Table length=297300>
zradec
float64float64float64
2.309097200.46421138.475609
2.49794116.2766156.148571
1.618846217.50623427.729229
1.360358209.7500069.125118
2.33265523.81912415.051518
3.088839245.17165157.761975
2.373299173.3549734.91245
2.542303137.50700439.254526
3.711993158.20371219.110721
2.164559241.6033520.833734
.........
1.197253343.65904412.314154
3.06474926.382062-0.859049
2.552077317.5616531.809564
2.398304155.41260129.174921
2.181301206.3569036.363123
2.43917930.74446728.764067
2.187777133.62529854.045642
2.415508182.17529226.12546
2.451015140.5279843.966504
3.1133915.96461229.114936

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]:
array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

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)


0.000188855808432
359.996729426
-10.9989631307
68.7228354106

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]:
array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

In [28]:
hu.mollview(hpixdata,rot=180)
plt.savefig("DR12Qmollview.pdf")



In [29]:
hu.orthview(hpixdata)
plt.savefig("DR12Qorth.pdf")