Skip to content

Commit

Permalink
Merge pull request #228 from cta-observatory/explicit_error
Browse files Browse the repository at this point in the history
Raise good error message in case border slices removed by EVB
  • Loading branch information
maxnoe authored Jul 29, 2024
2 parents a145edd + 55f74de commit 43ee740
Show file tree
Hide file tree
Showing 2 changed files with 18 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

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
9 changes: 9 additions & 0 deletions src/ctapipe_io_lst/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ def apply_drs4_corrections(self, event: LSTArrayEventContainer):
if r1.waveform is None:
r1.waveform = event.r0.tel[tel_id].waveform

n_samples = r1.waveform.shape[-1]
if n_samples != N_SAMPLES:
msg = (
f"Data has n_samples={n_samples}, expected {N_SAMPLES}."
" Applying offline drs4 corrections to data with border samples"
" already removed by EVB is not supported."
)
raise NotImplementedError(msg)

# float32 can represent all values of uint16 exactly,
# so this does not loose precision.
r1.waveform = r1.waveform.astype(np.float32, copy=False)
Expand Down

0 comments on commit 43ee740

Please sign in to comment.