PixelHistogram

PixelHistogram accumulates one histogram per detector pixel from 2D float64 images. The public PixelHistogram name is an alias for PixelHistogram_d, which stores bin counts as float64.

Note

PixelHistogram is designed for fast filling from 2D images, utilizing multiple threads, and contiguous storage of a specific type. No over/underflow bins are provided. For generic use cases consider boost-histogram. (https://boost-histogram.readthedocs.io/en/latest/)

Storage-specific variants are also available when a smaller or integer count type is preferred:

  • PixelHistogram_d: float64 storage

  • PixelHistogram_f: float32 storage

  • PixelHistogram_u64: uint64 storage

  • PixelHistogram_u32: uint32 storage

  • PixelHistogram_u16: uint16 storage

  • PixelHistogram_u8: uint8 storage

aare.PixelHistogram

alias of PixelHistogram_d

Showing API for PixelHistogram_d, all variant share the same API.

class aare._aare.PixelHistogram_d

Bases: pybind11_object

A histogram for pixel-wise statistics with float64 input axis and float64 bin storage

bin_centers(self: aare._aare.PixelHistogram_d) numpy.ndarray

Get the bin centers along the value axis.

Returns:

A 1D numpy array containing the center values for each histogram bin

bin_edges(self: aare._aare.PixelHistogram_d) numpy.ndarray

Get the bin edges along the value axis.

Returns:

A 1D numpy array containing the edge values for the histogram bins

fill_async(self: aare._aare.PixelHistogram_d, image: numpy.typing.NDArray[numpy.float64]) None

Submit an image for asynchronous filling.

The image is copied into an internal buffer before this call returns, so the caller may mutate or free the numpy array immediately. The actual histogram update happens on a background thread. If the internal queue is full this call blocks (with the GIL released) until a slot becomes available.

Parameters:

image – A 2D numpy array of pixel values (dtype: float64)

flush(self: aare._aare.PixelHistogram_d) None

Block until all images submitted via fill_async() have been merged into the accumulators. Cheap when nothing is pending.

values(self: aare._aare.PixelHistogram_d) numpy.ndarray

Get the histogram data as a numpy array.

Implicitly flushes any pending asynchronous fills before returning, so the snapshot is consistent with everything submitted up to this call.

Returns:

A 3D numpy array containing the histogram bins for each pixel