pyextal.acom.detect =================== .. py:module:: pyextal.acom.detect .. autoapi-nested-parse:: Bragg peak detection in an averaged diffraction pattern. Functions --------- .. autoapisummary:: pyextal.acom.detect.detect_peaks pyextal.acom.detect.direct_beam Module Contents --------------- .. py:function:: 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. :param image: 2D averaged diffraction pattern. :type image: np.ndarray :param min_distance: Smallest separation between peaks, in pixels. Defaults to 4. :type min_distance: int, optional :param threshold_rel: Peak height floor as a fraction of the brightest pixel. Defaults to 0.02. :type threshold_rel: float, optional :param num_peaks: Most peaks to return. Defaults to 200. :type num_peaks: int, optional :param refine: Fit a 2D Gaussian to each peak for sub-pixel accuracy. Defaults to True. :type refine: bool, optional :param crop: Half-width of the patch fitted per peak. Defaults to 5. :type crop: int, optional :returns: ``(positions, intensities)`` -- (n, 2) float pixel coordinates in (x, y) = (row, col) detector convention, and the peak height at each. :rtype: tuple[np.ndarray, np.ndarray] .. py:function:: direct_beam(positions, intensities, hint=None, search=8.0) Picks the direct beam from a set of detected peaks. :param positions: (n, 2) peak positions. :type positions: np.ndarray :param intensities: (n,) peak heights. :type intensities: np.ndarray :param hint: Approximate position; the nearest peak within `search` pixels is taken. The brightest peak is used when None. :type hint: tuple[float, float], optional :param search: Radius around `hint`, in pixels. Defaults to 8. :type search: float, optional :returns: Index into `positions`, and the position itself. :rtype: tuple[int, np.ndarray] :raises ValueError: If no peak was found, or none lies near `hint`.