Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python3
3import os
4from argparse import ArgumentParser, RawDescriptionHelpFormatter
5from glob import glob
6from llama.dev.background.pvalue import __doc__
8OUTFILE = 'populations.hdf5'
11def get_parser():
12 """Get CLI parser."""
13 parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
14 description=__doc__.replace(".. code:\n\n", ""))
15 parser.add_argument("-c", "--clobber", action="store_true", help=f"""
16 Overwrite "./{OUTFILE}" if it already exists. Will not overwrite by
17 default.""")
18 return parser
21def main():
22 """Run CLI."""
23 import h5py
24 import pandas
25 import numpy as np
26 parser = get_parser()
27 args = parser.parse_args()
28 tables = glob('*.txt')
29 if os.path.isfile(OUTFILE) and not args.clobber:
30 print(f"{OUTFILE} already exists, not overwriting; QUITTING.")
31 exit(1)
32 with h5py.File(OUTFILE, 'w') as outfile:
33 for table in tables:
34 path = table.split('.')[0].replace('-', '/')
35 dfrm = pandas.read_csv(table, skiprows=(1,), delim_whitespace=True)
36 # not worth using compression here; savings minimal. method here:
37 # http://docs.h5py.org/en/stable/high/dataset.html#filter-pipeline
38 outfile[path] = np.sort(dfrm['EVENT-ODDS-RATIO'], kind='heapsort')
41if __name__ == "__main__":
42 main()