From 0fa134bda06a07ceaa8719d6cd0aa85f053efe7b Mon Sep 17 00:00:00 2001 From: nieves Date: Tue, 16 Jan 2024 13:36:41 +0100 Subject: [PATCH] speed up code a bit --- ctapipe/image/cleaning.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ctapipe/image/cleaning.py b/ctapipe/image/cleaning.py index cea13d50869..2fff00d563a 100644 --- a/ctapipe/image/cleaning.py +++ b/ctapipe/image/cleaning.py @@ -434,7 +434,9 @@ def tailcuts_hysteresis_clean( # matrix (2d), we find all pixels that are above the boundary threshold # AND have any neighbor that is in the picture pixels_above_boundary = image >= boundary_thresh - + pixels_with_boundary_neighbors = geom.neighbor_matrix_sparse.dot( + pixels_above_boundary + ) for count in range(max_iter): pixels_in_picture_previous = pixels_in_picture.copy() pixels_with_picture_neighbors = geom.neighbor_matrix_sparse.dot( @@ -445,9 +447,6 @@ def tailcuts_hysteresis_clean( pixels_above_boundary & pixels_with_picture_neighbors ) | pixels_in_picture else: - pixels_with_boundary_neighbors = geom.neighbor_matrix_sparse.dot( - pixels_above_boundary - ) pixels_in_picture = ( pixels_above_boundary & pixels_with_picture_neighbors ) | (pixels_in_picture & pixels_with_boundary_neighbors)