From 55f74dea2bbfff05c4f79536ec3557c7fcb094a8 Mon Sep 17 00:00:00 2001 From: Maximilian Linhoff Date: Mon, 29 Jul 2024 12:59:48 +0200 Subject: [PATCH] Better error message for invalid tel_id --- src/ctapipe_io_lst/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ctapipe_io_lst/__init__.py b/src/ctapipe_io_lst/__init__.py index a60128da..37596281 100644 --- a/src/ctapipe_io_lst/__init__.py +++ b/src/ctapipe_io_lst/__init__.py @@ -454,12 +454,15 @@ def create_subarray(tel_id=1, reference_location=None): tel_descriptions = {tel_id: lst_tel_descr} - xyz = ground_frame_from_earth_location( - LST_LOCATIONS[tel_id], - reference_location, - ).cartesian.xyz - tel_positions = {tel_id: xyz} - + try: + location = LST_LOCATIONS[tel_id] + except KeyError: + known = list(LST_LOCATIONS.keys()) + msg = f"Location missing for tel_id={tel_id}. Known tel_ids: {known}. Is this LST data?" + raise KeyError(msg) from None + + ground_frame = ground_frame_from_earth_location(location, reference_location) + tel_positions = {tel_id: ground_frame.cartesian.xyz} subarray = SubarrayDescription( name=f"LST-{tel_id} subarray", tel_descriptions=tel_descriptions,