pyrex.io.HDF5Writer¶
-
class
pyrex.io.
HDF5Writer
(filename, mode='x', write_particles=True, write_triggers=True, write_antenna_triggers=False, write_rays=True, write_noise=False, write_waveforms=False, require_trigger=True)¶ Class for writing data to an hdf5 file.
Works as a context manager and allows for writing simulation/real data or analysis-level data to the given file.
- Parameters
- filenamestr
File name to open in the given write mode.
- modestr, optional
Mode with which to open the file. ‘w’ writes to the file, overwriting any existing data. ‘x’ writes to the file, failing if the file exists. ‘a’ appends to the file, creating if the file doesn’t exist. ‘r+’ appends to the file, failing if the file doesn’t exist.
- write_particlesbool, optional
Whether to write particle metadata when adding event data to the file.
- write_waveformsbool, optional
Whether to write waveform data when adding event data to the file.
- write_triggersbool, optional
Whether to write trigger data when adding event data to the file.
- require_triggerbool or list of str, optional
Whether to write data only when the detector is triggered. If
False
all data will be written for every event. IfTrue
most data will be written only on a detector trigger (particle metadata and trigger data will still be written for every event). If a list of strings is provided, then the specified data types will be written only on a detector trigger and all other data types will be written for every event.
- Other Parameters
- write_antenna_triggersbool, optional
Whether to write trigger data of individual antennas when adding event data to the file.
- write_raysbool, optional
Whether to write ray metadata when adding event data to the file.
- write_noisebool, optional
Whether to write noise-generation metadata when adding event data to the file.
- Attributes
- filenamestr
Name of the file (to be) opened.
is_open
Boolean of whether the file is currently open.
has_detector
Boolean of whether the file has a linked detector.
Methods
add
(event[, triggered, ray_paths, …])Add the data from an event to the file.
add_analysis_indices
(name, global_index, …)Write the given start and length indices to the event indices dataset.
add_analysis_metadata
(name, metadata[, index])Writes the given metadata to the analysis metadata group at name.
add_file_metadata
(metadata)Writes the given metadata to the general file metadata group.
close
()Close the hdf5 file.
create_analysis_dataset
(name, *args, **kwargs)Create the given analysis dataset in the file.
create_analysis_group
(name, *args, **kwargs)Create the given analysis group in the file.
create_analysis_metadataset
(name, *args, …)Create the given analysis metadata group in the file.
open
()Open the hdf5 file for writing.
set_detector
(detector)Link the given detector to the file.