Coverage for src/km3dq_common/detector_fact_classes.py: 0%
32 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-16 14:13 +0000
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-16 14:13 +0000
1#!/usr/bin/env python3
2import re
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 position=0,
22 status="",
23 upi=0,
24 site="",
25 det="",
26 time="",
27 following_run=0,
28 comment="",
29 waveform="",
30 emission_rate="",
31 documentation="",
32 author="")
34 def compute_utm_coord_from_detx(self):
35 if self.site == "ARCA":
36 self.coord_utm["x"] = self.coord_detx["x"] + 587600
37 self.coord_utm["y"] = self.coord_detx["y"] + 4016800
38 self.coord_utm["z"] = self.coord_detx["z"]
39 else:
40 self.coord_utm["x"] = self.coord_detx["x"] + 256500
41 self.coord_utm["y"] = self.coord_detx["y"] + 4743000
42 self.coord_utm["z"] = self.coord_detx["z"]
44 def compute_detx_coord_from_utm(self):
45 if self.site == "ARCA":
46 self.coord_detx["x"] = self.coord_utm["x"] - 587600
47 self.coord_detx["y"] = self.coord_utm["y"] - 4016800
48 self.coord_detx["z"] = self.coord_utm["z"]
49 else:
50 self.coord_detx["x"] = self.coord_utm["x"] - 256500
51 self.coord_detx["y"] = self.coord_utm["y"] - 4743000
52 self.coord_detx["z"] = self.coord_utm["z"]
54 def extract_coord_from_location(self):
55 r = re.search(
56 r"([du])\((-*\d+\.\d+)\,(-*\d+\.\d+)\,(-*\d+\.\d+)\)",
57 self.location
58 )
60 if r.group(1) == "d": # detx coordinates in detector fact file
61 self.coord_detx["x"] = float(r.group(2))
62 self.coord_detx["y"] = float(r.group(3))
63 self.coord_detx["z"] = float(r.group(4))
64 self.compute_utm_coord_from_detx()
65 elif r.group(1) == "u": # utm coordinates in detector fact file
66 self.coord_utm["x"] = float(r.group(2))
67 self.coord_utm["y"] = float(r.group(3))
68 self.coord_utm["z"] = float(r.group(4))
69 self.compute_detx_coord_from_utm()