Coverage for src/km3dq_common/detector_fact_classes.py: 0%

34 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-14 11:06 +0000

1#!/usr/bin/env python3 

2import re 

3 

4 

5############################################################################### 

6class DetectorFact(dict): 

7 """ 

8 Detector fact classes inheriting from a dict 

9 https://realpython.com/inherit-python-dict/ 

10 """ 

11 def __init__(self): 

12 dict.__init__(self, 

13 hardware="", 

14 location="", 

15 coord_detx={"x":0., 

16 "y":0., 

17 "z":0.}, 

18 coord_utm={"x":0., 

19 "y":0., 

20 "z":0.}, 

21 accuracy="", 

22 position=0, 

23 status="", 

24 upi=0, 

25 site="", 

26 det="", 

27 time="", 

28 following_run=0, 

29 comment="", 

30 waveform="", 

31 emission_rate="", 

32 documentation="", 

33 author="") 

34 

35 def compute_utm_coord_from_detx(self): 

36 if self.site == "ARCA": 

37 self.coord_utm["x"] = self.coord_detx["x"] + 587600 

38 self.coord_utm["y"] = self.coord_detx["y"] + 4016800 

39 self.coord_utm["z"] = self.coord_detx["z"] 

40 else: 

41 self.coord_utm["x"] = self.coord_detx["x"] + 256500 

42 self.coord_utm["y"] = self.coord_detx["y"] + 4743000 

43 self.coord_utm["z"] = self.coord_detx["z"] 

44 

45 def compute_detx_coord_from_utm(self): 

46 if self.site == "ARCA": 

47 self.coord_detx["x"] = self.coord_utm["x"] - 587600 

48 self.coord_detx["y"] = self.coord_utm["y"] - 4016800 

49 self.coord_detx["z"] = self.coord_utm["z"] 

50 else: 

51 self.coord_detx["x"] = self.coord_utm["x"] - 256500 

52 self.coord_detx["y"] = self.coord_utm["y"] - 4743000 

53 self.coord_detx["z"] = self.coord_utm["z"] 

54 

55 def extract_coord_from_location(self): 

56 r = re.search( 

57 r"([du])\((-*\d+\.\d+)\,(-*\d+\.\d+)\,(-*\d+\.\d+)\)([cdenu])", 

58 self.location 

59 ) 

60 

61 if r.group(1) == "d": # detx coordinates in detector fact file 

62 self.coord_detx["x"] = float(r.group(2)) 

63 self.coord_detx["y"] = float(r.group(3)) 

64 self.coord_detx["z"] = float(r.group(4)) 

65 self.compute_utm_coord_from_detx() 

66 elif r.group(1) == "u": # utm coordinates in detector fact file 

67 self.coord_utm["x"] = float(r.group(2)) 

68 self.coord_utm["y"] = float(r.group(3)) 

69 self.coord_utm["z"] = float(r.group(4)) 

70 self.compute_detx_coord_from_utm() 

71 

72 dict_accuracy = { 

73 "c": "calibration", 

74 "d": "detx file", 

75 "e": "exail", 

76 "n": "nominal", 

77 "u": "unknown" 

78 } 

79 self.accuracy = dict_accuracy[r.group(5)]