In [16]:
# Load the data.
# These are all SDSS objects with 0.004<z_spec<0.011.
# The SQL call is in SQL.txt
%pylab inline
from pandas.io.parsers import read_csv
d=read_csv('sdss_specz_0p004z_0p011z.csv')
In [17]:
# Define the "bright hosts".
r_bright = 13.0
wh_bright = np.where((d.r<r_bright) &
(d.redshift>0.005) &
(d.redshift<0.01))[0]
wh_faint = np.where(d.r>=r_bright)[0]
print 'There are %i gals brighter than r=%0.1f.'%(len(wh_bright),r_bright)
In [18]:
# Convert from (RA, DEC, spec-z) to (X,Y,Z).
# All distances are in Mpc.
from cosmolopy import fidcosmo, distance
dist_Mpc = distance.comoving_distance(d.redshift, **fidcosmo)
theta = (90.0-d.dec)*np.pi/180.; phi=d.ra*np.pi/180.
x = dist_Mpc*np.sin(theta)*np.cos(phi)
y = dist_Mpc*np.sin(theta)*np.sin(phi)
z = dist_Mpc*np.cos(theta)
xyz = np.vstack([x,y,z]).T
# Find all "faint" objects within X Mpc of each "bright host"
from sklearn.neighbors import KDTree
tree = KDTree(xyz[wh_faint,:], leaf_size=30)
d_max = 3.0 # Mpc
tmp = tree.query_radius(xyz[wh_bright,:], d_max, return_distance=True)
index_nb=tmp[0]; dist_nb=tmp[1]
# Plot a histogram of the distances to the bright hosts.
hist(np.concatenate(dist_nb), bins=30)
rc('font',**{'sans-serif':['Helvetica'], 'size':14})
xlabel('distance to "bright host"(Mpc)'); ylabel('N')
Out[18]:
I'm confused. I thought that I'd see an excess of neighbors below the virial radius of these bright hosts (~0.5 Mpc?). But instead everything is consistent with the neighbors being distributed randomly (dN/dr ~ r).