4D-STEM quickstart

Hide code cell source
%config InlineBackend.rc = {"figure.dpi": 72, "figure.figsize": (6.0, 4.0)}
%matplotlib inline

import abtem
import ase
import matplotlib.pyplot as plt
from ase.io import write

4D-STEM quickstart#

abtem.config.set({"device": "cpu"})
<abtem.core.config.set at 0x21a4e10ff40>
atoms = ase.build.mx2(vacuum=2)

atoms = abtem.orthogonalize_cell(atoms)

atoms *= (3, 2, 1)

abtem.show_atoms(atoms)
(<Figure size 432x288 with 1 Axes>,
 <AxesSubplot: xlabel='x [Å]', ylabel='y [Å]'>)
../../../_images/9016acb89f51f62d33fcaf962adfad21f0f6b8242dcd7f2e7fbb9160f494b30f.png
potential = abtem.Potential(atoms, sampling=0.05)

probe = abtem.Probe(energy=80e3, semiangle_cutoff=30)
probe.grid.match(potential)
grid_scan = abtem.GridScan.from_fractional_coordinates(
    potential,
    start=[0, 0],
    end=[1 / 3, 1 / 2],
    sampling=probe.aperture.nyquist_sampling,
)
detector = abtem.PixelatedDetector()

measurements = probe.scan(potential, scan=grid_scan, detectors=detector)
measurements.array
Array Chunk
Bytes 5.60 MiB 5.60 MiB
Shape (10, 16, 89, 103) (10, 16, 89, 103)
Dask graph 1 chunks in 8 graph layers
Data type float32 numpy.ndarray
10 1 103 89 16
measurements.compute()
[########################################] | 100% Completed | 5.23 sms
<abtem.measurements.DiffractionPatterns object at 0x0000021A57CD9AB0>
filtered_measurements = measurements.gaussian_source_size(.3)

center_of_mass = filtered_measurements.center_of_mass()

interpolated_center_of_mass = center_of_mass.interpolate(0.05).tile((3, 2))

interpolated_center_of_mass.show(cbar=True, vmax=0.04, vmin=0);
../../../_images/52312b8f94fd550719fd7c2fa7acc75002a0492f48d71c4db46b4c98f06d1353.png