// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "HDF5DataFilePluginImageStats.h" #define RESERVE_IMAGES 1000 void HDF5DataFilePluginImageStats::OpenFile(HDF5File &data_file, const DataMessage &msg) { max_value.reserve(RESERVE_IMAGES); } void HDF5DataFilePluginImageStats::Write(const DataMessage &msg, uint64_t image_number) { if (msg.max_viable_pixel_value) max_value[image_number] = msg.max_viable_pixel_value.value(); if (msg.min_viable_pixel_value) min_value[image_number] = msg.min_viable_pixel_value.value(); if (msg.error_pixel_count) error_pixels[image_number] = msg.error_pixel_count.value(); if (msg.saturated_pixel_count) saturated_pixels[image_number] = msg.saturated_pixel_count.value(); } void HDF5DataFilePluginImageStats::WriteFinal(HDF5File &data_file) { HDF5Group(data_file, "/entry/image").NXClass("NXcollection"); if (!max_value.empty()) data_file.SaveVector("/entry/image/max_value", max_value.vec()); if (!max_value.empty()) data_file.SaveVector("/entry/image/min_value", min_value.vec()); if (!error_pixels.empty()) data_file.SaveVector("/entry/image/error_pixels", error_pixels.vec()); if (!saturated_pixels.empty()) data_file.SaveVector("/entry/image/saturated_pixels", saturated_pixels.vec()); }