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