Skip to content

Commit 7695123

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

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/ctapipe_io_lst/__init__.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,14 @@ 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}
457+
try:
458+
location = LST_LOCATIONS[tel_id]
459+
except KeyError:
460+
msg = f"No location known for tel_id={tel_id}. Is this LST data?"
461+
raise KeyError(msg) from None
462462

463+
ground_frame = ground_frame_from_earth_location(location, reference_location)
464+
tel_positions = {tel_id: ground_frame.cartesian.xyz}
463465
subarray = SubarrayDescription(
464466
name=f"LST-{tel_id} subarray",
465467
tel_descriptions=tel_descriptions,

0 commit comments

Comments
 (0)