hexsample.clustering — Clustering facilities#

Module documentation#

Clustering facilities.

class hexsample.clustering.Cluster(x: ndarray, y: ndarray, pha: ndarray)#

Small container class describing a cluster.

x: ndarray#
y: ndarray#
pha: ndarray#
size() int#

Return the size of the cluster.

pulse_height() float#

Return the total pulse height of the cluster.

centroid() Tuple[float, float]#

Return the cluster centroid.

class hexsample.clustering.ClusteringBase(grid: HexagonalGrid, zero_sup_threshold: float)#

Base class for the clustering.

grid: HexagonalGrid#
zero_sup_threshold: float#
zero_suppress(array: ndarray) ndarray#

Zero suppress a generic array.

run(event: DigiEventRectangular) Cluster#

Workhorse method to be reimplemented by derived classes.

class hexsample.clustering.ClusteringNN(grid: HexagonalGrid, zero_sup_threshold: float, num_neighbors: int)#

Neirest neighbor clustering.

This is a very simple clustering strategy where we use the highest pixel in the event as a seed, loop over the six neighbors (after the zero suppression) and keep the N highest pixels.

Parameters:

num_neighbors (int) – The number of neighbors (between 0 and 6) to include in the cluster.

num_neighbors: int#
run(event) Cluster#

Overladed method.

Warning

The loop ever the neighbors might likely be vectorized and streamlined for speed using proper numpy array for the offset indexes.