Coverage for hiperta_stream/scripts/offline_alt_az_dl1_maker_directory.py: 0%
18 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-07-16 10:16 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-07-16 10:16 +0000
1#!/usr/bin/env python
3import argparse
4import subprocess as sp
5import os
8def get_input_h5_filelist(data_path):
9 """Get list of h5 files inside the directory `data_path`"""
10 return [
11 os.path.abspath(os.path.join(data_path, f))
12 for f in os.listdir(data_path)
13 if os.path.isfile(os.path.join(data_path, f))
14 and os.path.join(data_path, f).endswith(".h5")
15 and "LST-1" in os.path.join(data_path, f)
16 ]
19def main():
20 parser = argparse.ArgumentParser(description="Offline AltAz DL1 maker")
22 parser.add_argument(
23 "--input-dl1-directory",
24 "-i",
25 type=str,
26 dest="input_dl1_dir",
27 help="Path to directory containing r0-hdf5 files to be analysed.",
28 default=None,
29 required=True,
30 )
32 parser.add_argument(
33 "--drive-log",
34 "-d",
35 type=str,
36 dest="drive_log",
37 help="Path to log drive, "
38 'example : "/fefs/aswg/data/real/monitoring/DrivePositioning/drive_log_21_07_08.txt"',
39 required=True,
40 )
42 args = parser.parse_args()
44 for file in get_input_h5_filelist(args.input_dl1_dir):
45 run_cmd = ["rta_fake_alt_az", "-f", f"{file}", "-d", f"{args.drive_log}"]
46 answer = sp.run(run_cmd)
48 if answer.returncode != 0:
49 raise ChildProcessError(f"rta_fake_alt_az script failed when processing file {file}")
51 print("All files correctly processed.")
54if __name__ == "__main__":
55 main()