import numpy as np
from .._calib import r1_calibration
from ..memory import copyto
from ..memory import empty
[docs]class CameraR1Calibrator:
[docs] def calibrate(self, event):
"""
Perform the conversion from raw R0 data to R1 data
(ADC Samples -> PE Samples), and fill the r1 container.
Parameters
----------
event : container
A `ctapipe` event container
"""
# COPY WAVEFORM IN A 3D Array aligned (with pitch) -> mandatory for vectorization
# Prepare data
for tel_id in event.r0.tels_with_data:
samples = empty((event.r0.tel[tel_id].waveform.shape), dtype=np.uint16)
copyto(samples, event.r0.tel[tel_id].waveform)
calibrated = empty(samples.shape, dtype=np.float32)
n_samples = samples.shape[2]
ped = event.mc.tel[tel_id].pedestal / n_samples
dc_to_pe = event.mc.tel[tel_id].dc_to_pe
# Apply calibation and fill r1
r1_calibration(samples, ped, dc_to_pe, calibrated)
event.r1.tel[tel_id].waveform = calibrated