added docs, tests and benchmark for mean_over_dataset

This commit is contained in:
mazzol_a committed 2026-10-03 15:43:39 +02:00
1 parent 929e5efab9
commit 6e40b9af81
10 files changed
+306 -35

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
#include "aare/DataSetAggregation.hpp"
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
namespace py = pybind11;
using namespace aare;
template <typename FRAME_TYPE>
void bind_DataSetAggregation(pybind11::module_ &m) {
m.def(
"mean_over_dataset",
[](const std::filesystem::path &path, size_t num_samples,
size_t num_frames_per_sample, int num_threads) {
auto result =
new NDArray<FRAME_TYPE, 3>(mean_over_dataset<FRAME_TYPE>(
path, num_samples, num_frames_per_sample, num_threads));
return return_image_data(result);
},
py::arg("path"), py::arg("num_samples"),
py::arg("num_frames_per_sample"), py::arg("num_threads") = 16,
R"pbdoc(
Compute the mean over several frames per sample stored in a file.
Parameters:
-----------
path (str): The path to the file containing the dataset.
num_samples (int): The number of samples in the dataset.
num_frames_per_sample (int): The number of frames per sample.
num_threads (int, optional): The number of threads to use for parallel computation. Defaults to 16.
Returns:
--------
np.ndarray: A numpy array containing the mean frame for each sample with shape (rows, cols, num_samples).
)pbdoc");
}
+3
View File
@@ -11,6 +11,7 @@
#include "bind_ClusterFinder.hpp"
#include "bind_ClusterFinderMT.hpp"
#include "bind_ClusterVector.hpp"
#include "bind_DataSetAggregation.hpp"
#include "bind_Defs.hpp"
#include "bind_Eta.hpp"
#include "bind_FastPedestal.hpp"
@@ -178,4 +179,6 @@ PYBIND11_MODULE(_aare, m) {
define_eta<double>(m, "d");
define_eta<int>(m, "i");
define_eta<int16_t>(m, "i16");
bind_DataSetAggregation<uint16_t>(m);
}