peak_position_refinement_com#
- Diffraction2D.peak_position_refinement_com(peak_array, square_size=10, lazy_result=True, show_progressbar=True)[source]#
Refines the peak position using the center of mass.
- Parameters:
peak_array (Numpy or Dask array) – Object with x and y coordinates of the peak positions. Must have the same dimensions as this signal’s navigation dimensions.
square_size (int) – Even integer, sub image from which the center of mass is calculated. Default 5.
lazy_result (bool, default True) – If True, will return a LazyDiffraction2D object. If False, will compute the result and return a Diffraction2D object.
show_progressbar (bool, default True)
- Returns:
output_array – Same size as the two last dimensions in data, in the form [[y0, x0], [y1, x1], …]. The peak positions themselves are stored in 2D NumPy arrays inside each position in peak_array. This is done instead of making a 4D NumPy array, since the number of found peaks can vary in each position.
- Return type:
dask 2D object array
Examples
>>> s = pxm.data.dummy_data.get_cbed_signal() >>> peak_array = s.find_peaks_lazy() >>> refined_peak_array = s.peak_position_refinement_com(peak_array, 20) >>> refined_peak_array_com = refined_peak_array.compute( ... show_progressbar=False) >>> s.add_peak_array_as_markers(refined_peak_array_com) >>> s.plot()