Healpix pixelization of DR72 SDSS Database

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.constants import c
import matplotlib.pyplot as plt
import math
import scipy.special as sp

Read the data file

Sorted and reduced column set data can now be 'read' to reduce RAM requirements of the table reading.


In [4]:
sdssq=ascii.read("/home/rohin/Desktop/healpix/SDSS_quasar_radecz.dat")

In [5]:
sdssq


Out[5]:
<Table masked=False length=46420>
RADecz
float64float64float64
0.03860515.2984761.1986
0.03908813.9384472.24
0.039269-10.4644281.8442
0.04754714.9293530.4596
0.0498420.0403720.479
0.05478614.1763030.9491
0.072421-8.8566071.2499
0.10011615.334840.9885
0.10957813.767970.7678
0.120086-10.4654961.1377
.........
359.8767570.6259960.8621
359.910011-0.5801361.2039
359.918899-9.1619280.5702
359.933901-0.9606261.7851
359.952209-10.6607040.8288
359.95609315.0751850.2977
359.972672-9.6154540.3585
359.98635813.8588252.3826
359.9925460.8610622.0382
359.996089-9.1622291.2845

In [6]:
sdssq.sort("z")

In [40]:
newcol=sdssq.Column(name='pix',data=pixdata)
sdssq.add_column(newcol)


Out[40]:
<Table masked=False length=46420>
RADecz
float64float64float64
229.84028159.139920.078
47.615933-0.8307660.0802
325.2273320.4272780.0838
146.9381077.422390.0858
128.10559337.1267280.0919
258.54845557.9761180.0926
167.5502891.2244170.0949
170.28577953.8558620.1029
166.4124622.049270.1055
252.00342829.9492710.1059
.........
138.31898959.3226745.1215
162.65196458.0735055.1318
337.188116-7.9653755.1417
149.2826.1832225.1571
138.93184249.4046665.196
185.44341744.7577875.2056
163.34578158.070045.2149
246.61043127.8590255.2751
243.60474446.6747155.3131
37.906881-7.4818035.4135

Create a healpix map with NSIDE=64 (no. of pixels = 49152 as $NPIX=12\times NSIDE^2$) because the no. of galaxies in the survey are less. For higher resolution (later for dr12) we will consider NSIDE=512 or even 1024. For now, we will create a 64 NSIDE map.


In [19]:
NSIDE=128
dt72hpix=hu.HealPix("ring",NSIDE)

We have data of galaxies with redshifts between 0 and 0.5 ($0<z<0.5$). To look at a time slice/at a certain epoch we need to choose the list of galaxies within a redshift window. As, measurement of redshift has $\pm 0.05$ error. We can bin all the data into redshifts with range limited to 0.05 variation each. So, we have 10 databins with almost identical redshifts. We save each databin in a different file.


In [20]:
j=0
for i in range(1,25):
    pixdata = open("/home/rohin/Desktop/healpix/binned3/pixdata%d_%d.dat"%(NSIDE,i),'w')
    pixdata.write("ra\t dec\t z\t pix \n")
    #for j in range(len(sdssdr72)):
    
    while sdssq[j]['z']<0.2*i:
        pixdata.write("%f\t" %sdssq[j]['RA'])
        pixdata.write("%f\t" %sdssq[j]['Dec'])
        pixdata.write("%f\t" %sdssq[j]['z'])
        pixdata.write("%d\n" %dt72hpix.eq2pix(sdssq[j]['RA'],sdssq[j]['Dec']))
            #print dt72hpix.eq2pix(sdssdr72[j]['ra'],sdssdr72[j]['dec'])
        j=j+1
    pixdata.close()

In [21]:
pixdata = ascii.read("/home/rohin/Desktop/healpix/binned3/pixdata128_9.dat")
hpixdata=np.array(np.zeros(hu.nside2npix(NSIDE)))
for j in range(len(pixdata)):
    hpixdata[pixdata[j]['pix']]+=1

In [22]:
hpixdata


Out[22]:
array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

In [23]:
hu.mollview(hpixdata,rot=180)



In [25]:
blah=hu.read_map("/home/rohin/Desktop/healpix/rast_sdss_dr72safe0_nside512.fits")


NSIDE = 512
ORDERING = NESTED in fits file
Ordering converted to RING

In [27]:
hu.mollview(blah,rot=180)



In [ ]: