def measure_nbar_clustering(Mr): '''measure wp for the galaxy catalog with the luminosity threshold Mr''' #Corrfunc settings for wp measurements: boxsize = 250 nthreads = 4 pimax = 40.0 binfile = path.join(path.dirname(path.abspath(__file__)), "../", "bin") autocorr = 1 filename = util.dat_dir()+'AM_Mr'+str(Mr)+'dat' cat = np.loadtxt(filename) pos = cat[:,1:4] x, y, z = pos[:,0], pos[:,1], pos[:,2] vel = cat[:,4:7] vx, vy, vz = vel[:,0], vel[:,1], vel[:,2] #applying RSD: pos = return_xyz_formatted_array(x, y, z, velocity = vz, velocity_distortion_dimension = 'z') #enforcing periodic boundary conditions: pos = enforce_periodicity_of_box(pos, boxsize) pos = pos.astype(np.float32) x, y, z = pos[:,0] , pos[:,1] , pos[:,2] wp_result = _countpairs.countpairs_wp(boxsize, pimax, nthreads, binfile, x, y, z) nbar = 1.*len(pos)/boxsize**3. wp = np.array(wp_result)[:,3] return nbar , wp
def _sum_stat(self, theta, prior_range=None): self.model.param_dict['logM0'] = theta[0] self.model.param_dict['sigma_logM'] = theta[1] self.model.param_dict['logMmin'] = theta[2] self.model.param_dict['alpha'] = theta[3] self.model.param_dict['logM1'] = theta[4] self.model.populate_mock(self.halocat) x = self.model.mock.galaxy_table['x'] y = self.model.mock.galaxy_table['y'] z = self.model.mock.galaxy_table['z'] vz = self.model.mock.galaxy_table['vz'] # applying RSD pos = return_xyz_formatted_array(x, y, z, velocity = vz, velocity_distortion_dimension = 'z') # enforcing PBC pos = enforce_periodicity_of_box(pos, self.boxsize) pos = pos.astype(np.float32) x, y, z = pos[:,0] , pos[:,1] , pos[:,2] results_wp = _countpairs.countpairs_wp(self.boxsize, self.pimax, self.nthreads, self.binfile, x, y, z) wp = np.array(results_wp)[:,3] nbar = 1.*len(pos)/(self.boxsize)**3. return nbar , wp
def _sum_stat(self, theta, prior_range=None): self.model.param_dict['logM0'] = theta[0] self.model.param_dict['sigma_logM'] = theta[1] self.model.param_dict['logMmin'] = theta[2] self.model.param_dict['alpha'] = theta[3] self.model.param_dict['logM1'] = theta[4] gmff = [] for i in xrange(1): self.model.populate_mock(self.halocat) x = self.model.mock.galaxy_table['x'] y = self.model.mock.galaxy_table['y'] z = self.model.mock.galaxy_table['z'] vz = self.model.mock.galaxy_table['vz'] # applying RSD pos = return_xyz_formatted_array(x, y, z, velocity = vz, velocity_distortion_dimension = 'z') # enforcing PBC pos = enforce_periodicity_of_box(pos, self.boxsize) bperp = 0.14 bpar = 0.75 Lbox = np.array([self.boxsize, self.boxsize, self.boxsize]) period = Lbox groups = FoFGroups(pos, b_perp=bperp, b_para=bpar, Lbox = Lbox , period=Lbox) group_ids = groups.group_ids group_richness = richness(group_ids) gmff.append(np.histogram(np.array(group_richness) ,self.data_gmf_bin)[0] / (self.data_gmf_bin_width * self.boxsize**3.)) gmf = np.mean(np.array(gmff) , axis = 0) nbar = 1.*len(pos)/(self.boxsize)**3. return nbar , gmf
def compute_jackknife_covariance(Mr , nsub): box_size = 250. filename = util.dat_dir()+'AM_Mr'+str(Mr)+'dat' cat = np.loadtxt(filename) pos = cat[:,1:4] #positions of all galaxies in the box vel = cat[:,4:7] #velocities of all galaxies x , y , z = pos[:,0], pos[:,1], pos[:,2] vx, vy, vz = vel[:,0], vel[:,1], vel[:,2] rsd_pos = return_xyz_formatted_array(x, y, z, velocity = vz, velocity_distortion_dimension = 'z') rsd_pos = enforce_periodicity_of_box(rsd_pos, box_size) number_of_subboxes = nsub ** 3 #Corrfunc settings for wp measurements: subbox_size = box_size / nsub nthreads = 4 pimax = 25.0 binfile = path.join(path.dirname(path.abspath(__file__)), "../", "bin") len_wp = len(np.loadtxt(binfile)) wps = np.zeros((number_of_subboxes , len_wp)) nbars = np.zeros((number_of_subboxes , 1)) for subvol_index in xrange(number_of_subboxes): sub_rsd_pos = mask_positions(rsd_pos , subvol_index , nsub) sub_rsd_pos = sub_rsd_pos.astype(np.float32) sub_x, sub_y, sub_z = sub_rsd_pos[:,0] , sub_rsd_pos[:,1] , sub_rsd_pos[:,2] wp_result = _countpairs.countpairs_wp(subbox_size, pimax, nthreads, binfile, sub_x, sub_y, sub_z) nbars[subvol_index] = 1.*len(sub_rsd_pos)/subbox_size**3. wps[subvol_index] = np.array(wp_result)[:,3] nbar_covar = np.array([np.var(nbars)]) wp_covar = np.cov(wps.T) return nbar_covar , wp_covar
def main(): cov = np.loadtxt("../../data/wpxicov_dr72_bright0_mr21.0_z0.159_nj400") f_MD = (1. + 71.74*10**6. / (1000.)**3.) f_bol = (1. + 71.74*10.**6. / (250.)**3.) print("covariance correction factor=" , f_bol/f_MD) cov = cov*f_bol/f_MD model.param_dict['logM0'] = 12.59 model.param_dict['sigma_logM'] = 0.49 model.param_dict['logMmin'] = 12.78 model.param_dict['alpha'] = 1.14 model.param_dict['logM1'] = 13.99 model.param_dict['mean_occupation_satellites_assembias_param1'] = 0.0 halocat = CachedHaloCatalog(simname = 'bolplanck', redshift = 0, halo_finder = 'rockstar') model.populate_mock(halocat, enforce_PBC = True) pos = three_dim_pos_bundle(model.mock.galaxy_table, 'x', 'y', 'z') print("modelnumber density=" , len(pos)/halocat.Lbox**3.) print("data number density=" , 1.16*10**-3.) x = model.mock.galaxy_table['x'] y = model.mock.galaxy_table['y'] z = model.mock.galaxy_table['z'] vz = model.mock.galaxy_table['vz'] # applying RSD pos = return_xyz_formatted_array(x, y, z, velocity = vz, velocity_distortion_dimension = 'z') # enfprcing PBC pos = enforce_periodicity_of_box(pos, halocat.Lbox) tstart = time.time() t0 = tstart pos = pos.astype(np.float32) x, y, z = pos[:,0] , pos[:,1] , pos[:,2] t1 = time.time() print("Done reading the data - time taken = {0:10.1f} seconds" .format(t1 - t0)) print("Beginning Correlation functions calculations") boxsize = halocat.Lbox nthreads = 4 pimax = 40.0 binfile = path.join(path.dirname(path.abspath(__file__)), "../../", "bin") autocorr = 1 numbins_to_print = 12 print("\nRunning 2-D projected correlation function wp(rp)") results_wp = _countpairs.countpairs_wp(boxsize, pimax, nthreads, binfile, x, y, z) print("\n# ****** wp: first {0} bins ******* " .format(numbins_to_print)) print("# rmin rmax rpavg wp npairs") print("##########################################################") for ibin in range(numbins_to_print): items = results_wp[ibin] print("{0:12.4f} {1:12.4f} {2:10.4f} {3:10.1f} {4:10d}" .format(items[0], items[1], items[2], items[3], items[4])) print("-----------------------------------------------------------") data_wp = np.loadtxt("../../data/wpxi_dr72_bright0_mr21.0_z0.159_nj400")[:,1] print(data_wp.shape) data_wp_error = np.sqrt(np.diag(cov)[:12]) print(data_wp_error.shape) rbins = np.loadtxt(binfile) rs = np.mean(rbins , axis = 1) plt.figure(figsize=(10,10)) plt.errorbar(rs , data_wp , data_wp_error , fmt=".k" , capsize = 2) plt.plot(rs , np.array(results_wp)[:,3]) plt.loglog() plt.savefig("wp.pdf")
def main(): #cov = np.loadtxt("../../data/wpxicov_dr72_bright0_mr21.0_z0.159_nj400") #f_MD = (1. + 71.74*10**6. / (1000.)**3.) #f_bol = (1. + 71.74*10.**6. / (250.)**3.) #print("covariance correction factor=" , f_bol/f_MD) #cov = cov*f_bol/f_MD gmf_cat = np.loadtxt("gmf20.dat") data_gmf = gmf_cat[:,2] data_gmf_err = (gmf_cat[:,3]**2. + gmf_cat[:,4]**2.)**.5 data_gmf_bin = np.hstack([gmf_cat[:,0],gmf_cat[-1,1]]) print(data_gmf_bin) model.param_dict['logM0'] = 11.16 model.param_dict['sigma_logM'] = 0.61 model.param_dict['logMmin'] = 12.10 model.param_dict['alpha'] = 1.08 model.param_dict['logM1'] = 13.33 model.param_dict['mean_occupation_centrals_assembias_param1'] = -1. halocat = CachedHaloCatalog(simname = 'bolplanck', redshift = 0, halo_finder = 'rockstar') model.populate_mock(halocat) pos = three_dim_pos_bundle(model.mock.galaxy_table, 'x', 'y', 'z') print("modelnumber density=" , len(pos)/halocat.Lbox**3.) print("data number density=" , 1.16*10**-3.) x = model.mock.galaxy_table['x'] y = model.mock.galaxy_table['y'] z = model.mock.galaxy_table['z'] vz = model.mock.galaxy_table['vz'] # applying RSD pos = return_xyz_formatted_array(x, y, z, velocity = vz, velocity_distortion_dimension = 'z') # enfprcing PBC #pos = enforce_periodicity_of_box(pos, halocat.Lbox) from halotools.mock_observables import FoFGroups bperp = 0.14 bpar = 0.75 Lbox = np.array([halocat.Lbox,halocat.Lbox,halocat.Lbox]) period = Lbox groups = FoFGroups(pos, b_perp=bperp, b_para=bpar, Lbox = Lbox , period=Lbox) #model.mock.galaxy_table['fof_group_id'] = groups.group_ids #model.mock.galaxy_table.sort(['fof_group_id']) #from halotools.utils import group_member_generator #grouping_key = 'fof_group_id' #requested_columns = [] #group_gen = group_member_generator(model.mock.galaxy_table, grouping_key, requested_columns) #group_richness = np.zeros(len(model.mock.galaxy_table), dtype=int) #for first, last, member_props in group_gen: # group_richness[first:last] = last-first group_ids = groups.group_ids group_richness = richness(group_ids) gmf = np.histogram(np.array(group_richness) , data_gmf_bin)[0] / halocat.Lbox**3. chi = np.sum(((gmf - data_gmf)**2. / data_gmf_err**2.)[:-1]) print(chi/(len(gmf)-1)) bin_centers = 0.5 * (data_gmf_bin[1:] + data_gmf_bin[:-1]) plt.figure(figsize=(10,10)) plt.errorbar(bin_centers , data_gmf , data_gmf_err , fmt=".k" , capsize = 2) plt.plot(bin_centers , gmf) plt.yscale("log") plt.xlim([0,60]) plt.savefig("gmf.pdf")
lower_assembias_bound = 0, upper_assembias_bound = np.inf, **kwargs) cens_occ_model = Zheng07Cens(threshold = -21) cens_prof_model = TrivialPhaseSpace() from halotools.empirical_models import NFWPhaseSpace sats_occ_model = AssembiasZheng07Sats() sats_prof_model = NFWPhaseSpace() model_instance = HodModelFactory( centrals_occupation = cens_occ_model, centrals_profile = cens_prof_model, satellites_occupation = sats_occ_model, satellites_profile = sats_prof_model) model_instance.param_dict['mean_occupation_satellites_assembias_param1'] = -1. model_instance.populate_mock(simname = 'multidark') x = model_instance.mock.galaxy_table['x'] y = model_instance.mock.galaxy_table['y'] z = model_instance.mock.galaxy_table['z'] vz = model_instance.mock.galaxy_table['vz'] pos = return_xyz_formatted_array(x, y, z, velocity = vz, velocity_distortion_dimension = 'z')