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

make_linear_plane#

BeamShift.make_linear_plane(mask=None)[source]#

Fit linear planes to the beam shifts, which replaces the original data.

In many scanning transmission electron microscopes, the center position of the diffraction pattern will change as a function of the scan position. This is most apparent when scanning over large regions (100+ nanometers). Thus, when working with datasets, it is typically necessary to correct for this. However, other effects can also affect the apparent center point, like diffraction contrast. So while it is possible to correct for the beam shift by finding the center position in each diffraction pattern, this can lead to features such as interfaces or grain boundaries affecting the centering of the diffraction pattern. As the shift caused by the scan system is a slow and monotonic, it can often be approximated by fitting linear planes to the x- and y- beam shifts.

In addition, for regions within the scan where the center point of the direct beam is hard to ascertain precisely, for example in very thick or heavily diffracting regions, a mask can be used to ignore fitting the plane to these regions.

This method does this, and replaces the original beam shift data with these fitted planes. The beam shift signal can then be directly used in the center_direct_beam() method.

Note that for very large regions, this linear plane will probably not approximate the beam shift very well. In those cases a higher order plane will likely be necessary. Alternatively, a vacuum scan with exactly the same scanning parameters should be used.

Parameters:

mask (HyperSpy signal, optional) – Must be the same shape as the navigation dimensions of the beam shift signal. The True values will be masked.

Examples

>>> s = pxm.signals.BeamShift(np.random.randint(0, 99, (100, 120, 2)))
>>> s_mask = hs.signals.Signal2D(np.zeros((100, 120), dtype=bool))
>>> s_mask.data[20:-20, 20:-20] = True
>>> s.make_linear_plane(mask=s_mask)