Fix overlap runs (#125)

* Update nb

* Update script

* Update script

* Rename

* Update script

* Update script

* Remove warning

* Ignore minors when extracting MAH

* Fix paths bug

* Move notebooks

* Move files

* Rename and delete things

* Rename file

* Move file

* Rename things

* Remove old print statement

* Add basic MAH plot

* Add random MAH path

* Output snapshot numbers

* Add MAH random extraction

* Fix redshift bug

* Edit script

* Add extracting random MAH

* Little updates

* Add CB2 redshift

* Add some caching

* Add diagnostic plots

* Add caching

* Minor updates

* Update nb

* Update notebook

* Update script

* Add Sorce randoms

* Add CB2 varysmall

* Update nb

* Update nb

* Update nb

* Use catalogue HMF

* Move definition of radec2galactic

* Update nb

* Update import

* Update import

* Add galatic coords to catalogues

* Update nb
This commit is contained in:
Richard Stiskalek 2024-04-08 11:23:21 +02:00 committed by GitHub
parent c71f5a8513
commit ee222cd010
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 1813 additions and 798 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,48 @@
# Copyright (C) 2024 Richard Stiskalek
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""Script to help with `hmf.py`."""
import csiborgtools
import numpy as np
from tqdm import tqdm
def calculate_hmf(simname, bin_edges, halofinder="FOF", max_distance=135):
"""
Calculate the halo mass function for a given simulation from catalogues.
"""
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
nsims = paths.get_ics(simname)
bounds = {"dist": (0, max_distance)}
hmf = np.full((len(nsims), len(bin_edges) - 1), np.nan)
volume = 4 / 3 * np.pi * max_distance**3
for i, nsim in enumerate(tqdm(nsims)):
if "csiborg2_" in simname:
kind = simname.split("_")[-1]
if halofinder == "FOF":
cat = csiborgtools.read.CSiBORG2Catalogue(
nsim, 99, kind, bounds=bounds)
elif halofinder == "SUBFIND":
cat = csiborgtools.read.CSiBORG2SUBFINDCatalogue(
nsim, 99, kind, kind, bounds=bounds)
else:
raise ValueError(f"Unknown halofinder: {halofinder}")
else:
raise ValueError(f"Unknown simname: {simname}")
hmf[i] = cat.halo_mass_function(bin_edges, volume, "totmass")[1]
return hmf

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long