def Pk_binning(fin, BoxSize, grid): # read input file k_in, Pk_in = np.loadtxt(fin, dtype=np.float32, unpack=True) # compute expected Pk k, Pk, Nmodes = PKL.expected_Pk(k_in, Pk_in, BoxSize, grid) Pk = np.asarray(Pk) Nmodes = np.asarray(Nmodes) return k, Pk, Nmodes
import numpy as np import Pk_library as PKL import sys,os #################################### INPUT ########################################### BoxSize = 512.0 #Mpc/h grid = 1024 fin = '../../param_files/0.15eV/reps_files/0.15eV_Pm_rescaled_z127.0000.txt' fout = 'Pk_binned_CLASS_0.15eV_matter_z=127.txt' #fin = '../../param_files/0.15eV/reps_files/0.15eV_Pcb_rescaled_z127.0000.txt' #fout = 'Pk_binned_CLASS_0.15eV_cb_z=127.txt' #fin = '../../param_files/0.15eV/reps_files/0.15eV_Pn_rescaled_z127.0000.txt' #fout = 'Pk_binned_CLASS_0.15eV_n_z=127.txt' ###################################################################################### # read Pk k, Pk = np.loadtxt(fin, unpack=True) k = k.astype(np.float32) Pk = Pk.astype(np.float32) # compute binned Pk and save results to file k, Pk, Nmodes = PKL.expected_Pk(k, Pk, BoxSize, grid) np.savetxt(fout, np.transpose([k, Pk]))
############################################# BoxSize = 1000.0 #Mpc/h dims = 1024 ############################################################################# if obj_type == 'Pk': # do a loop over the different input files for input_file, f_out in zip(input_files, f_outs): # read input file k_in, Pk_in = np.loadtxt(input_file, dtype=np.float32, unpack=True) # compute expected Pk k, Pk, Nmodes = PKL.expected_Pk(k_in, Pk_in, BoxSize, dims) # save results to file ignoring DC mode np.savetxt(f_out, np.transpose([k, Pk, Nmodes])) # WARNING!!!! This is still the old version # UPDATE!!!!! elif obj_type == 'CF': # compute the value of |k| in each cell of the grid [array, k] = PSL.CIC_correction(dims) del array bins_CF = dims / 2 + 1 # compute the value of r in each point of the grid