def calc_all_observables(param): model.param_dict.update(dict(zip(param_names, param))) ##update model.param_dict with pairs (param_names:params) try: model.mock.populate() except: model.populate_mock(halocat) gc.collect() output = [] pos_gals_d = return_xyz_formatted_array(*(model.mock.galaxy_table[ax] for ax in 'xyz'), \ velocity=model.mock.galaxy_table['vz'], velocity_distortion_dimension='z',\ period=Lbox) ##redshift space distorted pos_gals_d = np.array(pos_gals_d,dtype=float) pos_gals = return_xyz_formatted_array(*(model.mock.galaxy_table[ax] for ax in 'xyz'), period=Lbox) pos_gals = np.array(pos_gals,dtype=float) ########one mock, different vpfcens and ptclposes. np.random.rand(num_sphere,3)*250, ptclpos particle_masses = halocat.particle_mass total_num_ptcls_in_snapshot = halocat.num_ptcl_per_dim**3 downsampling_factor = total_num_ptcls_in_snapshot/float(num_ptcls_to_use) vpf = void_prob_func(pos_gals_d, r_vpf, random_sphere_centers=vpf_centers, period=Lbox) ggl = delta_sigma(pos_gals, ptclpos, particle_masses=particle_masses, downsampling_factor=downsampling_factor,\ rp_bins=rp_bins_ggl, period=Lbox)[1]/1e12 ######## # parameter set output.append(param) return output
def voidprobfunc(rbins, n_ran, period, filename): global path if filename.endswith(".npy"): sample = np.load(os.path.join(path, filename)) vpf = void_prob_func(sample, rbins=rbins, n_ran=n_ran, period=period) np.save(os.path.join('/home/ajana/VPF/', 'vpf_' + str(filename)), (rbins.astype('float64'), vpf.astype('float64'))) else: raise TypeError("File should be in .npy format")
def voidprobfunc(rbins, n_ran, period, filename): global path if filename.endswith(".npy"): sample = np.load(os.path.join(path, filename)) vpf = void_prob_func(sample, rbins=rbins, n_ran=n_ran, period=period) np.save( os.path.join('/mnt/data4/Abhishek/fidmock/vpf', 'vpf_' + str(filename)), (rbins, vpf)) #np.save(os.path.join('/mnt/data4/Abhishek/VPF/random','vpf_'+str(filename)),(rbins.astype('float64'),vpf.astype('float64'))) else: raise TypeError("File should be in .npy format")
def calc_all_observables(param, seed=seed): model.param_dict.update(dict( zip(param_names, param))) ##update model.param_dict with pairs (param_names:params) try: model.mock.populate(seed=seed) except: model.populate_mock(halocat, seed=seed) gc.collect() output = [] pos_gals_d = return_xyz_formatted_array(*(model.mock.galaxy_table[ax] for ax in 'xyz'), \ velocity=model.mock.galaxy_table['vz'], velocity_distortion_dimension='z',\ period=Lbox) ##redshift space distorted pos_gals_d = np.array(pos_gals_d, dtype=float) pos_gals = return_xyz_formatted_array(*(model.mock.galaxy_table[ax] for ax in 'xyz'), period=Lbox) pos_gals = np.array(pos_gals, dtype=float) particle_masses = halocat.particle_mass total_num_ptcls_in_snapshot = halocat.num_ptcl_per_dim**3 downsampling_factor = total_num_ptcls_in_snapshot / float(num_ptcls_to_use) vpf = void_prob_func(pos_gals_d, r_vpf, random_sphere_centers=vpf_centers, period=Lbox) wprp = wp(pos_gals_d, r_wp, pi_max, period=Lbox) Pcic = np.bincount(counts_in_cylinders(pos_gals_d, pos_gals_d, proj_search_radius, \ cylinder_half_length, period=Lbox), minlength=100)[1:71]/float(pos_gals_d.shape[0]) Pcic_40 = np.add.reduceat(Pcic, sum_40) ggl = delta_sigma(pos_gals, ptclpos, particle_masses=particle_masses, downsampling_factor=downsampling_factor,\ rp_bins=rp_bins_ggl, period=Lbox)[1]/1e12 func = np.concatenate((np.array( (pos_gals_d.shape[0] / float(Lbox**3), )), wprp, ggl, vpf, Pcic_40)) output.append(func) # parameter set output.append(param) output.append(np.where(param - fid != 0)[0][0]) return output
def calc_all_observables(param): model.param_dict.update(dict( zip(param_names, param))) ##update model.param_dict with pairs (param_names:params) try: model.mock.populate() except: model.populate_mock(halocat) gc.collect() output = [] pos_gals_d = return_xyz_formatted_array(*(model.mock.galaxy_table[ax] for ax in 'xyz'), \ velocity=model.mock.galaxy_table['vz'], velocity_distortion_dimension='z',\ period=Lbox) ##redshift space distorted pos_gals_d = np.array(pos_gals_d, dtype=float) vpf = void_prob_func(pos_gals_d, r_vpf, random_sphere_centers=vpf_centers, period=Lbox) wprp = wp(pos_gals_d, r_wp, pi_max, period=Lbox) Pcic = np.bincount(counts_in_cylinders(pos_gals_d, pos_gals_d, proj_search_radius, \ cylinder_half_length,period=Lbox), minlength=100)[1:71]/float(pos_gals_d.shape[0]) func = np.concatenate((np.array( (pos_gals_d.shape[0] / float(Lbox**3), )), wprp, vpf, Pcic)) output.append(func) # parameter set output.append(param) output.append(np.where(param - median_w != 0)[0][0]) return output
def calc_vpf(i): vpf_centers = random_vpfcen(num_sphere) return void_prob_func(pos_gals_d, r_vpf, random_sphere_centers=vpf_centers, period=Lbox)