TableLoader¶
-
class
ctapipe.io.
TableLoader
(**kwargs: Any)[source]¶ Bases:
ctapipe.core.component.Component
Load telescope-event or subarray-event data from ctapipe HDF5 files
This class provides high-level access to data stored in ctapipe HDF5 files, such as created by the ctapipe-process tool (
ProcessorTool
).The following
TableLoader
methods load data from all relevant tables, depending on the options, and joins them into single tables:TableLoader.read_telescope_events_by_type
retuns a dict with a table per telescope type, which is needed for e.g. DL1 image data that might have different shapes for each of the telescope types as tables do not support variable length columns.
- Attributes
- subarray
SubarrayDescription
The subarray as read from
input_url
.
- subarray
Attributes Summary
Use a Enum class as model for the data type description.
A path Trait for input/output files.
A boolean (True, False) trait.
A boolean (True, False) trait.
A boolean (True, False) trait.
A boolean (True, False) trait.
A boolean (True, False) trait.
A boolean (True, False) trait.
A boolean (True, False) trait.
Methods Summary
close
()Close the underlying hdf5 file
Read the simulated shower distribution histograms
Read the simulation configuration table
read_subarray_events
([start, stop, keep_order])Read subarray-based event information.
read_subarray_events_chunked
(chunk_size)Iterate over chunks of subarray events.
read_telescope_events
([telescopes, start, stop])Read telescope-based event information.
read_telescope_events_by_type
([telescopes, …])Read telescope-based event information.
Iterate over chunks of telescope events.
read_telescope_events_chunked
(chunk_size, …)Iterate over chunks of telescope events.
Attributes Documentation
-
focal_length_choice
¶ Use a Enum class as model for the data type description. Note that if no default-value is provided, the first enum-value is used as default-value.
# -- SINCE: Python 3.4 (or install backport: pip install enum34) import enum from traitlets import HasTraits, UseEnum class Color(enum.Enum): red = 1 # -- IMPLICIT: default_value blue = 2 green = 3 class MyEntity(HasTraits): color = UseEnum(Color, default_value=Color.blue) entity = MyEntity(color=Color.red) entity.color = Color.green # USE: Enum-value (preferred) entity.color = "green" # USE: name (as string) entity.color = "Color.green" # USE: scoped-name (as string) entity.color = 3 # USE: number (as int) assert entity.color is Color.green
-
input_url
¶ A path Trait for input/output files.
- Attributes
- exists: boolean or None
If True, path must exist, if False path must not exist
- directory_ok: boolean
If False, path must not be a directory
- file_ok: boolean
If False, path must not be a file
-
load_dl1_images
¶ A boolean (True, False) trait.
-
load_dl1_parameters
¶ A boolean (True, False) trait.
-
load_dl2
¶ A boolean (True, False) trait.
-
load_instrument
¶ A boolean (True, False) trait.
-
load_simulated
¶ A boolean (True, False) trait.
-
load_true_images
¶ A boolean (True, False) trait.
-
load_true_parameters
¶ A boolean (True, False) trait.
Methods Documentation
-
read_subarray_events
(start=None, stop=None, keep_order=True)[source]¶ Read subarray-based event information.
- Returns
- table: astropy.io.Table
Table with primary index columns “obs_id” and “event_id”.
-
read_subarray_events_chunked
(chunk_size)[source]¶ Iterate over chunks of subarray events.
- Parameters
- chunk_size: int
Number of subarray events to load per chunk
-
read_telescope_events
(telescopes=None, start=None, stop=None)[source]¶ Read telescope-based event information.
If the corresponding traitlets are True, also subarray event information is joined onto the table.
The start, stop parameters enable to only load parts of the file, note however, to maintain integrity of subarray events, these refer to the subarray indices in the file. E.g.
start=0
,stop=10
would load the telescope events corresponding to the first 10 subarray events in the input file.- Parameters
- telescopes: Optional[List[Union[int, str, TelescopeDescription]]]
A list containing any combination of telescope IDs and/or telescope descriptions. If None, all available telescopes are read.
- start: int
First subarray event to read
- stop: int
Last subarray event (non-inclusive)
- Returns
- events: astropy.io.Table
Table with primary index columns “obs_id”, “event_id” and “tel_id”.
-
read_telescope_events_by_type
(telescopes=None, start=None, stop=None) → Dict[str, astropy.table.table.Table][source]¶ Read telescope-based event information.
- Parameters
- telescopes: List[Union[int, str, TelescopeDescription]]
Any list containing a combination of telescope IDs or telescope_descriptions.
- Returns
- tables: dict(astropy.io.Table)
Dictionary of tables organized by telescope types Table with primary index columns “obs_id”, “event_id” and “tel_id”.
-
read_telescope_events_by_type_chunked
(chunk_size, **kwargs)[source]¶ Iterate over chunks of telescope events.
- Parameters
- chunk_size: int
Number of subarray events to load per chunk. The telescope tables might be larger or smaller than chunk_size depending on the selected telescopes.
- **kwargs are passed to `read_telescope_events`
-
read_telescope_events_chunked
(chunk_size, **kwargs)[source]¶ Iterate over chunks of telescope events.
- Parameters
- chunk_size: int
Number of subarray events to load per chunk. The telescope tables might be larger or smaller than chunk_size depending on the selected telescopes.
- **kwargs are passed to `read_telescope_events`