Coverage for src/km3pipe/tests/test_hardware.py: 100%
349 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-08 03:14 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-08 03:14 +0000
1# Filename: test_hardware.py
2# pylint: disable=C0111,C0103,R0904
3"""
4Detector description (detx format v5)
6global_det_id ndoms
7dom_id line_id floor_id npmts
8 pmt_id_global x y z dx dy dz t0
9 pmt_id_global x y z dx dy dz t0
10 ...
11 pmt_id_global x y z dx dy dz t0
12dom_id line_id floor_id npmts
13 ...
15"""
17from copy import deepcopy
18from os.path import join, dirname
19from io import StringIO
21import numpy as np
23from km3pipe.testing import TestCase, data_path
24from km3pipe.hardware import Detector, PMT
25from km3pipe.math import qrot_yaw
27__author__ = "Tamas Gal"
28__copyright__ = "Copyright 2016, Tamas Gal and the KM3NeT collaboration."
29__credits__ = []
30__license__ = "MIT"
31__maintainer__ = "Tamas Gal"
32__email__ = "tgal@km3net.de"
33__status__ = "Development"
35EXAMPLE_DETX = StringIO(
36 "\n".join(
37 (
38 "1 3",
39 "1 1 1 3",
40 " 1 1.1 1.2 1.3 -1.1 0.2 0.3 10",
41 " 2 1.4 1.5 1.6 0.1 -1.2 0.3 20",
42 " 3 1.7 1.8 1.9 0.1 0.2 -1.3 30",
43 "2 1 2 3",
44 " 4 2.1 2.2 2.3 -1.1 0.2 0.3 40",
45 " 5 2.4 2.5 2.6 0.1 -1.2 0.3 50",
46 " 6 2.7 2.8 2.9 0.1 0.2 -1.3 60",
47 "3 1 3 3",
48 " 7 3.1 3.2 3.3 -1.1 0.2 0.3 70",
49 " 8 3.4 3.5 3.6 0.1 -1.2 0.3 80",
50 " 9 3.7 3.8 3.9 0.1 0.2 -1.3 90",
51 )
52 )
53)
55EXAMPLE_DETX_MIXED_IDS = StringIO(
56 "\n".join(
57 (
58 "1 3",
59 "8 1 1 3",
60 " 83 1.1 1.2 1.3 -1.1 0.2 0.3 10",
61 " 81 1.4 1.5 1.6 0.1 -1.2 0.3 20",
62 " 82 1.7 1.8 1.9 0.1 0.2 -1.3 30",
63 "7 1 2 3",
64 " 71 2.1 2.2 2.3 -1.1 0.2 0.3 40",
65 " 73 2.4 2.5 2.6 0.1 -1.2 0.3 50",
66 " 72 2.7 2.8 2.9 0.1 0.2 -1.3 60",
67 "6 1 3 3",
68 " 62 3.1 3.2 3.3 -1.1 0.2 0.3 70",
69 " 63 3.4 3.5 3.6 0.1 -1.2 0.3 80",
70 " 61 3.7 3.8 3.9 0.1 0.2 -1.3 90",
71 )
72 )
73)
75EXAMPLE_DETX_RADIAL = StringIO(
76 "\n".join(
77 (
78 "1 3",
79 "1 1 1 4",
80 " 1 1 0 0 1 0 0 10",
81 " 2 0 1 0 0 1 0 20",
82 " 3 -1 0 0 -1 0 0 30",
83 " 4 0 -1 0 0 -1 0 40",
84 "2 1 2 2",
85 " 5 0 0 1 0 0 1 50",
86 " 6 0 0 -1 0 0 -1 60",
87 "3 1 3 2",
88 " 7 1 2 3 1 2 3 70",
89 " 8 -3 -2 -1 -3 -2 -1 80",
90 "4 2 1 2",
91 " 9 0 0 1 0 0 1 90",
92 " 10 0 0 -1 0 0 -1 100",
93 )
94 )
95)
98class TestDetector(TestCase):
99 def setUp(self):
100 self.det = Detector()
101 self.det._det_file = EXAMPLE_DETX
103 def test_parse_header_extracts_correct_det_id(self):
104 self.det._parse_header()
105 self.assertEqual(1, self.det.det_id)
107 def test_parse_header_extracts_correct_n_doms(self):
108 self.det._parse_header()
109 self.assertEqual(3, self.det.n_doms)
111 def test_parse_doms_maps_each_dom_correctly(self):
112 self.det._parse()
113 expected = {1: (1, 1, 3), 2: (1, 2, 3), 3: (1, 3, 3)}
114 self.assertDictEqual(expected, self.det.doms)
116 def test_dom_ids(self):
117 self.det._parse()
118 self.assertEqual((1, 2, 3), tuple(self.det.dom_ids))
120 def test_parse_reset_cache(self):
121 self.det._parse()
122 assert not self.det._dom_positions
123 assert not self.det._pmt_angles
124 assert not self.det._xy_positions
125 self.det.dom_positions
126 self.det.pmt_angles
127 self.det.xy_positions
128 assert self.det._dom_positions
129 assert len(self.det._pmt_angles) == 3
130 assert len(self.det._xy_positions) == 1
131 self.det.reset_caches()
132 assert not self.det._dom_positions
133 assert not self.det._pmt_angles
134 assert not self.det._xy_positions
136 def test_parse_doms_maps_each_dom_correctly_for_mixed_pmt_ids(self):
137 self.det._det_file = EXAMPLE_DETX_MIXED_IDS
138 self.det._parse()
139 expected = {8: (1, 1, 3), 7: (1, 2, 3), 6: (1, 3, 3)}
140 self.assertDictEqual(expected, self.det.doms)
142 def test_dom_positions(self):
143 self.det._parse()
144 assert np.allclose(
145 [1.49992331, 1.51893187, 1.44185513], self.det.dom_positions[1]
146 )
147 assert np.allclose(
148 [2.49992331, 2.51893187, 2.44185513], self.det.dom_positions[2]
149 )
150 assert np.allclose(
151 [3.49992331, 3.51893187, 3.44185513], self.det.dom_positions[3]
152 )
154 def test_xy_positions(self):
155 self.det._parse()
156 assert len(self.det.xy_positions) == 1
157 assert np.allclose([1.49992331, 1.51893187], self.det.xy_positions[0])
159 def test_correct_number_of_pmts(self):
160 self.det._parse()
161 assert 9 == len(self.det.pmts)
163 def test_pmt_attributes(self):
164 self.det._parse()
165 assert (1, 2, 3, 4, 5, 6, 7, 8, 9) == tuple(self.det.pmts.pmt_id)
166 assert np.allclose(
167 [1.1, 1.4, 1.7, 2.1, 2.4, 2.7, 3.1, 3.4, 3.7], self.det.pmts.pos_x
168 )
169 assert np.allclose((1.7, 1.8, 1.9), self.det.pmts.pos[2])
170 assert np.allclose((0.1, 0.2, -1.3), self.det.pmts.dir[8])
172 def test_pmt_index_by_omkey(self):
173 self.det._parse()
174 assert 5 == self.det._pmt_index_by_omkey[(1, 2, 2)]
175 assert 0 == self.det._pmt_index_by_omkey[(1, 1, 0)]
176 assert 4 == self.det._pmt_index_by_omkey[(1, 2, 1)]
177 assert 1 == self.det._pmt_index_by_omkey[(1, 1, 1)]
179 def test_pmt_index_by_pmt_id(self):
180 self.det._parse()
181 assert 0 == self.det._pmt_index_by_pmt_id[1]
183 def test_pmt_with_id_returns_correct_omkeys(self):
184 self.det._parse()
185 pmt = self.det.pmt_with_id(1)
186 assert (1, 1, 0) == (pmt.du, pmt.floor, pmt.channel_id)
187 pmt = self.det.pmt_with_id(5)
188 assert (1, 2, 1) == (pmt.du, pmt.floor, pmt.channel_id)
190 def test_pmt_with_id_returns_correct_omkeys_with_mixed_pmt_ids(self):
191 self.det._det_file = EXAMPLE_DETX_MIXED_IDS
192 self.det._parse()
193 pmt = self.det.pmt_with_id(73)
194 assert (1, 2, 1) == (pmt.du, pmt.floor, pmt.channel_id)
195 pmt = self.det.pmt_with_id(81)
196 assert (1, 1, 1) == (pmt.du, pmt.floor, pmt.channel_id)
198 def test_pmt_with_id_raises_exception_for_invalid_id(self):
199 self.det._parse()
200 with self.assertRaises(KeyError):
201 self.det.pmt_with_id(100)
203 def test_get_pmt(self):
204 self.det._det_file = EXAMPLE_DETX_MIXED_IDS
205 self.det._parse()
206 pmt = self.det.get_pmt(7, 2)
207 assert (1, 2, 2) == (pmt.du, pmt.floor, pmt.channel_id)
209 def test_xy_pos(self):
210 self.det._parse()
211 xy = self.det.xy_positions
212 assert xy is not None
214 def test_ascii(self):
215 detx_string = "\n".join(
216 (
217 "1 3",
218 "1 1 1 3",
219 " 1 1.1 1.2 1.3 1.1 2.1 3.1 10.0",
220 " 2 1.4 1.5 1.6 4.1 5.1 6.1 20.0",
221 " 3 1.7 1.8 1.9 7.1 8.1 9.1 30.0",
222 "2 1 2 3",
223 " 4 2.1 2.2 2.3 1.2 2.2 3.2 40.0",
224 " 5 2.4 2.5 2.6 4.2 5.2 6.2 50.0",
225 " 6 2.7 2.8 2.9 7.2 8.2 9.2 60.0",
226 "3 1 3 3",
227 " 7 3.1 3.2 3.3 1.3 2.3 3.3 70.0",
228 " 8 3.4 3.5 3.6 4.3 5.3 6.3 80.0",
229 " 9 3.7 3.8 3.9 7.3 8.3 9.3 90.0\n",
230 )
231 )
232 detx_fob = StringIO(detx_string)
234 self.det = Detector()
235 self.det._det_file = detx_fob
236 self.det._parse()
237 assert detx_string == self.det.ascii
239 def test_ascii_with_mixed_dom_ids(self):
240 detx_string = "\n".join(
241 (
242 "1 3",
243 "8 1 1 3",
244 " 1 1.1 1.2 1.3 1.1 2.1 3.1 10.0",
245 " 2 1.4 1.5 1.6 4.1 5.1 6.1 20.0",
246 " 3 1.7 1.8 1.9 7.1 8.1 9.1 30.0",
247 "4 1 2 3",
248 " 4 2.1 2.2 2.3 1.2 2.2 3.2 40.0",
249 " 5 2.4 2.5 2.6 4.2 5.2 6.2 50.0",
250 " 6 2.7 2.8 2.9 7.2 8.2 9.2 60.0",
251 "9 1 3 3",
252 " 7 3.1 3.2 3.3 1.3 2.3 3.3 70.0",
253 " 8 3.4 3.5 3.6 4.3 5.3 6.3 80.0",
254 " 9 3.7 3.8 3.9 7.3 8.3 9.3 90.0\n",
255 )
256 )
257 detx_fobj = StringIO(detx_string)
259 self.det = Detector()
260 self.det._det_file = detx_fobj
261 self.det._parse()
262 assert detx_string == self.det.ascii
264 def test_init_from_string(self):
265 detx_string = "\n".join(
266 (
267 "1 3",
268 "8 1 1 3",
269 " 1 1.1 1.2 1.3 1.1 2.1 3.1 10.0",
270 " 2 1.4 1.5 1.6 4.1 5.1 6.1 20.0",
271 " 3 1.7 1.8 1.9 7.1 8.1 9.1 30.0",
272 "4 1 2 3",
273 " 4 2.1 2.2 2.3 1.2 2.2 3.2 40.0",
274 " 5 2.4 2.5 2.6 4.2 5.2 6.2 50.0",
275 " 6 2.7 2.8 2.9 7.2 8.2 9.2 60.0",
276 "9 1 3 3",
277 " 7 3.1 3.2 3.3 1.3 2.3 3.3 70.0",
278 " 8 3.4 3.5 3.6 4.3 5.3 6.3 80.0",
279 " 9 3.7 3.8 3.9 7.3 8.3 9.3 90.0\n",
280 )
281 )
282 det = Detector(string=detx_string)
283 assert 1 == det.n_dus
284 assert 3 == det.n_doms
286 def test_detx_format_version_1(self):
287 det = Detector(filename=data_path("detx/detx_v1.detx"))
288 assert 2 == det.n_dus
289 assert 6 == det.n_doms
290 assert 3 == det.n_pmts_per_dom
291 assert 1 == det.version
292 self.assertListEqual([1.1, 1.2, 1.3], list(det.pmts.pos[0]))
293 self.assertListEqual([3.4, 3.5, 3.6], list(det.pmts.pos[7]))
294 self.assertListEqual([23.4, 23.5, 23.6], list(det.pmts.pos[16]))
296 def test_detx_v1_is_the_same_ascii(self):
297 det = Detector(filename=data_path("detx/detx_v1.detx"))
298 with open(data_path("detx/detx_v1.detx"), "r") as fobj:
299 assert fobj.read() == det.ascii
301 def test_detx_format_version_2(self):
302 det = Detector(filename=data_path("detx/detx_v2.detx"))
303 assert 2 == det.n_dus
304 assert 6 == det.n_doms
305 assert 3 == det.n_pmts_per_dom
306 assert 256500.0 == det.utm_info.easting
307 assert 4743000.0 == det.utm_info.northing
308 assert "WGS84" == det.utm_info.ellipsoid
309 assert "32N" == det.utm_info.grid
310 assert -2425.0 == det.utm_info.z
311 assert 1500000000.1 == det.valid_from
312 assert 9999999999.0 == det.valid_until
313 assert 2 == det.version
314 self.assertListEqual([1.1, 1.2, 1.3], list(det.pmts.pos[0]))
315 self.assertListEqual([3.4, 3.5, 3.6], list(det.pmts.pos[7]))
316 self.assertListEqual([23.4, 23.5, 23.6], list(det.pmts.pos[16]))
318 def test_detx_v2_is_the_same_ascii(self):
319 det = Detector(filename=data_path("detx/detx_v2.detx"))
320 with open(data_path("detx/detx_v2.detx"), "r") as fobj:
321 assert fobj.read() == det.ascii
323 def test_detx_format_version_3(self):
324 det = Detector(filename=data_path("detx/detx_v3.detx"))
325 assert 2 == det.n_dus
326 assert 6 == det.n_doms
327 assert 3 == det.n_pmts_per_dom
328 assert 256500.0 == det.utm_info.easting
329 assert 4743000.0 == det.utm_info.northing
330 assert "WGS84" == det.utm_info.ellipsoid
331 assert "32N" == det.utm_info.grid
332 assert -2425.0 == det.utm_info.z
333 assert 1500000000.1 == det.valid_from
334 assert 9999999999.0 == det.valid_until
335 assert 3 == det.version
336 self.assertListEqual([1.1, 1.2, 1.3], list(det.pmts.pos[0]))
337 self.assertListEqual([3.4, 3.5, 3.6], list(det.pmts.pos[7]))
338 self.assertListEqual([23.4, 23.5, 23.6], list(det.pmts.pos[16]))
340 def test_detector_repr(self):
341 det = Detector(filename=data_path("detx/detx_v3.detx"))
342 assert "Detector id: '23', n_doms: 6, dus: [1, 2]" == repr(det)
344 def test_detx_format_version_3_with_whitespace(self):
345 det = Detector(filename=data_path("detx/detx_v3_whitespace.detx"))
346 assert 2 == det.n_dus
347 assert 6 == det.n_doms
348 assert 3 == det.n_pmts_per_dom
349 assert 256500.0 == det.utm_info.easting
350 assert 4743000.0 == det.utm_info.northing
351 assert "WGS84" == det.utm_info.ellipsoid
352 assert "32N" == det.utm_info.grid
353 assert -2425.0 == det.utm_info.z
354 assert 1500000000.1 == det.valid_from
355 assert 9999999999.0 == det.valid_until
356 assert 3 == det.version
357 self.assertListEqual([1.1, 1.2, 1.3], list(det.pmts.pos[0]))
358 self.assertListEqual([3.4, 3.5, 3.6], list(det.pmts.pos[7]))
359 self.assertListEqual([23.4, 23.5, 23.6], list(det.pmts.pos[16]))
361 def test_detx_format_comments(self):
362 det = Detector(filename=data_path("detx/detx_v1.detx"))
363 assert len(det.comments) == 0
365 det = Detector(filename=data_path("detx/detx_v2.detx"))
366 assert len(det.comments) == 0
368 det = Detector(filename=data_path("detx/detx_v3.detx"))
369 assert len(det.comments) == 2
370 assert " a comment line" == det.comments[0]
371 assert " another comment line starting with '#'" == det.comments[1]
373 def test_comments_are_written(self):
374 det = Detector(filename=data_path("detx/detx_v3.detx"))
375 det.add_comment("foo")
376 assert 3 == len(det.comments)
377 assert det.comments[2] == "foo"
378 assert "# foo" == det.ascii.splitlines()[2]
380 def test_detx_v3_is_the_same_ascii(self):
381 det = Detector(filename=data_path("detx/detx_v3.detx"))
382 with open(data_path("detx/detx_v3.detx"), "r") as fobj:
383 assert fobj.read() == det.ascii
385 def test_detx_v4(self):
386 det = Detector(filename=data_path("detx/detx_v4.detx"))
387 assert np.allclose(
388 [119.6, -12.2, 192.77], det.dom_positions[808956908], atol=1e-2
389 )
390 assert np.allclose(
391 [119.6, -12.2, 97.44], det.dom_positions[808981864], atol=1e-2
392 )
393 assert det.n_doms == 90
394 assert det.det_id == 44
395 assert det.n_pmts_per_dom == 31
396 assert det.n_dus == 5
397 assert np.allclose(
398 det.doms[808945480],
399 [
400 1,
401 5,
402 31,
403 86.500,
404 9.100,
405 66.821,
406 1.000000,
407 0.000000,
408 0.000000,
409 0.000000,
410 0.000,
411 ],
412 atol=1e-2,
413 )
414 assert np.allclose(
415 np.array(
416 [[86.5, 9.1], [86.6, 6.6], [109.6, 5.9], [97.8, -9.6], [119.6, -12.2]]
417 ),
418 det.xy_positions,
419 )
420 assert np.allclose(
421 [
422 3,
423 0.844,
424 0.449,
425 0.295,
426 808981864,
427 5,
428 8,
429 13367,
430 119.768,
431 -12.11,
432 97.5,
433 0,
434 207863.242,
435 ],
436 list(det.get_pmt(808981864, 3)),
437 )
439 def test_detx_v5(self):
440 det = Detector(filename=data_path("detx/detx_v5.detx"))
441 assert np.allclose(
442 [464.4, 564.7, 190.583], det.dom_positions[808956908], atol=1e-2
443 )
444 assert np.allclose(
445 [464.4, 564.7, 95.389], det.dom_positions[808981864], atol=1e-2
446 )
447 assert det.n_doms == 114
448 assert det.det_id == 49
449 assert det.n_pmts_per_dom == 31
450 assert det.n_dus == 6
451 assert np.allclose(
452 det.doms[808981864],
453 [
454 1.0000000e01,
455 8.0000000e00,
456 3.1000000e01,
457 4.6440000e02,
458 5.6470000e02,
459 9.5389000e01,
460 9.9995400e-01,
461 -7.8470000e-03,
462 3.9110000e-03,
463 4.0080000e-03,
464 0.0000000e00,
465 3.7861343e04,
466 ],
467 atol=1e-2,
468 )
469 assert np.allclose(
470 np.array(
471 [
472 [484.6, 564.65],
473 [464.4, 564.7],
474 [442.5, 567.45],
475 [474.15, 583.45],
476 [454.2, 583.0],
477 [431.1, 583.5],
478 ]
479 ),
480 det.xy_positions,
481 )
482 assert np.allclose(
483 [
484 3,
485 0.73205,
486 0.614161,
487 0.29479,
488 808981864,
489 10,
490 8,
491 13367,
492 464.546,
493 564.823,
494 95.448,
495 0,
496 207862.961,
497 ],
498 list(det.get_pmt(808981864, 3)),
499 )
502class TestDetectorTransformations(TestCase):
503 def setUp(self):
504 self.det = Detector()
505 self.det._det_file = EXAMPLE_DETX
507 def test_translate_detector(self):
508 self.det._parse()
509 t_vec = np.array([1, 2, 3])
510 orig_pos = self.det.pmts.pos.copy()
511 self.det.translate_detector(t_vec)
512 assert np.allclose(orig_pos + t_vec, self.det.pmts.pos)
514 def test_translate_detector_updates_xy_positions(self):
515 self.det._parse()
516 t_vec = np.array([1, 2, 3])
517 orig_xy_pos = self.det.xy_positions.copy()
518 self.det.translate_detector(t_vec)
519 assert np.allclose(orig_xy_pos + t_vec[:2], self.det.xy_positions)
521 def test_translate_detector_updates_dom_positions(self):
522 self.det._parse()
523 t_vec = np.array([1, 2, 3])
524 orig_dom_pos = deepcopy(self.det.dom_positions)
525 self.det.translate_detector(t_vec)
526 for dom_id, pos in self.det.dom_positions.items():
527 assert np.allclose(orig_dom_pos[dom_id] + t_vec, pos)
529 def test_rotate_dom_by_yaw(self):
530 det = Detector()
531 det._det_file = EXAMPLE_DETX_RADIAL
532 det._parse()
533 # here, only one PMT is checked
534 dom_id = 1
535 heading = 23
536 channel_id = 0
537 pmt_dir = det.pmts[det.pmts.dom_id == dom_id].dir[channel_id].copy()
538 pmt_dir_rot = qrot_yaw(pmt_dir, heading)
539 det.rotate_dom_by_yaw(dom_id, heading)
540 assert np.allclose(
541 pmt_dir_rot, det.pmts[det.pmts.dom_id == dom_id].dir[channel_id]
542 )
543 assert np.allclose(
544 [0.92050485, 0.39073113, 0],
545 det.pmts[det.pmts.dom_id == dom_id].pos[channel_id],
546 )
548 def test_rotate_dom_set_by_step_by_360_degrees(self):
549 det = Detector()
550 det._det_file = EXAMPLE_DETX_RADIAL
551 det._parse()
552 dom_id = 1
553 channel_id = 0
554 pmt_dir = det.pmts[det.pmts.dom_id == dom_id].dir[channel_id].copy()
555 pmt_pos = det.pmts[det.pmts.dom_id == dom_id].pos[channel_id].copy()
556 for i in range(36):
557 det.rotate_dom_by_yaw(dom_id, 10)
558 pmt_dir_rot = det.pmts[det.pmts.dom_id == dom_id].dir[channel_id]
559 assert np.allclose(pmt_dir, pmt_dir_rot)
560 pmt_pos_rot = det.pmts[det.pmts.dom_id == dom_id].pos[channel_id]
561 assert np.allclose(pmt_pos, pmt_pos_rot)
563 def test_rotate_du_by_yaw_step_by_step_360_degrees(self):
564 det = Detector()
565 det._det_file = EXAMPLE_DETX_RADIAL
566 det._parse()
567 du = 2
568 pmt_dir = det.pmts[det.pmts.du == du].dir.copy()
569 pmt_pos = det.pmts[det.pmts.du == du].pos.copy()
570 pmt_dir_other_dus = det.pmts[det.pmts.du != du].dir.copy()
571 pmt_pos_other_dus = det.pmts[det.pmts.du != du].pos.copy()
572 for i in range(36):
573 det.rotate_du_by_yaw(du, 10)
574 pmt_dir_rot = det.pmts[det.pmts.du == du].dir
575 pmt_pos_rot = det.pmts[det.pmts.du == du].pos
576 assert np.allclose(pmt_dir, pmt_dir_rot)
577 assert np.allclose(pmt_pos, pmt_pos_rot)
578 assert np.allclose(pmt_dir_other_dus, det.pmts[det.pmts.du != du].dir)
579 assert np.allclose(pmt_pos_other_dus, det.pmts[det.pmts.du != du].pos)
581 def test_rescale_detector(self):
582 self.det._parse()
583 dom_positions = deepcopy(self.det.dom_positions)
584 scale_factor = 2
585 self.det.rescale(scale_factor)
586 for dom_id, dom_pos in self.det.dom_positions.items():
587 assert np.allclose(dom_pos, dom_positions[dom_id] * scale_factor)
589 def test_dom_table(self):
590 self.det._parse()
591 dt = self.det.dom_table
592 assert 3 == len(dt)
593 assert np.allclose([1, 2, 3], dt.dom_id)
594 assert np.allclose([1, 1, 1], dt.du)
595 assert np.allclose([1, 2, 3], dt.floor)
596 assert np.allclose([1.49992331, 2.49992331, 3.49992331], dt.pos_x)
597 assert np.allclose([1.51893187, 2.51893187, 3.51893187], dt.pos_y)
598 assert np.allclose([1.44185513, 2.44185513, 3.44185513], dt.pos_z)
600 def test_dom_table_with_another_detx(self):
601 det = Detector()
602 det._det_file = EXAMPLE_DETX_RADIAL
603 det._parse()
605 dt = det.dom_table
606 assert 4 == len(dt)
607 assert np.allclose([1, 2, 3, 4], dt.dom_id)
608 assert np.allclose([1, 1, 1, 2], dt.du)
609 assert np.allclose([1, 2, 3, 1], dt.floor)
610 assert np.allclose([0, 0, 0, 0], dt.pos_x)
611 assert np.allclose([0, 0, 0, 0], dt.pos_y)
612 assert np.allclose([0, 0, 0, 0], dt.pos_z)
614 def test_center_of_mass(self):
615 det = Detector()
616 det._det_file = EXAMPLE_DETX
617 det._parse()
619 assert np.allclose([2.4, 2.5, 2.6], det.com)
621 def test_center_of_mass_with_another_detx(self):
622 det = Detector()
623 det._det_file = EXAMPLE_DETX_RADIAL
624 det._parse()
626 assert np.allclose([-0.2, 0.0, 0.2], det.com)
628 def test_jdetectordb_output_with_detx_v3(self):
629 det = Detector(
630 data_path("detx/D_ORCA006_t.A02181836.p.A02181837.r.A02182001.detx")
631 )
632 assert det.utm_info is not None
633 assert det.utm_info.ellipsoid == "WGS84"
634 assert det.utm_info.grid == "32N"
635 assert det.utm_info.easting == 256500.0
636 assert det.utm_info.northing == 4743000.0
637 assert det.utm_info.z == -2440.0