Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store subarray description in the output file of the stats tool #2696

Merged
merged 7 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes/2696.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Store also the SubarrayDescription in the camera monitoring data produced by the stats tool
24 changes: 17 additions & 7 deletions src/ctapipe/tools/calculate_pixel_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,20 @@ def setup(self):
self.input_data.dl1_images = True
# Load the subarray description from the input file
subarray = SubarrayDescription.from_hdf(self.input_data.input_url)
# Get the telescope ids from the input data or use the allowed_tels configuration
self.tel_ids = (
subarray.tel_ids if self.allowed_tels is None else self.allowed_tels
# Select a new subarray if the allowed_tels configuration is used
self.subarray = (
subarray
if self.allowed_tels is None
else subarray.select_subarray(self.allowed_tels, "Subarray")
)
# Initialization of the statistics calculator
self.stats_calculator = PixelStatisticsCalculator(
parent=self, subarray=subarray
parent=self, subarray=self.subarray
)

def start(self):
# Iterate over the telescope ids and calculate the statistics
for tel_id in self.tel_ids:
for tel_id in self.subarray.tel_ids:
# Read the whole dl1 images for one particular telescope
dl1_table = self.input_data.read_telescope_events_by_id(
telescopes=[
Expand Down Expand Up @@ -171,13 +173,21 @@ def start(self):
f"/dl1/monitoring/telescope/{self.output_table_name}/tel_{tel_id:03d}",
overwrite=self.overwrite,
)

def finish(self):
self.log.info(
"DL1 monitoring data was stored in '%s' under '%s'",
self.output_path,
f"/dl1/monitoring/telescope/{self.output_table_name}",
)

def finish(self):
# Store the subarray description in the output file
self.subarray.to_hdf(self.output_path, overwrite=self.overwrite)
self.log.info(
"Subarray description was stored in '%s'",
self.output_path,
)
# Close the file in the TableLoader
self.input_data.close()
self.log.info("Tool is shutting down")


Expand Down