Skip to content

Commit

Permalink
added metadata
Browse files Browse the repository at this point in the history
renamed output_column_name to output_table_name
  • Loading branch information
TjarkMiener committed Dec 12, 2024
1 parent 092c1e1 commit 3548c09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/ctapipe/tools/calculate_pixel_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class StatisticsCalculatorTool(Tool):
help="Column name of the pixel-wise image data to calculate statistics",
).tag(config=True)

output_column_name = Unicode(
output_table_name = Unicode(
default_value="statistics",
allow_none=False,
help="Column name of the output statistics",
help="Table name of the output statistics",
).tag(config=True)

output_path = Path(
Expand Down Expand Up @@ -164,19 +164,22 @@ def start(self):
"No faulty chunks found for telescope 'tel_id=%d'. Skipping second pass.",
tel_id,
)
# Add metadata to the aggregated statistics
aggregated_stats.meta["input_url"] = self.input_data.input_url
aggregated_stats.meta["input_column_name"] = self.input_column_name
# Write the aggregated statistics and their outlier mask to the output file
write_table(
aggregated_stats,
self.output_path,
f"/dl1/monitoring/telescope/{self.output_column_name}/tel_{tel_id:03d}",
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_column_name}",
f"/dl1/monitoring/telescope/{self.output_table_name}",
)
self.log.info("Tool is shutting down")

Expand Down
4 changes: 2 additions & 2 deletions src/ctapipe/tools/tests/test_calculate_pixel_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_calculate_pixel_stats_tool(tmp_path, dl1_image_file):
"StatisticsCalculatorTool": {
"allowed_tels": [tel_id],
"input_column_name": "image",
"output_column_name": "statistics",
"output_table_name": "statistics",
},
"PixelStatisticsCalculator": {
"stats_aggregator_type": [
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_tool_config_error(tmp_path, dl1_image_file):
"StatisticsCalculatorTool": {
"allowed_tels": [3],
"input_column_name": "image_charges",
"output_column_name": "statistics",
"output_table_name": "statistics",
}
}
)
Expand Down

0 comments on commit 3548c09

Please sign in to comment.