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

center_direct_beam#

Diffraction2D.center_direct_beam(method=None, shifts=None, return_shifts=False, subpixel=True, lazy_output=None, align_kwargs=None, inplace=True, *args, **kwargs)[source]#

Estimate the direct beam position in each experimentally acquired electron diffraction pattern and translate it to the center of the image square.

Parameters:
  • method (str {‘cross_correlate’, ‘blur’, ‘interpolate’, ‘center_of_mass’}) – Method used to estimate the direct beam position. The direct beam position can also be passed directly with the shifts parameter.

  • shifts (Signal, optional) – The position of the direct beam, which can either be passed with this parameter (shifts), or calculated on its own. Both shifts and the signal need to have the same navigation shape, and shifts needs to have one signal dimension with size 2.

  • return_shifts (bool, default False) – If True, the values of applied shifts are returned

  • subpixel (bool, optional) – If True, the data will be interpolated, allowing for subpixel shifts of the diffraction patterns. This can lead to changes in the total intensity of the diffraction images, see Notes for more information. If False, the data is not interpolated. Default True.

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

  • align_kwargs (dict) – Parameters passed to the alignment function. See scipy.ndimage.shift for more information about the parameters.

  • *args, **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(), pyxem.signals.diffraction2d.Diffraction2D.get_direct_beam_position(), and pyxem.signals.diffraction2d.Diffraction2D.center_of_mass(),

Example

>>> s.center_direct_beam(method='blur', sigma=1)

Using the shifts parameter

>>> s_shifts = s.get_direct_beam_position(
...    method="interpolate", sigma=1, upsample_factor=2, kind="nearest")
>>> s.center_direct_beam(shifts=s_shifts)

Notes

If the signal has an integer dtype, and subpixel=True is used (the default) the total intensity in the diffraction images will most likely not be preserved. This is due to subpixel=True utilizing interpolation. To keep the total intensity use a float dtype, which can be done by s.change_dtype('float32', rechunk=False).