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

1#!/usr/bin/env python 

2 

3import argparse 

4import subprocess as sp 

5import os 

6 

7 

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 ] 

17 

18 

19def main(): 

20 parser = argparse.ArgumentParser(description="Offline AltAz DL1 maker") 

21 

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 ) 

31 

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 ) 

41 

42 args = parser.parse_args() 

43 

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) 

47 

48 if answer.returncode != 0: 

49 raise ChildProcessError(f"rta_fake_alt_az script failed when processing file {file}") 

50 

51 print("All files correctly processed.") 

52 

53 

54if __name__ == "__main__": 

55 main()