Magnetic DPC#

This example shows a basic workflow for doing magnetic DPC on a simple simulated test dataset. The dataset consists of alternating stripes of switching magnetic fields resulting in reversals of the direction of the magnetic field.

This is a generalization of some of the real datasets which are more completely analyzed in the longer Demo Notebooks.

import pyxem as pxm

s = pxm.data.simulated_stripes()

s_beam_pos = s.get_direct_beam_position(
    method="center_of_mass", half_square_width=20
)  # Just the center of the DP
  0%|          | 0/49 [00:00<?, ?it/s]
 65%|██████▌   | 32/49 [00:00<00:00, 314.18it/s]
100%|██████████| 49/49 [00:00<00:00, 254.14it/s]

Visualizing the Shifts#

The shifts can be visualized using the plot() method which shows both the x and y shifts in a single plot.

x-shift, y-shift
[<Axes: title={'center': 'x-shift'}, xlabel='x axis (px)', ylabel='y axis (px)'>, <Axes: title={'center': 'y-shift'}, xlabel='x axis (px)', ylabel='y axis (px)'>]

Visualizing the Shifts as color signal#

To plot the shifts in one signal, with the color showing the magnitude and direction.

Signal

Plotting Magnitude and Direction#

Since each probe position is a vector, we can plot the magnitude and phase (direction).

  • Magnitude of  Signal
  • Signal
  0%|          | 0/33 [00:00<?, ?it/s]
100%|██████████| 33/33 [00:00<00:00, 3120.69it/s]

Plotting the bivariate histogram#

The shifts vectors can also be visualized as a histogram

Bivariate histogram of  Signal

Plotting with matplotlib#

Pyxem also provides a convenient way to plot the magnitude and phase of the beam shifts using matplotlib. This is useful for creating publication-ready figures.

import matplotlib.pyplot as plt
from pyxem.utils.plotting import plot_beam_shift_color

fig, axs = plt.subplots(1, 1)
inset = axs.inset_axes([0.06, 0.57, 0.2, 0.2])
plot_beam_shift_color(
    s_beam_pos,
    phase_rotation=45,
    autolim=True,
    autolim_sigma=3,
    ax_indicator=inset,
    ax=axs,
)

fig, axs = plt.subplots(1, 1)
inset = axs.inset_axes([0.06, 0.57, 0.2, 0.2])
plot_beam_shift_color(
    s_beam_pos,
    phase_rotation=45,
    autolim=True,
    autolim_sigma=3,
    ax_indicator=inset,
    only_phase=True,
    ax=axs,
)

# sphinx_gallery_thumbnail_number = 3
  • magnetic dpc
  • magnetic dpc
  • x-shift, y-shift, x-shift
<Figure size 640x480 with 1 Axes>

Total running time of the script: (0 minutes 1.765 seconds)

Gallery generated by Sphinx-Gallery