Skip to content

Commit

Permalink
Read number of samples from RunHeaders.
Browse files Browse the repository at this point in the history
  • Loading branch information
aleberti committed Apr 19, 2023
1 parent bd321b6 commit a89ab9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
21 changes: 18 additions & 3 deletions ctapipe_io_magic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
DATA_MONO_SUMT_TRIGGER_PATTERN,
PEDESTAL_TRIGGER_PATTERN,
DATA_STEREO_TRIGGER_PATTERN,
N_SAMPLES,
)

__all__ = [
Expand Down Expand Up @@ -668,12 +667,28 @@ def prepare_subarray_info(self):
f"Invalid focal length choice: {self.focal_length_choice}"
)


# camera info from MAGICCam.camgeom.fits.gz file
camera_geom = load_camera_geometry()

n_pixels = camera_geom.n_pixels

n_samples_array_list = ["MRawRunHeader.fNumSamplesHiGain"]
n_samples_list = []

for rootf in self.files_:
nsample_info = rootf['RunHeaders'].arrays(n_samples_array_list, library="np")
n_samples_file = int(nsample_info['MRawRunHeader.fNumSamplesHiGain'][0])
n_samples_list.append(n_samples_file)

n_samples_list = np.unique(n_samples_list).tolist()

if len(n_samples_list) > 1:
raise ValueError(
"Loaded files contain different number of readout samples. \
Please load files with the same readout configuration.")

n_samples = n_samples_list[0]

pulse_shape_lo_gain = np.array([0., 1., 2., 1., 0.])
pulse_shape_hi_gain = np.array([1., 2., 3., 2., 1.])
pulse_shape = np.vstack((pulse_shape_lo_gain, pulse_shape_hi_gain))
Expand All @@ -688,7 +703,7 @@ def prepare_subarray_info(self):
reference_pulse_sample_width=u.Quantity(0.5, u.ns),
n_channels=1,
n_pixels=n_pixels,
n_samples=N_SAMPLES,
n_samples=n_samples,
)

camera = CameraDescription('MAGICCam', camera_geom, camera_readout)
Expand Down
1 change: 0 additions & 1 deletion ctapipe_io_magic/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
MC_SUMT_TRIGGER_PATTERN = 32
# also for data taken in stereo with SumTrigger
DATA_STEREO_TRIGGER_PATTERN = 128
N_SAMPLES = 50

0 comments on commit a89ab9a

Please sign in to comment.