HDF5MonitoringSource#

class ctapipe.io.HDF5MonitoringSource(*args: t.Any, **kwargs: t.Any)[source]#

Bases: MonitoringSource

Class for reading HDF5 monitoring data as a MonitoringSource.

This class provides a common interface for accessing HDF5 monitoring data from different monitoring types. An event following the ArrayEventContainer is passed to the fill_monitoring_container() method and the different monitoring types are filled into a MonitoringContainer instance. See MonitoringContainer for details.

A basic example on how to use the HDF5MonitoringSource:

>>> from ctapipe.io import SimTelEventSource, HDF5MonitoringSource
>>> from ctapipe.utils import get_dataset_path
>>> tel_id = 1
>>> event_source = SimTelEventSource(
...    input_url="dataset://gamma_prod6_preliminary.simtel.zst",
...    allowed_tels={tel_id},
...    max_events=1,
...    skip_r1_calibration=True,
... )
>>> file = get_dataset_path("calibpipe_camcalib_single_chunk_i0.1.0.dl1.h5")
>>> monitoring_source = HDF5MonitoringSource(
...    subarray=event_source.subarray,
...    input_files=[file],
... )
>>> for event in event_source:
...     # Fill the event data with the monitoring container
...     monitoring_source.fill_monitoring_container(event)
...     # Print the monitoring information for the camera calibration
...     print(event.monitoring.tel[tel_id].camera.coefficients["time"])
...     print(event.monitoring.tel[tel_id].camera.coefficients["factor"])
...     print(event.monitoring.tel[tel_id].camera.coefficients["pedestal_offset"])
...     print(event.monitoring.tel[tel_id].camera.coefficients["time_shift"])
...     print(event.monitoring.tel[tel_id].camera.coefficients["outlier_mask"])
...     print(event.monitoring.tel[tel_id].camera.coefficients["is_valid"])
40587.000000011576
[[0.01539444 0.01501589 0.0158232  ... 0.01514254 0.01504862 0.01497081]
 [0.25207437 0.24654945 0.25933876 ... 0.24859268 0.24722679 0.24587582]]
[[399.5        398.66666667 399.5        ... 399.25       398.41666667
  399.        ]
 [400.08333333 400.41666667 399.91666667 ... 400.25       399.5
  399.66666667]]
[[ 0.01000023  0.1800003  -0.09000015 ... -0.12999916  0.1800003
   0.07999992]
 [ 0.2800007  -0.27000046  0.11000061 ...  0.04000092 -0.19000053
  -0.4699993 ]]
[[False False False ... False False False]
 [False False False ... False False False]]
True
Attributes:
input_files: list of Paths

Paths to the input monitoring files.

pixel_statistics: dict

Dictionary to hold pixel statistics tables

camera_coefficients: dict

Dictionary to hold camera coefficients

telescope_pointings: dict

Dictionary to hold telescope pointing information

Attributes Summary

available_data

Returns the available monitoring types of this source.

available_telescope_data

Returns the available telescope monitoring types of this source.

camera_coefficients

has_camera_coefficients

True for files that contain camera calibration coefficients

has_pixel_statistics

True for files that contain pixel statistics

has_pointings

True for files that contain pointing information

input_files

List of paths to the HDF5 input files containing monitoring data

is_simulation

True for files with a simulation group at the root of the file.

pixel_statistics

telescope_pointings

timestamp_tolerance

Tolerance for timestamps outside monitoring validity ranges

Methods Summary

fill_monitoring_container(event)

Fill the monitoring container for a given event.

get_camera_monitoring_container(tel_id[, time])

Retrieve the camera monitoring container with interpolated data.

get_table(monitoring_type[, subtype])

Get the monitoring table for a given monitoring type.

get_telescope_pointing_container(tel_id, time)

Get the telescope pointing container for a given telescope ID and time.

get_telescope_table(tel_id, monitoring_type)

Get the monitoring table for a given telescope monitoring type.

get_telescope_values(tel_id, time, ...[, ...])

Get monitoring values for specific timestamp(s).

get_values(time, monitoring_type[, subtype])

Get monitoring values for specific timestamp(s).

Attributes Documentation

available_data#
available_telescope_data#
camera_coefficients#
has_camera_coefficients#

True for files that contain camera calibration coefficients

has_pixel_statistics#

True for files that contain pixel statistics

has_pointings#

True for files that contain pointing information

input_files#

List of paths to the HDF5 input files containing monitoring data

is_simulation#

True for files with a simulation group at the root of the file.

pixel_statistics#
telescope_pointings#
timestamp_tolerance#

Tolerance for timestamps outside monitoring validity ranges

Methods Documentation

fill_monitoring_container(event: ArrayEventContainer)[source]#

Fill the monitoring container for a given event.

Parameters:
eventArrayEventContainer

The event to fill the monitoring container for.

get_camera_monitoring_container(tel_id: int, time: Time = None) → CameraMonitoringContainer[source]#

Retrieve the camera monitoring container with interpolated data.

Parameters:
tel_idint

The telescope ID to retrieve the monitoring data for.

timeastropy.time.Time or None

Optional target timestamp(s) to find the camera monitoring data for. The target timestamp(s) are required to interpolate the monitoring data of observation. For monitoring data of simulation, the first entry of the monitoring data is typically used if no timestamp is provided.

Returns:
CameraMonitoringContainer

The camera monitoring container.

get_table(monitoring_type: MonitoringType, subtype: str | None = None) → Table[source]#

Get the monitoring table for a given monitoring type.

Parameters:
monitoring_typeMonitoringType

The type of monitoring data to retrieve.

subtypestr | None

Optional subtype

Returns:
astropy.table.Table

The monitoring table.

Raises:
KeyError

If monitoring_type / subtype is not available.

get_telescope_pointing_container(tel_id: int, time: Time) → TelescopePointingContainer[source]#

Get the telescope pointing container for a given telescope ID and time.

Parameters:
tel_idint

The telescope ID to retrieve the monitoring data for.

timeastropy.time.Time

Target timestamp to find the telescope pointing data for.

Returns:
TelescopePointingContainer

The telescope pointing container.

get_telescope_table(tel_id: int, monitoring_type: TelescopeMonitoringType, subtype: str | None = None) → Table[source]#

Get the monitoring table for a given telescope monitoring type.

Parameters:
monitoring_typeMonitoringType

The type of monitoring data to retrieve.

subtypestr | None

Optional subtype, e.g. for PIXEL_STATISTICS type

Returns:
astropy.table.Table

The monitoring table.

Raises:
KeyError

If monitoring_type is not available.

TypeError

If tel_id scope doesn’t match monitoring_type requirements.

get_telescope_values(tel_id: int, time: Time, monitoring_type: TelescopeMonitoringType, subtype: str | None = None)[source]#

Get monitoring values for specific timestamp(s).

Performs interpolation or nearest-neighbor lookup as appropriate.

Parameters:
timeastropy.time.Time

Target timestamp(s). Can be scalar or array.

monitoring_typeMonitoringType

The type of monitoring data to retrieve.

subtypestr | None

Optional subtype

Returns:
monitoring_data

Monitoring values at requested time(s). Return type depends on monitoring_type.

Raises:
KeyError

If monitoring_type unavailable

ValueError

If time out of bounds.

get_values(time: Time, monitoring_type: MonitoringType, subtype: str | None = None)[source]#

Get monitoring values for specific timestamp(s).

Performs interpolation or nearest-neighbor lookup as appropriate.

Parameters:
timeastropy.time.Time

Target timestamp(s). Can be scalar or array.

monitoring_typeMonitoringType

The type of monitoring data to retrieve.

subtypestr | None

Optional subtype

Returns:
monitoring_data

Monitoring values at requested time(s). Return type depends on monitoring_type.

Raises:
KeyError

If monitoring_type unavailable

ValueError

If time out of bounds.