diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index c3c823b5..dd2b6824 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -1,6 +1,6 @@ package: name: aare - version: 2024.12.16.dev0 #TODO! how to not duplicate this? + version: 2025.1.7.dev0 #TODO! how to not duplicate this? source: diff --git a/include/aare/ClusterFinder.hpp b/include/aare/ClusterFinder.hpp index 8bd77ccd..aa17d19b 100644 --- a/include/aare/ClusterFinder.hpp +++ b/include/aare/ClusterFinder.hpp @@ -121,8 +121,8 @@ class ClusterFinder { } else if (total > c3 * m_nSigma * rms) { // pass } else { - // m_pedestal.push(iy, ix, frame(iy, ix)); - m_pedestal.push_fast(iy, ix, frame(iy, ix)); + // m_pedestal.push(iy, ix, frame(iy, ix)); // Safe option + m_pedestal.push_fast(iy, ix, frame(iy, ix)); // Assume we have reached n_samples in the pedestal, slight performance improvement continue; // It was a pedestal value nothing to store } @@ -157,114 +157,6 @@ class ClusterFinder { } } } - - // // template - // std::vector - // find_clusters_with_threshold(NDView frame, - // Pedestal &pedestal) { - // assert(m_threshold > 0); - // std::vector clusters; - // std::vector> eventMask; - // for (int i = 0; i < frame.shape(0); i++) { - // eventMask.push_back(std::vector(frame.shape(1))); - // } - // double tthr, tthr1, tthr2; - - // NDArray rest({frame.shape(0), frame.shape(1)}); - // NDArray nph({frame.shape(0), frame.shape(1)}); - // // convert to n photons - // // nph = (frame-pedestal.mean()+0.5*m_threshold)/m_threshold; // can - // be - // // optimized with expression templates? - // for (int iy = 0; iy < frame.shape(0); iy++) { - // for (int ix = 0; ix < frame.shape(1); ix++) { - // auto val = frame(iy, ix) - pedestal.mean(iy, ix); - // nph(iy, ix) = (val + 0.5 * m_threshold) / m_threshold; - // nph(iy, ix) = nph(iy, ix) < 0 ? 0 : nph(iy, ix); - // rest(iy, ix) = val - nph(iy, ix) * m_threshold; - // } - // } - // // iterate over frame pixels - // for (int iy = 0; iy < frame.shape(0); iy++) { - // for (int ix = 0; ix < frame.shape(1); ix++) { - // eventMask[iy][ix] = eventType::PEDESTAL; - // // initialize max and total - // FRAME_TYPE max = std::numeric_limits::min(); - // long double total = 0; - // if (rest(iy, ix) <= 0.25 * m_threshold) { - // pedestal.push(iy, ix, frame(iy, ix)); - // continue; - // } - // eventMask[iy][ix] = eventType::NEIGHBOUR; - // // iterate over cluster pixels around the current pixel - // (ix,iy) for (short ir = -(m_cluster_sizeY / 2); - // ir < (m_cluster_sizeY / 2) + 1; ir++) { - // for (short ic = -(m_cluster_sizeX / 2); - // ic < (m_cluster_sizeX / 2) + 1; ic++) { - // if (ix + ic >= 0 && ix + ic < frame.shape(1) && - // iy + ir >= 0 && iy + ir < frame.shape(0)) { - // auto val = frame(iy + ir, ix + ic) - - // pedestal.mean(iy + ir, ix + ic); - // total += val; - // if (val > max) { - // max = val; - // } - // } - // } - // } - - // auto rms = pedestal.std(iy, ix); - // if (m_nSigma == 0) { - // tthr = m_threshold; - // tthr1 = m_threshold; - // tthr2 = m_threshold; - // } else { - // tthr = m_nSigma * rms; - // tthr1 = m_nSigma * rms * c3; - // tthr2 = m_nSigma * rms * c2; - - // if (m_threshold > 2 * tthr) - // tthr = m_threshold - tthr; - // if (m_threshold > 2 * tthr1) - // tthr1 = tthr - tthr1; - // if (m_threshold > 2 * tthr2) - // tthr2 = tthr - tthr2; - // } - // if (total > tthr1 || max > tthr) { - // eventMask[iy][ix] = eventType::PHOTON; - // nph(iy, ix) += 1; - // rest(iy, ix) -= m_threshold; - // } else { - // pedestal.push(iy, ix, frame(iy, ix)); - // continue; - // } - // if (eventMask[iy][ix] == eventType::PHOTON && - // frame(iy, ix) - pedestal.mean(iy, ix) >= max) { - // eventMask[iy][ix] = eventType::PHOTON_MAX; - // DynamicCluster cluster(m_cluster_sizeX, m_cluster_sizeY, - // Dtype(typeid(FRAME_TYPE))); - // cluster.x = ix; - // cluster.y = iy; - // short i = 0; - // for (short ir = -(m_cluster_sizeY / 2); - // ir < (m_cluster_sizeY / 2) + 1; ir++) { - // for (short ic = -(m_cluster_sizeX / 2); - // ic < (m_cluster_sizeX / 2) + 1; ic++) { - // if (ix + ic >= 0 && ix + ic < frame.shape(1) && - // iy + ir >= 0 && iy + ir < frame.shape(0)) { - // auto tmp = frame(iy + ir, ix + ic) - - // pedestal.mean(iy + ir, ix + ic); - // cluster.set(i, tmp); - // i++; - // } - // } - // } - // clusters.push_back(cluster); - // } - // } - // } - // return clusters; - // } }; } // namespace aare \ No newline at end of file diff --git a/include/aare/Pedestal.hpp b/include/aare/Pedestal.hpp index bda94f21..ab73cb9b 100644 --- a/include/aare/Pedestal.hpp +++ b/include/aare/Pedestal.hpp @@ -165,8 +165,8 @@ template class Pedestal { m_sum2(row, col) += val * val; m_cur_samples(row, col)++; } else { - m_sum(row, col) += val - m_sum(row, col) / m_cur_samples(row, col); - m_sum2(row, col) += val * val - m_sum2(row, col) / m_cur_samples(row, col); + m_sum(row, col) += val - m_sum(row, col) / m_samples; + m_sum2(row, col) += val * val - m_sum2(row, col) / m_samples; } //Since we just did a push we know that m_cur_samples(row, col) is at least 1 m_mean(row, col) = m_sum(row, col) / m_cur_samples(row, col); diff --git a/pyproject.toml b/pyproject.toml index b8390030..35bdefba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "aare" -version = "2024.12.16.dev0" +version = "2025.1.7.dev0" [tool.scikit-build] cmake.verbose = true