From ac6d7fe4e3535da53a453be60a66e08176350501 Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 1 Jul 2026 14:24:01 +0200 Subject: [PATCH] added sparse mask python bindings --- include/aare/utils/SparseMask.hpp | 3 +++ python/aare/__init__.py | 2 ++ python/src/module.cpp | 2 ++ src/utils/SparseMask.cpp | 2 ++ 4 files changed, 9 insertions(+) diff --git a/include/aare/utils/SparseMask.hpp b/include/aare/utils/SparseMask.hpp index 95b6966d..acb1e4f7 100644 --- a/include/aare/utils/SparseMask.hpp +++ b/include/aare/utils/SparseMask.hpp @@ -38,6 +38,9 @@ class SparseMask { void write_to_file(const std::filesystem::path &filename) const; + /// @brief Get number of bad channels + size_t num_bad_channels() const; + private: /// @brief stoarge format of the sparse mask, either row major or column /// major diff --git a/python/aare/__init__.py b/python/aare/__init__.py index 84224613..a9cf6f33 100644 --- a/python/aare/__init__.py +++ b/python/aare/__init__.py @@ -56,3 +56,5 @@ from ._aare import ( PixelHistogram_u32, PixelHistogram_u64, ) + +from ._aare import SparseMask diff --git a/python/src/module.cpp b/python/src/module.cpp index 52c830b9..6a147c2a 100644 --- a/python/src/module.cpp +++ b/python/src/module.cpp @@ -18,6 +18,7 @@ #include "bind_PixelMap.hpp" #include "bind_RawFile.hpp" #include "bind_calibration.hpp" +#include "utils/bind_SparseMask.hpp" // TODO! migrate the other names #include "ctb_raw_file.hpp" @@ -78,6 +79,7 @@ PYBIND11_MODULE(_aare, m) { define_fit_bindings(m); define_interpolation_bindings(m); define_jungfrau_data_file_io_bindings(m); + define_sparse_mask_bindings(m); bind_calibration(m); diff --git a/src/utils/SparseMask.cpp b/src/utils/SparseMask.cpp index cbbbc3b1..b49d1647 100644 --- a/src/utils/SparseMask.cpp +++ b/src/utils/SparseMask.cpp @@ -61,4 +61,6 @@ bool SparseMask::is_masked(const size_t row, const size_t col) const { } } +size_t SparseMask::num_bad_channels() const { return innerindices_.size(); } + } // namespace aare \ No newline at end of file