Skip to content

Commit 14a43b1

Browse files
committed
relax check for subarrays
1 parent 2714e6b commit 14a43b1

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

dl1_data_handler/reader.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ class DLDataReader(Component):
163163
help="Skip files that are not compatible to the reference instead of raising an error",
164164
).tag(config=True)
165165

166+
enforce_subarray_equality = Bool(
167+
default_value=True,
168+
help=(
169+
"Enforce strict equality of subarray descriptions between files, "
170+
"raising an error if they do not match exactly. If False, a looser check "
171+
"primarily on telescope IDs is performed to ensure compatibility."
172+
),
173+
).tag(config=True)
174+
166175
allowed_tel_types = List(
167176
default_value=None,
168177
allow_none=True,
@@ -353,17 +362,21 @@ def __init__(
353362
if selected_tel_ids is not None:
354363
subarray = subarray.select_subarray(self.tel_ids)
355364

356-
# Check if it matches the reference
357-
if not subarray.__eq__(self.subarray):
365+
# Check if the subarray matches the reference
366+
subarrays_match = (
367+
subarray.__eq__(self.subarray)
368+
if self.enforce_subarray_equality
369+
else SubarrayDescription.check_matching_subarrays([self.subarray, subarray])
370+
)
371+
if not subarrays_match:
372+
message = (
373+
f"Subarray description of file '{filename}' does not match the reference subarray description."
374+
)
358375
if self.skip_incompatible_files:
359-
self.log.warning(
360-
f"Skipping '{filename}'. Subarray description does not match the reference subarray description."
361-
)
376+
self.log.warning(f"Skipping '{filename}'. {message}")
362377
del self.files[filename]
363378
else:
364-
raise ValueError(
365-
f"Subarray description of file '{filename}' does not match the reference subarray description."
366-
)
379+
raise ValueError(message)
367380

368381
# Set the telescope type and camera name as class attributes for mono mode for convenience
369382
# FIXME Make image mapper not a dict because we only need one since we do not select multiple telescope types for image/wvf reading

0 commit comments

Comments
 (0)