mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-05-20 17:41:13 +00:00
Fix PHEW empty clumps
This commit is contained in:
parent
b49d9852ff
commit
ed554cc877
2 changed files with 16 additions and 7 deletions
|
@ -16,7 +16,7 @@
|
|||
Functions to read in the particle and clump files.
|
||||
"""
|
||||
from abc import ABC, abstractmethod
|
||||
from os.path import isfile, join
|
||||
from os.path import isfile, join, getsize
|
||||
from warnings import warn
|
||||
|
||||
import numpy
|
||||
|
@ -329,10 +329,15 @@ class CSiBORGReader(BaseReader):
|
|||
fname = join(self.paths.snapshots(nsim, "csiborg", tonew=False),
|
||||
"output_{}".format(nsnap),
|
||||
"clump_{}.dat".format(nsnap))
|
||||
if not isfile(fname):
|
||||
raise FileExistsError("Clump file `{}` does not exist."
|
||||
.format(fname))
|
||||
|
||||
if not isfile(fname) or getsize(fname) == 0:
|
||||
raise FileExistsError(f"Clump file `{fname}` does not exist.")
|
||||
|
||||
data = numpy.genfromtxt(fname)
|
||||
|
||||
if data.ndim == 1:
|
||||
raise FileExistsError(f"Invalid clump file `{fname}`.")
|
||||
|
||||
# How the data is stored in the clump file.
|
||||
clump_cols = {"index": (0, numpy.int32),
|
||||
"level": (1, numpy.int32),
|
||||
|
|
|
@ -327,8 +327,12 @@ def make_phew_halo_catalogue(nsim, find_ultimate_parent, verbose):
|
|||
f.close()
|
||||
|
||||
for nsnap in tqdm(snapshots, disable=not verbose, desc="Snapshot"):
|
||||
data = reader.read_phew_clumps(nsnap, nsim, find_ultimate_parent=False,
|
||||
verbose=False)
|
||||
try:
|
||||
data = reader.read_phew_clumps(
|
||||
nsnap, nsim, find_ultimate_parent=find_ultimate_parent,
|
||||
verbose=False)
|
||||
except FileExistsError:
|
||||
continue
|
||||
|
||||
with h5py.File(fname, "r+") as f:
|
||||
grp = f.create_group(str(nsnap))
|
||||
|
@ -364,7 +368,7 @@ def main(nsim, args):
|
|||
calculate_initial(nsim, args.simname, args.halofinder, True)
|
||||
|
||||
if args.make_phew:
|
||||
make_phew_halo_catalogue(nsim, True, True)
|
||||
make_phew_halo_catalogue(nsim, False, True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue