Skip to content

Commit

Permalink
Better error message for invalid tel_id
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jul 29, 2024
1 parent 7889ee5 commit 55f74de
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/ctapipe_io_lst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 462 in src/ctapipe_io_lst/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/ctapipe_io_lst/__init__.py#L459-L462

Added lines #L459 - L462 were not covered by tests

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,
Expand Down

0 comments on commit 55f74de

Please sign in to comment.