Skip to content

Commit 43ee740

Browse files
authored
Merge pull request #228 from cta-observatory/explicit_error
Raise good error message in case border slices removed by EVB
2 parents a145edd + 55f74de commit 43ee740

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-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}. Known tel_ids: {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,

src/ctapipe_io_lst/calibration.py

+9
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,15 @@ def apply_drs4_corrections(self, event: LSTArrayEventContainer):
230230
if r1.waveform is None:
231231
r1.waveform = event.r0.tel[tel_id].waveform
232232

233+
n_samples = r1.waveform.shape[-1]
234+
if n_samples != N_SAMPLES:
235+
msg = (
236+
f"Data has n_samples={n_samples}, expected {N_SAMPLES}."
237+
" Applying offline drs4 corrections to data with border samples"
238+
" already removed by EVB is not supported."
239+
)
240+
raise NotImplementedError(msg)
241+
233242
# float32 can represent all values of uint16 exactly,
234243
# so this does not loose precision.
235244
r1.waveform = r1.waveform.astype(np.float32, copy=False)

0 commit comments

Comments
 (0)