""" #import dependencies import numpy as np import MAS_library as MASL import sys, os, h5py, time import units_library as UL import matplotlib.pyplot as plt import h5py dims = 2048 MAS = 'CIC' #import illustris_python as il delta = np.zeros((dims, dims, dims), dtype=np.float32) U = UL.units() rho_crit = U.rho_crit #h^2 Msun/Mpc^3 # read header FILE_TYPE = '/hydro/' #or subhalos #TODO: Before this, cp from fof_files into a new folder made @ ../dat/illustris_tng/hydro/groupcat/groups_099 # Once done, you can use TNG's illustris-python code to read in this data for hod computation root = '../dat/illustris_tng/' + FILE_TYPE + 'groupcat/groups_099/' basePath = '../dat/illustris_tng' + FILE_TYPE + 'groupcat' # /scratch/gpfs/nk11/dm2gal/dat/illustris-data/hydrosim # this part you'll need to download. #sys.path.append("/home/nk11") sys.path.append('/scratch/nsk367/pytorch-use/research')
from mpi4py import MPI import numpy as np import snapshot as sn import readsnapHDF5 as rs import units_library as UL import HI_library as HIL import sys,os,glob,h5py import groupcat ####### MPI DEFINITIONS ####### comm = MPI.COMM_WORLD nprocs = comm.Get_size() myrank = comm.Get_rank() U = UL.units(); rho_crit = U.rho_crit #h^2 Msun/Mpc^3 TREECOOL_file = '/n/home09/fvillaescusa/Illustris/HI/TREECOOL_fg_dec11' ################################ INPUT ######################################## run = '/n/hernquistfs3/IllustrisTNG/Runs/L75n1820TNG' fout = 'M_HI_new_75_1820.txt' snaps = np.array([17, 21, 25, 33, 50, 99]) ############################################################################### # find offset_root and snapshot_root snapshot_root = '%s/output/'%run # find the numbers each cpu will work on array = np.arange(0, len(snaps)) numbers = np.where(array%nprocs==myrank)[0] numbers = snaps[numbers]
import numpy as np import MAS_library as MASL import sys,os,h5py,time import units_library as UL import HI_library as HIL U = UL.units(); rho_crit = U.rho_crit #h^2 Msun/Mpc^3 ################################ INPUT ######################################## snapnums = np.array([85, 68, 60]) runs = ['/simons/scratch/sgenel/Illustris_IllustrisTNG_public_data_release/L75n1820FP'] fouts = ['Illustris100-1_matter'] dims = 2048 MAS = 'CIC' ############################################################################## for fout,run in zip(fouts,runs): # find whether it is an N-body or an hydro sims if run[-2:]=='DM': Nbody = True else: Nbody = False # do a loop over the different redshifts for snapnum in snapnums: # define the array hosting delta_HI and delta_m delta_m = np.zeros((dims,dims,dims), dtype=np.float32) # read header snapshot = '%s/output/snapdir_%03d/snap_%03d'%(run,snapnum, snapnum)
f.close() density = np.zeros((dims,dims), dtype=np.float64) pos2D = np.ascontiguousarray(pos[:,0:2]) if component=='HI': MASL.voronoi_RT_2D(density, pos2D, M_HI, radii, x_min, y_min, 0, 1, x_max-x_min, False) if component in ['gas','CDM']: MASL.voronoi_RT_2D(density, pos2D, mass, radii, x_min, y_min, 0, 1, x_max-x_min, False) # convert (Msun/h)/(Mpc/h)^2 to cm^{-2} factor = h*(1.0+redshift)**2*\ (UL.units().Msun_g)/(UL.units().mH_g)/(UL.units().Mpc_cm)**2 ####### CAUTION!!!! ######## #factor/=(1.0+redshift)**2 ########################### density *= factor # save density field to file f = h5py.File(fout_df, 'w') f.create_dataset('df', data=density) f.close()
import numpy as np import sys,os import mass_function_library as MFL import units_library as UL import integration_library as IL ############################ CONSTANTS ############################ pi = np.pi rho_crit = (UL.units()).rho_crit #h^2 Msun/Mpc^3 deltac = 1.686 ################################################################### ############################################################################## # This functions computes the halo bias, b(M), in a set of different halo masses # k_in --------> input k # Pk_in -------> input Pk # OmegaM ------> value of Omega_m # Masses ------> array with the halo masses where to evaluate the halo bias # author ------> SMT01', 'Tinker' def bias(k_in, Pk_in, OmegaM, Masses, author, bins=10000): rhoM = rho_crit*OmegaM # sort the input k-array indexes = np.argsort(k_in) k_in = k_in[indexes]; Pk_in = Pk_in[indexes] # interpolate the input k-array into bins points k = np.logspace(np.log10(k_in[0]), np.log10(k_in[-1]), bins) Pk = np.interp(np.log(k), np.log(k_in), Pk_in)
# This routine returns the circular velocity of a halo of mass M at redshift z def Vcirc(M,z,Omega_m,Omega_l): x = Omega_m*(1.0+z)**3/(Omega_m*(1.0+z)**3 + Omega_l) - 1.0 delta_c = 18*np.pi**2 + 82.0*x - 39.0*x**2 rho_crit_z = rho_crit*(Omega_m*(1.0+z)**3 + Omega_l) Hz = 100.0*np.sqrt(Omega_m*(1.0+z)**3 + Omega_l) #km/s/(Mpc/h) R = ((3.0*M)/(4.0*np.pi*delta_c*rho_crit_z))**(1.0/3.0) #Mpc/h V = np.sqrt(0.5*Hz**2*delta_c*R**2) return V rho_crit = UL.units().rho_crit ############################### INPUT ####################################### Omega_m = 0.3089 Omega_l = 1.0-Omega_m threshold = 0.98 #find Mmin such as lighter halos only host 1-threshold % of HI ############################################################################# for z in [0.000, 0.997, 2.002, 3.008, 4.008, 4.996]: f = h5py.File('M_HI_new_75_1820_z=%.3f.hdf5'%z, 'r') M_HI = f['M_HI'][:] M = f['Mass'][:] R = f['R'][:] f.close()
# This scripts computes the value of Omega_HI and HI shot-noise # assuming a M_HI(M) = M_0*(M/Mmin)^alpha*exp(-Mmin/M) # P_SN = 1/(rho_c^0*Omega_HI)^2*\int_0^oo n(M)*M_HI(M)^2dM # Omega_HI = 1/rho_c^0*\int_0^oo n(M)*M_HI(M) dM import numpy as np import sys, os import mass_function_library as MFL import units_library as UL import integration_library as IL rho_crit = UL.units().rho_crit ################################# INPUT ###################################### # input Pk at wanted MF redshift. For neutrinos use CDM+B Pk f_Pk = '../../CAMB/illustris_matterpower_z=0.dat' bins_k = 10000 #number of bins to use in the input Pk # For neutrinos use Omega_{CDM+B} instead of Omega_m Omega_m = 0.3089 M_min = 1e8 #Msun/h M_max = 1e16 #Msun/h bins_MF = 800 #number of bins in the HMF author = 'ST' f_out = 'ST_MF_z=0.dat' # optional arguments z = 0.0 # only for 'Tinker', 'Tinker10' and Crocce delta = 200 # only for 'Tinker' and 'Tinker10' # M_HI parameters (M0 only needed for Omega_HI, not P_SN) alpha, M0, Mmin = 0.63, 4.7e8, 2.2e10 #z=0
import numpy as np import sys, os import mass_function_library as MFL import units_library as UL import integration_library as IL ############################ CONSTANTS ############################ pi = np.pi rho_crit = (UL.units()).rho_crit #h^2 Msun/Mpc^3 deltac = 1.686 ################################################################### ############################################################################## # This functions computes the halo bias, b(M), in a set of different halo masses # k_in --------> input k # Pk_in -------> input Pk # OmegaM ------> value of Omega_m # Masses ------> array with the halo masses where to evaluate the halo bias # author ------> SMT01', 'Tinker' def bias(k_in, Pk_in, OmegaM, Masses, author, bins=10000): rhoM = rho_crit * OmegaM # sort the input k-array indexes = np.argsort(k_in) k_in = k_in[indexes] Pk_in = Pk_in[indexes] # interpolate the input k-array into bins points
import numpy as np import readsnap import redshift_space_library as RSL import MAS_library as MASL import units_library as UL import Pk_library as PKL import sys,os ########### routines ############ # Pk_comp(snapshot_fname,ptype,dims,do_RSD,axis,cpus) # Pk_Gadget(snapshot_fname,dims,particle_type,do_RSD,axis,cpus) ################################# U = UL.units(); rho_crit = U.rho_crit # dictionary for files name name_dict = {'0' :'GAS', '01':'GCDM', '02':'GNU', '04':'Gstars', '1' :'CDM', '12':'CDMNU', '14':'CDMStars', '2' :'NU', '24':'NUStars', '4' :'Stars', '-1':'matter'} ############################################################################### # This routine computes the power spectrum of either a single species or of all # species from a Gadget routine # snapshot_fname -----------> name of the Gadget snapshot # ptype --------------------> scalar: 0-GAS, 1-CDM, 2-NU, 4-Stars, -1:ALL # dims ---------------------> Total number of cells is dims^3 to compute Pk # do_RSD -------------------> Pk in redshift-space (True) or real-space (False) # axis ---------------------> axis along which move particles in redshift-space
import numpy as np import sys, os, h5py import Pk_library as PKL import units_library as UL rho_crit = UL.units().rho_crit #critical density of the Universe at z=0 ##################################### INPUT ############################################# prefixes = ['TNG100', 'TNG100DM', 'TNG300', 'TNG300DM'] BoxSizes = [75.0, 75.0, 205.0, 205.0] #Mpc/h redshifts = [0.0, 0.2, 0.4, 0.7, 1.0, 1.5, 2.0, 3.0, 4.0] axis = 0 #axis along which RSD are placed (no matter in our case) MAS = 'CIC' threads = 48 #openmp threads ######################################################################################### # do a loop over the different simulations for prefix, BoxSize in zip(prefixes, BoxSizes): # do a loop over the different redshifts for z in redshifts[::-1]: # find the name of the output file fout = 'Pk_%s_z=%.1f.txt' % (prefix, z) if os.path.exists(fout): continue # read the file containing the mass per voxel fin = '%s_z=%.1f.hdf5' % (prefix, z) f = h5py.File(fin, 'r') delta = f['density'][:] f.close()