Check out the Hyperspy Workshop May 13-17, 2024 Online

center_of_mass#

Diffraction2D.center_of_mass(threshold=None, mask=None, **kwargs)[source]#

Get the centre of the STEM diffraction pattern using center of mass. Threshold can be set to only use the most intense parts of the pattern. A mask can be used to exclude parts of the diffraction pattern.

Parameters:
  • threshold (number, optional) – The thresholding will be done at mean times this threshold value.

  • mask (tuple (x, y, r), optional) – Round mask centered on x and y, with radius r. These are pixel values rather than physical units. Default None which means no mask is used.

Returns:

DPCSignal with beam shifts along the navigation dimension and spatial dimensions as the signal dimension(s).

Return type:

DPCSignal

Examples

With mask centered at x=105, y=120 and 30 pixel radius

>>> s = pxm.data.dummy_data.get_disk_shift_simple_test_signal()
>>> mask = (25, 25, 10)
>>> s_com = s.center_of_mass(mask=mask, show_progressbar=False)
>>> s_color = s_com.get_color_signal()

Also threshold

>>> s_com = s.center_of_mass(threshold=1.5, show_progressbar=False)

Get a lazy signal, then calculate afterwards

>>> s_com = s.center_of_mass(lazy_result=True, show_progressbar=False)
>>> s_com.compute(show_progressbar=False)