format
Build on RHEL9 / build (push) Failing after 2m34s
Build on RHEL8 / build (push) Failing after 3m10s
Run tests using data on local RHEL8 / build (push) Failing after 3m58s

This commit is contained in:
Erik Fröjdh
2026-08-03 10:08:25 +02:00
parent 07b994c72e
commit 09399f7b82
10 changed files with 30 additions and 48 deletions
+16 -18
View File
@@ -3,10 +3,10 @@
#include "aare/ClusterFile.hpp"
#include "aare/ClusterVector.hpp"
#include "aare/Dtype.hpp"
#include "aare/FastPedestal.hpp"
#include "aare/NDArray.hpp"
#include "aare/NDView.hpp"
#include "aare/Pedestal.hpp"
#include "aare/FastPedestal.hpp"
#include "aare/defs.hpp"
#include <cstddef>
@@ -74,8 +74,6 @@ class ClusterFinder {
NDArray<PEDESTAL_TYPE, 2> noise() { return m_pedestal.std(); }
void clear_pedestal() { m_pedestal.clear(); }
void update_threshold() { m_threshold = m_pedestal.std() * m_nSigma; }
/**
@@ -94,6 +92,7 @@ class ClusterFinder {
m_clusters = ClusterVector<ClusterType>{};
return tmp;
}
private:
/**
* @brief Process a single pixel: scan its cluster window, decide whether it
@@ -102,8 +101,8 @@ class ClusterFinder {
* (border pixels), if false they are assumed in bounds (interior pixels).
*/
template <bool CheckBounds>
void process_pixel(const NDView<FRAME_TYPE, 2> &frame,
const int iy, const int ix) {
void process_pixel(const NDView<FRAME_TYPE, 2> &frame, const int iy,
const int ix) {
constexpr int dy = ClusterSizeY / 2;
constexpr int dx = ClusterSizeX / 2;
constexpr int has_center_pixel_x = ClusterSizeX % 2;
@@ -114,9 +113,9 @@ class ClusterFinder {
const int cols = static_cast<int>(frame.shape(1));
const int rows = static_cast<int>(frame.shape(0));
const auto center = (static_cast<std::size_t>(iy) *
static_cast<std::size_t>(cols)) +
static_cast<std::size_t>(ix);
const auto center =
(static_cast<std::size_t>(iy) * static_cast<std::size_t>(cols)) +
static_cast<std::size_t>(ix);
const auto *corrected = m_pd_corrected_frame.data();
const PEDESTAL_TYPE threshold = m_threshold.data()[center];
const PEDESTAL_TYPE value = corrected[center];
@@ -140,9 +139,9 @@ class ClusterFinder {
}
} else {
for (int ir = -dy; ir < dy + has_center_pixel_y; ir++) {
const auto *pixel =
corrected + static_cast<std::size_t>(iy + ir) * cols +
(ix - dx);
const auto *pixel = corrected +
static_cast<std::size_t>(iy + ir) * cols +
(ix - dx);
for (int k = 0; k < ClusterSizeX; k++) {
const PEDESTAL_TYPE val = pixel[k];
total += val;
@@ -177,9 +176,9 @@ class ClusterFinder {
const PEDESTAL_TYPE corrected_value =
corrected[(static_cast<std::size_t>(y) * cols) +
x];
if constexpr (
std::is_integral_v<CT> &&
std::is_floating_point_v<PEDESTAL_TYPE>) {
if constexpr (std::is_integral_v<CT> &&
std::is_floating_point_v<
PEDESTAL_TYPE>) {
cluster.data[i] = static_cast<CT>(
std::lround(corrected_value));
} else {
@@ -236,15 +235,14 @@ class ClusterFinder {
m_clusters.set_frame_number(frame_number);
const int rows = static_cast<int>(frame.shape(0));
const int cols = static_cast<int>(frame.shape(1));
// TODO! See if we can get the same performace using the operator-
// m_pd_corrected_frame = frame - m_pedestal.view();
//here we should be able to safely assume that the frame and corrected frame have the same size
// here we should be able to safely assume that the frame and corrected
// frame have the same size
auto n_pixels = frame.size();
auto pd = m_pedestal.view().data();
auto corrected = m_pd_corrected_frame.data();
+9 -18
View File
@@ -18,17 +18,17 @@ namespace aare {
template <typename PEDESTAL_TYPE> class FastPedestal {
// Did we accumulate enough samples and updated the mean?
bool m_ready = false;
bool m_ready = false;
uint32_t m_rows;
uint32_t m_cols;
uint32_t m_samples;
double m_inv_samples; // precompute 1/m_samples for faster division
double m_inv_samples; // precompute 1/m_samples for faster division
uint32_t m_cur_samples = 0; // number of samples accumulated so far
// For cache locality we want to keep sum and sum2 close. Improves performance
// for random access.
// For cache locality we want to keep sum and sum2 close. Improves
// performance for random access.
struct Entry {
double sum;
double sum2;
@@ -46,11 +46,11 @@ template <typename PEDESTAL_TYPE> class FastPedestal {
size_t rc_to_index(uint32_t row, uint32_t col) const {
return (static_cast<std::size_t>(row) * m_cols) + col;
}
public:
FastPedestal(uint32_t rows, uint32_t cols, uint32_t n_samples = 1000)
: m_rows(rows), m_cols(cols), m_samples(n_samples),
m_inv_samples(1.0 / n_samples),
m_sum({rows, cols}, Entry{0, 0}),
m_inv_samples(1.0 / n_samples), m_sum({rows, cols}, Entry{0, 0}),
m_mean({rows, cols}, PEDESTAL_TYPE(0)) {
assert(rows > 0 && cols > 0 && n_samples > 0);
}
@@ -64,9 +64,7 @@ template <typename PEDESTAL_TYPE> class FastPedestal {
return m_mean(row, col);
}
PEDESTAL_TYPE mean(ssize_t index) const {
return m_mean[index];
}
PEDESTAL_TYPE mean(ssize_t index) const { return m_mean[index]; }
NDArray<PEDESTAL_TYPE, 2> variance() {
NDArray<PEDESTAL_TYPE, 2> res({m_rows, m_cols});
@@ -102,7 +100,6 @@ template <typename PEDESTAL_TYPE> class FastPedestal {
return std::sqrt(variance(index));
}
bool ready() const { return m_ready; }
uint32_t cur_samples() const { return m_cur_samples; }
@@ -113,7 +110,6 @@ template <typename PEDESTAL_TYPE> class FastPedestal {
m_ready = false;
}
template <typename T> void push(NDView<T, 2> frame) {
if (frame.shape() != std::array<ssize_t, 2>{m_rows, m_cols}) {
throw std::runtime_error(
@@ -164,7 +160,6 @@ template <typename PEDESTAL_TYPE> class FastPedestal {
uint32_t cols() const { return m_cols; }
uint32_t n_samples() const { return m_samples; }
/**
* @brief Update one pixel using its flat index.
*
@@ -180,18 +175,15 @@ template <typename PEDESTAL_TYPE> class FastPedestal {
auto &entry = m_sum[index];
entry.sum += val - entry.sum * m_inv_samples;
entry.sum2 += val * val - entry.sum2 * m_inv_samples;
m_mean[index] =
static_cast<PEDESTAL_TYPE>(entry.sum * m_inv_samples);
m_mean[index] = static_cast<PEDESTAL_TYPE>(entry.sum * m_inv_samples);
}
template <typename T>
void push(const uint32_t row, const uint32_t col, const T val_) {
if (!ready()) {
throw std::runtime_error("Pedestal is not ready, cannot push");
}
const auto index =
(static_cast<std::size_t>(row) * m_cols) + col;
const auto index = (static_cast<std::size_t>(row) * m_cols) + col;
push_fast(index, val_);
}
@@ -216,6 +208,5 @@ template <typename PEDESTAL_TYPE> class FastPedestal {
m_mean[i] = static_cast<PEDESTAL_TYPE>(entry.sum * m_inv_samples);
}
}
};
} // namespace aare
+2 -4
View File
@@ -105,15 +105,13 @@ void PixelHistogramImpl<T, StorageType>::fill_unchecked(int row, int col,
int bin = static_cast<int>((value - m_xmin) * m_scale);
// Guard against floating-point rounding pushing val just below
bin = std::clamp(bin, 0, m_n_bins - 1);
auto& cell = m_values(row, col, bin);
auto &cell = m_values(row, col, bin);
if constexpr (std::is_integral_v<StorageType>) {
if (cell >=
std::numeric_limits<StorageType>::max()) {
if (cell >= std::numeric_limits<StorageType>::max()) {
return;
}
}
++cell;
}
template <typename T, typename StorageType>
-1
View File
@@ -11,7 +11,6 @@
namespace py = pybind11;
using namespace aare;
#pragma GCC diagnostic push
-1
View File
@@ -18,7 +18,6 @@
namespace py = pybind11;
using namespace aare;
#pragma GCC diagnostic push
+2 -2
View File
@@ -27,8 +27,8 @@ void define_ClusterFileSink(py::module &m, const std::string &typestr) {
using ClusterType = Cluster<T, ClusterSizeX, ClusterSizeY, CoordType>;
//TODO! adapt to set pedestal type (needs templating of ClusterFileSink)
//or maybe access through base class?
// TODO! adapt to set pedestal type (needs templating of ClusterFileSink)
// or maybe access through base class?
py::class_<ClusterFileSink<ClusterType>>(m, class_name.c_str())
.def(py::init<ClusterFinderMT<ClusterType, uint16_t, double> *,
const std::filesystem::path &>())
-1
View File
@@ -18,7 +18,6 @@
namespace py = pybind11;
using namespace aare;
#pragma GCC diagnostic push
-1
View File
@@ -18,7 +18,6 @@
namespace py = pybind11;
using namespace aare;
#pragma GCC diagnostic push
-1
View File
@@ -16,7 +16,6 @@
namespace py = pybind11;
using namespace aare;
#pragma GCC diagnostic push
+1 -1
View File
@@ -1,5 +1,5 @@
#pragma once
#include <cstdint>
//Configure module wide pedestal type for cluster finding
// Configure module wide pedestal type for cluster finding
using pd_type = double;