get_direct_beam_position#

Diffraction2D.get_direct_beam_position(method, lazy_output=None, signal_slice=None, half_square_width=None, **kwargs)[source]#

Estimate the direct beam position in each experimentally acquired electron diffraction pattern. Returns the shifts required to center the diffraction pattern.

Parameters:
  • method (str,) – Must be one of “cross_correlate”, “blur”, “interpolate” or “center_of_mass”.

    “cross_correlate”: Center finding using cross-correlation of circles of

    radius_start to radius_finish.

    “blur”: Center finding by blurring each frame with a Gaussian kernel with

    standard deviation sigma and finding the maximum.

    “interpolate”: Finding the center by summing along X/Y and finding the peak

    for each axis independently. Data is blurred first using a Gaussian kernel with standard deviation sigma.

    “center_of_mass”: The center is found using a calculation of the center of mass.

    Optionally a mask can be applied to focus on just the center of some dataset. To suppress contrast from diffuse scattering, a threshold value threshold can also be given. The mean intensity of the diffraction image will be multiplied by this and any values below the product will be set to 0.

  • lazy_output (optional) – If True, s_shifts will be a lazy signal. If False, a non-lazy signal. By default, if the signal is (non-)lazy, the result will also be (non-)lazy.

  • signal_slice (None or tuple) – A tuple defining the (low_x,high_x, low_y, high_y) to slice the data before finding the direct beam. Equivalent to s.isig[low_x:high_x, low_y:high_y].get_direct_beam_position()+[low_x,low_y])

  • half_square_width (int) – Half the side length of square that captures the direct beam in all scans. Means that the centering algorithm is stable against diffracted spots brighter than the direct beam. Crops the diffraction pattern to half_square_width pixels around the center of the diffraction pattern. Only one of half_square_width or signal_slice can be defined.

  • **kwargs – Additional arguments accepted by pyxem.utils.diffraction.find_beam_center_blur(), pyxem.utils.diffraction.find_beam_center_interpolate(), pyxem.utils.diffraction.find_beam_offset_cross_correlation(), and pyxem.signals.diffraction.center_of_mass_from_image(),

Returns:

s_shifts – Array containing the shifts for each SED pattern, with the first signal index being the x-shift and the second the y-shift.

Return type:

pyxem.signals.BeamShift

Examples

Using center of mass method

>>> s = pxm.data.dummy_data.get_disk_shift_simple_test_signal()
>>> s_bs = s.get_direct_beam_position(method="center_of_mass")
>>> s_bs_color = s_bs.get_color_signal()

Also threshold

>>> s_bs = s.get_direct_beam_position(method="center_of_mass", threshold=2)

Get a lazy signal, then calculate afterwards

>>> s_bs = s.get_direct_beam_position(lazy_output=True, method="center_of_mass")
>>> s_bs.compute(show_progressbar=False)