Skip to content

Commit 412b951

Browse files
authored
Addition of CalibrationWriterNectarCAM tool for writing Category A calibration files (#207)
* Add script to obtain metadata of `ctapipe` and `nectarchain`. Taken from `lstcam_calib` with minor adaptations for `nectarchain`. * added group name as option to HDF5 readout, particularly useful for pedestal output files that use various groups to store data * first attempt for a Tool that writes a category A output file from NectarCAM containers * Add example script for the usage of the CalibrationWriterNectarCAM tool * ensure that filled arrays have the correct type (based on `lstcam_calib` example file) * do one-padding instead of zero-padding to expand arrays related to pixel status with missing pixels (so a missing pixel = True for those that are added, i.e. due that were not included due to hardware failure) * fixed hardware failing pixel status bug
1 parent 6f8ef31 commit 412b951

File tree

5 files changed

+796
-6
lines changed

5 files changed

+796
-6
lines changed

src/nectarchain/data/container/core.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class NectarCAMContainer(Container):
5454
"""
5555

5656
@staticmethod
57-
def _container_from_hdf5(path, container_class, index_component=0):
57+
def _container_from_hdf5(
58+
path, container_class, index_component=0, group_name="data"
59+
):
5860
"""Static method to read a container from an HDF5 file.
5961
6062
Parameters:
@@ -74,15 +76,17 @@ def _container_from_hdf5(path, container_class, index_component=0):
7476
container = container_class()
7577
with HDF5TableReader(path) as reader:
7678
tableReader = reader.read(
77-
table_name=f"/data/{container_class.__name__}_{index_component}",
79+
table_name=(
80+
f"/{group_name}/{container_class.__name__}_{index_component}"
81+
),
7882
containers=container_class,
7983
)
8084
container = next(tableReader)
8185

8286
yield container
8387

8488
@classmethod
85-
def from_hdf5(cls, path, index_component=0):
89+
def from_hdf5(cls, path, index_component=0, group_name="data"):
8690
"""Reads a container from an HDF5 file.
8791
8892
Parameters:
@@ -99,7 +103,10 @@ def from_hdf5(cls, path, index_component=0):
99103
"""
100104

101105
return cls._container_from_hdf5(
102-
path, container_class=cls, index_component=index_component
106+
path,
107+
container_class=cls,
108+
index_component=index_component,
109+
group_name=group_name,
103110
)
104111

105112

src/nectarchain/data/container/gain_container.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class GainContainer(NectarCAMContainer):
4343
pixels_id = Field(type=np.ndarray, dtype=np.uint16, ndim=1, description="pixel ids")
4444

4545
@classmethod
46-
def from_hdf5(cls, path):
46+
def from_hdf5(cls, path, group_name="data"):
4747
"""Class method to read a GainContainer from an HDF5 file.
4848
4949
Args:
@@ -52,7 +52,9 @@ def from_hdf5(cls, path):
5252
Yields:
5353
GainContainer: The container from the data in the HDF5 file.
5454
"""
55-
return super(__class__, cls)._container_from_hdf5(path, container_class=cls)
55+
return super(__class__, cls)._container_from_hdf5(
56+
path, container_class=cls, group_name=group_name
57+
)
5658

5759

5860
class SPEfitContainer(GainContainer):

0 commit comments

Comments
 (0)