pyextal.acom.detect

Bragg peak detection in an averaged diffraction pattern.

Functions

detect_peaks(image[, min_distance, threshold_rel, ...])

Finds Bragg peaks and refines them to sub-pixel positions.

direct_beam(positions, intensities[, hint, search])

Picks the direct beam from a set of detected peaks.

Module Contents

pyextal.acom.detect.detect_peaks(image, min_distance=4, threshold_rel=0.02, num_peaks=200, refine=True, crop=5)

Finds Bragg peaks and refines them to sub-pixel positions.

Parameters:
  • image (np.ndarray) – 2D averaged diffraction pattern.

  • min_distance (int, optional) – Smallest separation between peaks, in pixels. Defaults to 4.

  • threshold_rel (float, optional) – Peak height floor as a fraction of the brightest pixel. Defaults to 0.02.

  • num_peaks (int, optional) – Most peaks to return. Defaults to 200.

  • refine (bool, optional) – Fit a 2D Gaussian to each peak for sub-pixel accuracy. Defaults to True.

  • crop (int, optional) – Half-width of the patch fitted per peak. Defaults to 5.

Returns:

(positions, intensities) – (n, 2) float pixel coordinates in (x, y) = (row, col) detector convention, and the peak height at each.

Return type:

tuple[np.ndarray, np.ndarray]

pyextal.acom.detect.direct_beam(positions, intensities, hint=None, search=8.0)

Picks the direct beam from a set of detected peaks.

Parameters:
  • positions (np.ndarray) – (n, 2) peak positions.

  • intensities (np.ndarray) – (n,) peak heights.

  • hint (tuple[float, float], optional) – Approximate position; the nearest peak within search pixels is taken. The brightest peak is used when None.

  • search (float, optional) – Radius around hint, in pixels. Defaults to 8.

Returns:

Index into positions, and the position itself.

Return type:

tuple[int, np.ndarray]

Raises:

ValueError – If no peak was found, or none lies near hint.