Skip to content

Commit fd1fb78

Browse files
authored
Merge pull request #2853 from cta-observatory/remove-index-tables
Remove write_index_tables option of DataWriter, seems to corrupt files
2 parents 7fe063c + e6b629d commit fd1fb78

File tree

3 files changed

+4
-58
lines changed

3 files changed

+4
-58
lines changed

docs/changes/2853.api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Remove the option ``DataWriter.write_index_tables`` along with its alias
2+
in ``ctapipe-process --write-index-tables``.
3+
The option seems to corrupt output files for large data sizes, is not used
4+
in ctapipe itself and was not tested.

src/ctapipe/io/datawriter.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,6 @@ class DataWriter(Component):
218218
default_value="blosc:zstd",
219219
).tag(config=True)
220220

221-
write_index_tables = Bool(
222-
help=(
223-
"Generate PyTables index datasets for all tables that contain an "
224-
"event_id or tel_id. These speed up in-kernel pytables operations,"
225-
"but add some overhead to the file. They can also be generated "
226-
"and attached after the file is written "
227-
),
228-
default_value=False,
229-
).tag(config=True)
230-
231221
overwrite = Bool(help="overwrite output file if it exists").tag(config=True)
232222

233223
transform_waveform = Bool(default_value=False).tag(config=True)
@@ -374,9 +364,6 @@ def finish(self):
374364
if not self._at_least_one_event:
375365
self.log.warning("No events have been written to the output file")
376366

377-
if self.write_index_tables:
378-
self._generate_indices()
379-
380367
write_reference_metadata_headers(
381368
subarray=self._subarray,
382369
obs_ids=self.event_source.obs_ids,
@@ -719,46 +706,6 @@ def _write_dl2_stereo_event(self, event: ArrayEventContainer):
719706
containers=[event.index, container],
720707
)
721708

722-
def _generate_table_indices(self, h5file, start_node):
723-
"""helper to generate PyTables index tabnles for common columns"""
724-
for node in h5file.iter_nodes(start_node):
725-
if not isinstance(node, tables.group.Group):
726-
self.log.debug("generating indices for node: %s", node)
727-
if "event_id" in node.colnames:
728-
node.cols.event_id.create_index()
729-
self.log.debug("generated event_id index")
730-
if "tel_id" in node.colnames:
731-
node.cols.tel_id.create_index()
732-
self.log.debug("generated tel_id index")
733-
if "obs_id" in node.colnames:
734-
self.log.debug("generated obs_id index")
735-
node.cols.obs_id.create_index(kind="ultralight")
736-
else:
737-
# recurse
738-
self._generate_table_indices(h5file, node)
739-
740-
def _generate_indices(self):
741-
"""generate PyTables index tables for common columns"""
742-
self.log.debug("Writing index tables")
743-
if self.write_dl1_images:
744-
self._generate_table_indices(
745-
self._writer.h5file, "/dl1/event/telescope/images"
746-
)
747-
if self._is_simulation:
748-
self._generate_table_indices(
749-
self._writer.h5file, "/simulation/event/telescope/images"
750-
)
751-
if self.write_dl1_parameters:
752-
self._generate_table_indices(
753-
self._writer.h5file, "/dl1/event/telescope/parameters"
754-
)
755-
if self._is_simulation:
756-
self._generate_table_indices(
757-
self._writer.h5file, "/simulation/event/telescope/parameters"
758-
)
759-
760-
self._generate_table_indices(self._writer.h5file, "/dl1/event/subarray")
761-
762709
def _write_context_metadata_headers(self):
763710
"""write out any user-defined metadata in the context_metadata field to the
764711
headers.

src/ctapipe/tools/process.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,6 @@ class ProcessorTool(Tool):
151151
"store DL2/Event parameters in output",
152152
"don't DL2/Event parameters in output",
153153
),
154-
**flag(
155-
"write-index-tables",
156-
"DataWriter.write_index_tables",
157-
"generate PyTables index tables for the parameter and image datasets",
158-
),
159154
**flag(
160155
"write-muon-parameters",
161156
"DataWriter.write_muon_parameters",

0 commit comments

Comments
 (0)