Animations#
abTEM visualizations can be animated over ensemble axes. In this example, we animate a probe over different values of astigmatism. We ramp the astigmatism from \(-70 \ \mathrm{Å}\) to \(70 \ \mathrm{Å}\) and back again at an angle of \(\pi / 4\), with a static value for the defocus of \(70 \ \mathrm{Å}\).
astigmatism = np.linspace(-70, 70, 50)
astigmatism = np.concatenate([astigmatism, astigmatism[:-1][::-1]])
probe = abtem.Probe(
semiangle_cutoff=30,
defocus=70,
astigmatism=astigmatism,
astigmatism_angle=np.pi / 4,
gpts=256,
extent=10,
energy=200e3,
)
probes = probe.build().compute()
VAnimations are created via the .animate method, which can be rendered in HTML using Javascript via the to_jshtml method.
visualization = probes.show(cmap="hsluv", display=False, cbar=True, vmin=0, vmax=8e-5)
animation = visualization.animate(adjust_scale=False, interval=100)
HTML(animation.to_jshtml())
We can switch off the axes and the label, and easily save the animation to disk, for example as a GIF file.
visualization = probes.show(
cmap="hsluv", display=False, cbar=False, vmin=0, vmax=8e-5, figsize=(3, 3))
visualization.axis_off(spines=False)
visualization.adjust_tight_bbox()
animation = visualization.animate(adjust_scale=False, interval=100)
HTML(animation.to_jshtml())
animation.save("../thumbnails/animations.gif", writer="pillow")