-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconvert_ctrees_to_h5
More file actions
executable file
·66 lines (61 loc) · 3.09 KB
/
Copy pathconvert_ctrees_to_h5
File metadata and controls
executable file
·66 lines (61 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
from uchuutools import convert_ctrees_to_h5
import argparse
helpmsg = "\nUsage Scenario 1:\n"
helpmsg += "-----------------\n"
helpmsg += "If you are converting the output of the standard "\
"Consistent-Trees code, then \nplease provide the "\
"full-path to the 'forests.list' and 'locations.dat'"\
"(order is unimportant).\n\n"
helpmsg += "Usage Scenario 2:\n"
helpmsg += "-----------------\n"
helpmsg += "If you are converting the output of the parallel "\
"Consistent-Trees code \nfrom the Uchuu collaboration, "\
"then please provide all the tree filenames \nthat "\
"you would like to convert (i.e., files ending with "\
"'<prefix>.tree').\nThe names for relevant "\
"'forests.list (<prefix>.forest)' and \n"\
"'locations.dat (<prefix>.loc)' will be "\
"automatically constructed.\n\n"
descr = "Convert ascii Consistent-Trees files into hdf5 "\
"(optionally in MPI parallel)"
parser = argparse.ArgumentParser(description=descr)
parser.add_argument('outputdir', metavar='<output directory>', type=str,
help='the output directory for the hdf5 file(s)')
parser.add_argument("filenames", metavar="<CTrees filenames>",
type=str, nargs='+',
help="list of input (ascii) Consistent-Trees filenames")
prog_group = parser.add_mutually_exclusive_group()
prog_group.add_argument("-p", "--progressbar", dest='show_progressbar',
action="store_true", default=True,
help="display a progressbar on rank=0")
prog_group.add_argument("-np", "--no-progressbar", dest='show_progressbar',
action='store_false', help="disable the progressbar")
# Do you want to write each halo as a struct (i.e., ALL the
# properties of any given halo are written together, array of structures),
# or do you want to write out individual datasets for each of the
# halo properties (i.e., any given property of ALL halos are written
# together, structure of arrays -> default)
# write_halo_props_cont = True # True -> structure of arrays,
# # False-> array of structures
dset_group = parser.add_mutually_exclusive_group()
dset_group.add_argument("-m", "--multiple-dsets", dest='write_halo_props_cont',
action="store_true", default=True,
help="write a separate dataset for each halo property")
dset_group.add_argument("-s", "--single-dset", dest='write_halo_props_cont',
action="store_false", default=False,
help="write a single dataset containing all halo "
"properties")
try:
args = parser.parse_args()
except SystemExit as e:
print(helpmsg)
raise e
try:
from mpi4py import MPI
comm = MPI.COMM_WORLD
except ImportError:
comm = None
convert_ctrees_to_h5(args.filenames, outputdir=args.outputdir,
write_halo_props_cont=args.write_halo_props_cont,
comm=comm, show_progressbar=args.show_progressbar)