Add MDPL2 HMF

This commit is contained in:
rstiskalek 2024-04-08 10:39:41 +01:00
parent ee222cd010
commit 096f2055c9
2 changed files with 44 additions and 23 deletions

File diff suppressed because one or more lines are too long

View file

@ -17,6 +17,7 @@
import csiborgtools
import numpy as np
from tqdm import tqdm
from h5py import File
def calculate_hmf(simname, bin_edges, halofinder="FOF", max_distance=135):
@ -46,3 +47,20 @@ def calculate_hmf(simname, bin_edges, halofinder="FOF", max_distance=135):
hmf[i] = cat.halo_mass_function(bin_edges, volume, "totmass")[1]
return hmf
def MDPL2_HMF(bin_edges):
"""MDPL2 FoF halo mass function."""
fname = "/mnt/extraspace/rstiskalek/catalogs/MDPL2_FOF_125.hdf5"
with File(fname, "r") as f:
mass = f["mass"][:]
dx = np.diff(np.log10(bin_edges))
if not np.all(np.isclose(dx, dx[0])):
raise ValueError("Bin edges must be logarithmically spaced.")
dx = dx[0]
hmf = csiborgtools.number_counts(mass, bin_edges)
hmf /= 1000**3 * dx
return hmf