import healpy as hp from cosmology import * rho = 2.775e11*omegam*h**2 # Msun/Mpc^3 f=open('halos.pksc') N=np.fromfile(f,count=3,dtype=np.int32)[0] # only take first five entries for testing (there are ~8e8 halos total...) # comment the following line to read in all halos N = 5 catalog=np.fromfile(f,count=N*10,dtype=np.float32) catalog=np.reshape(catalog,(N,10)) x = catalog[:,0]; y = catalog[:,1]; z = catalog[:,2] # Mpc (comoving) vx = catalog[:,3]; vy = catalog[:,4]; vz = catalog[:,5] # km/sec R = catalog[:,6] # Mpc # convert to mass, comoving distance, radial velocity, redshfit, RA and DEc M200m = 4*np.pi/3.*rho*R**3 # this is M200m (mean density 200 times mean) in Msun chi = np.sqrt(x**2+y**2+z**2) # Mpc vrad = (x*vx + y*vy + z*vz) / chi # km/sec redshift = zofchi(chi) theta, phi = hp.vec2ang(np.column_stack((x,y,z))) # in radians ### e.g. project to a map, matching the websky orientations #nside = 1024 #map = np.zeros((hp.nside2npix(nside))) #pix = hp.vec2pix(nside, x, y, z) #pix = hp.ang2pix(nside, theta, phi) does the same #weight = 1. #1 for number density, array of size(x) for arbitrary #np.add.at(map, pix, weight)