Skip to content

Commit 349f207

Browse files
committed
Better error message for invalid tel_id
1 parent 7889ee5 commit 349f207

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/ctapipe_io_lst/__init__.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,15 @@ def create_subarray(tel_id=1, reference_location=None):
454454

455455
tel_descriptions = {tel_id: lst_tel_descr}
456456

457-
xyz = ground_frame_from_earth_location(
458-
LST_LOCATIONS[tel_id],
459-
reference_location,
460-
).cartesian.xyz
461-
tel_positions = {tel_id: xyz}
462-
457+
try:
458+
location = LST_LOCATIONS[tel_id]
459+
except KeyError:
460+
known = list(LST_LOCATIONS.keys())
461+
msg = f"Location missing for tel_id={tel_id} not in {known}. Is this LST data?"
462+
raise KeyError(msg) from None
463+
464+
ground_frame = ground_frame_from_earth_location(location, reference_location)
465+
tel_positions = {tel_id: ground_frame.cartesian.xyz}
463466
subarray = SubarrayDescription(
464467
name=f"LST-{tel_id} subarray",
465468
tel_descriptions=tel_descriptions,

0 commit comments

Comments
 (0)