check ready before updating pd (#391)
Build on RHEL9 / build (push) Successful in 2m49s
Build on RHEL8 / build (push) Successful in 3m29s
Run tests using data on local RHEL8 / build (push) Failing after 4m37s
Build on local RHEL8 / build (push) Successful in 3m16s

- For set_nSigma only call update_pedestal if we have accumulated enough
samples otherwise just write it
- For update threshold check if pd is ready and if not throw

closes #390
This commit is contained in:
Erik Fröjdh
2026-09-30 14:54:59 +02:00
committed by GitHub
parent 941325ea15
commit 2efdd17d81
8 changed files with 177 additions and 12 deletions
+4
View File
@@ -55,6 +55,10 @@ void define_ClusterFinder(py::module &m, const std::string &typestr) {
&ClusterFinder<ClusterType, uint16_t, pd_type>::clear_pedestal)
.def("update_threshold",
&ClusterFinder<ClusterType, uint16_t, pd_type>::update_threshold)
.def_property_readonly(
"pedestal_ready",
&ClusterFinder<ClusterType, uint16_t, pd_type>::pedestal_ready,
R"(True once enough pedestal frames have been pushed to find clusters.)")
.def_property_readonly(
"pedestal",
[](ClusterFinder<ClusterType, uint16_t, pd_type> &self) {
+4
View File
@@ -62,6 +62,10 @@ void define_ClusterFinderMT(py::module &m, const std::string &typestr) {
&ClusterFinderMT<ClusterType, uint16_t, pd_type>::clear_pedestal)
.def("update_threshold",
&ClusterFinderMT<ClusterType, uint16_t, pd_type>::update_threshold)
.def(
"pedestal_ready",
&ClusterFinderMT<ClusterType, uint16_t, pd_type>::pedestal_ready,
R"(waits for the queued frames, then returns True if all cluster finders have enough pedestal frames to find clusters.)")
.def("sync", &ClusterFinderMT<ClusterType, uint16_t, pd_type>::sync)
.def("stop", &ClusterFinderMT<ClusterType, uint16_t, pd_type>::stop)
.def("start", &ClusterFinderMT<ClusterType, uint16_t, pd_type>::start)
+37
View File
@@ -135,6 +135,43 @@ def test_cluster_finder():
assert clusters.size == 0
def test_cluster_finder_set_nSigma_before_pedestal_is_ready():
shape = [10, 10]
n_samples = 4
cf = _aare.ClusterFinder_Cluster3x3i(shape, min_pedestal_samples=n_samples)
assert not cf.pedestal_ready
cf.nSigma = 50
assert cf.nSigma == 50
# Pedestal of 100 with a noise of 2
for i in range(n_samples):
cf.push_pedestal_frame(np.full(shape, 98 + 4 * (i % 2), dtype=np.uint16))
assert cf.pedestal_ready
# 30 ADU is a cluster at the default nSigma of 5 but not at 50
frame = np.full(shape, 100, dtype=np.uint16)
frame[5, 5] = 130
cf.find_clusters(frame)
assert cf.steal_clusters().size == 0
def test_cluster_finder_mt_set_nSigma_before_pedestal_is_ready():
shape = [10, 10]
n_samples = 4
cf = _aare.ClusterFinderMT_Cluster3x3i(
shape, n_threads=2, min_pedestal_samples=n_samples
)
assert not cf.pedestal_ready()
cf.set_nSigma(50)
for i in range(n_samples):
cf.push_pedestal_frame(np.full(shape, 98 + 4 * (i % 2), dtype=np.uint16))
assert cf.pedestal_ready()
cf.stop()
def test_2x2_reduction():
"""Test 2x2 Reduction"""
cluster = _aare.Cluster3x3i(5,5,np.array([1, 1, 1, 2, 3, 1, 2, 2, 1], dtype=np.int32))