mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-08-05 22:02:24 +02:00
fixed failing test
This commit is contained in:
@@ -54,13 +54,21 @@ class ClusterFinder {
|
||||
c2(sqrt((ClusterSizeY + 1) / 2 * (ClusterSizeX + 1) / 2)),
|
||||
c3(sqrt(ClusterSizeX * ClusterSizeY)),
|
||||
m_pedestal(image_size[0], image_size[1]), m_clusters(capacity),
|
||||
m_threshold({image_size[0], image_size[1]}, 0),
|
||||
m_pd_corrected_frame({image_size[0], image_size[1]}, 0) {
|
||||
LOG(logDEBUG) << "ClusterFinder: "
|
||||
<< "image_size: " << image_size[0] << "x" << image_size[1]
|
||||
<< ", nSigma: " << nSigma << ", capacity: " << capacity;
|
||||
}
|
||||
|
||||
void set_nSigma(PEDESTAL_TYPE nSigma) { m_nSigma = nSigma; }
|
||||
/**
|
||||
* @brief Set the nSigma parameter and update the threshold.
|
||||
* @param nSigma the new nSigma parameter.
|
||||
*/
|
||||
void set_nSigma(PEDESTAL_TYPE nSigma) {
|
||||
m_nSigma = nSigma;
|
||||
update_threshold();
|
||||
}
|
||||
|
||||
PEDESTAL_TYPE get_nSigma() const { return m_nSigma; }
|
||||
|
||||
@@ -227,6 +235,10 @@ class ClusterFinder {
|
||||
// // TODO! deal with even size clusters
|
||||
// // currently 3,3 -> +/- 1
|
||||
// // 4,4 -> +/- 2
|
||||
if (!m_pedestal.ready()) {
|
||||
throw std::runtime_error(
|
||||
"Pedestal is not ready, cannot find clusters");
|
||||
}
|
||||
|
||||
constexpr int dy = ClusterSizeY / 2;
|
||||
constexpr int dx = ClusterSizeX / 2;
|
||||
|
||||
@@ -103,15 +103,18 @@ def test_max_sum():
|
||||
|
||||
def test_cluster_finder():
|
||||
"""Test ClusterFinder"""
|
||||
shape = [100,100]
|
||||
cf = _aare.ClusterFinder_Cluster3x3i(shape)
|
||||
|
||||
clusterfinder = _aare.ClusterFinder_Cluster3x3i([100,100])
|
||||
#Push 1000 frames to the pedestal
|
||||
for i in range(1000):
|
||||
frame = np.random.normal(loc = 100, scale = 5, size = shape).astype(np.uint16)
|
||||
cf.push_pedestal_frame(frame)
|
||||
cf.update_threshold()
|
||||
frame = np.zeros(shape=shape, dtype=np.uint16)
|
||||
cf.find_clusters(frame)
|
||||
|
||||
#frame = np.random.rand(100,100)
|
||||
frame = np.zeros(shape=[100,100])
|
||||
|
||||
clusterfinder.find_clusters(frame)
|
||||
|
||||
clusters = clusterfinder.steal_clusters(False) #conversion does not work
|
||||
clusters = cf.steal_clusters(False) #conversion does not work
|
||||
|
||||
assert clusters.size == 0
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ def test_fast_pedestal_initialization(pedestal_type, expected_dtype):
|
||||
|
||||
pedestal.push_init(first)
|
||||
pedestal.push_init(second)
|
||||
pedestal.update_mean()
|
||||
|
||||
|
||||
expected_mean = np.array(
|
||||
[[3, 5, 7], [9, 11, 13]], dtype=expected_dtype
|
||||
@@ -28,7 +28,7 @@ def test_fast_pedestal_steady_state_push():
|
||||
pedestal = FastPedestal_d(1, 2, 2)
|
||||
pedestal.push_init(np.array([[2, 4]], dtype=np.uint16))
|
||||
pedestal.push_init(np.array([[4, 6]], dtype=np.uint16))
|
||||
pedestal.update_mean()
|
||||
|
||||
|
||||
pedestal.push(np.array([[6, 8]], dtype=np.uint16))
|
||||
|
||||
@@ -38,7 +38,7 @@ def test_fast_pedestal_steady_state_push():
|
||||
def test_fast_pedestal_exposes_read_only_buffer_and_subtraction():
|
||||
pedestal = FastPedestal_d(1, 2, 1)
|
||||
pedestal.push_init(np.array([[2, 4]], dtype=np.uint16))
|
||||
pedestal.update_mean()
|
||||
|
||||
|
||||
view = np.asarray(pedestal)
|
||||
result = np.array([[12, 14]], dtype=np.uint16) - pedestal
|
||||
|
||||
Reference in New Issue
Block a user