ctapipe is not stable yet, so expect large and rapid changes to structure and functionality as we explore various design choices before the 1.0 release.

DataWriter#

class ctapipe.io.DataWriter(**kwargs: Any)[source]#

Bases: Component

Serialize a sequence of events into a HDF5 file, in the correct format

Examples

inside a Tool:

with DataWriter(parent=self) as write_data:
    for event in source:
        calibrate(event)
        process_images(event)
        write_data(event)

Attributes Summary

compression_level

compression level, 0=None, 9=maximum

compression_type

compressor algorithm to use.

contact_info

A trait whose value must be an instance of a specified class.

context_metadata

Additional metadata keywords and values that describe this data.

datalevels

returns a list of data levels requested

image_dtype

A trait for unicode strings.

image_offset

An int trait.

image_scale

A float trait.

instrument_info

A trait whose value must be an instance of a specified class.

output_path

output filename

overwrite

overwrite output file if it exists

peak_time_dtype

A trait for unicode strings.

peak_time_offset

An int trait.

peak_time_scale

A float trait.

transform_image

A boolean (True, False) trait.

transform_peak_time

A boolean (True, False) trait.

transform_waveform

A boolean (True, False) trait.

waveform_dtype

A trait for unicode strings.

waveform_offset

An int trait.

waveform_scale

A float trait.

write_dl1_images

Store DL1 Images if available

write_dl1_parameters

Store DL1 image parameters if available

write_dl2

Store DL2 stereo shower parameters if available

write_index_tables

Generate PyTables index datasets for all tables that contain an event_id or tel_id.

write_muon_parameters

Store muon parameters if available

write_r0_waveforms

Store R0 waveforms if available

write_r1_waveforms

Store R1 waveforms if available

Methods Summary

__call__(event)

Write a single event to the output file.

finish()

called after all events are done

table_name(tel_id)

construct dataset table names depending on chosen split method

write_simulation_histograms(event_source)

Write the distribution of thrown showers

Attributes Documentation

compression_level#

compression level, 0=None, 9=maximum

compression_type#

compressor algorithm to use.

contact_info#

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

Subclasses can declare default classes by overriding the klass attribute

context_metadata#

Additional metadata keywords and values that describe this data. This should be a dictionary where the keys will be appended to the CONTEXT section of the output file’s attributes. Keys can be hierarchical by using a space between each level, e.g. SIMULATION PRODUCTION would make a key PRODUCTION grouped under the key SIMULATION

datalevels#

returns a list of data levels requested

image_dtype#

A trait for unicode strings.

image_offset#

An int trait.

image_scale#

A float trait.

instrument_info#

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

Subclasses can declare default classes by overriding the klass attribute

output_path#

output filename

overwrite#

overwrite output file if it exists

peak_time_dtype#

A trait for unicode strings.

peak_time_offset#

An int trait.

peak_time_scale#

A float trait.

transform_image#

A boolean (True, False) trait.

transform_peak_time#

A boolean (True, False) trait.

transform_waveform#

A boolean (True, False) trait.

waveform_dtype#

A trait for unicode strings.

waveform_offset#

An int trait.

waveform_scale#

A float trait.

write_dl1_images#

Store DL1 Images if available

write_dl1_parameters#

Store DL1 image parameters if available

write_dl2#

Store DL2 stereo shower parameters if available

write_index_tables#

Generate PyTables index datasets for all tables that contain an event_id or tel_id. These speed up in-kernel pytables operations,but add some overhead to the file. They can also be generated and attached after the file is written

write_muon_parameters#

Store muon parameters if available

write_r0_waveforms#

Store R0 waveforms if available

write_r1_waveforms#

Store R1 waveforms if available

Methods Documentation

__call__(event: ArrayEventContainer)[source]#

Write a single event to the output file.

finish()[source]#

called after all events are done

table_name(tel_id)[source]#

construct dataset table names depending on chosen split method

write_simulation_histograms(event_source)[source]#

Write the distribution of thrown showers

Notes

  • this only runs if this is a simulation file. The current implementation is a bit of a hack and implies we should improve SimTelEventSource to read this info.

  • Currently the histograms are at the end of the simtel file, so if max_events is set to non-zero, the end of the file may not be read, and this no histograms will be found.