ChooseLattice#
ChooseLattice displays a single 2D image and lets you click an ordered
origin, a1, and a2 on it. The picked pixel coordinates and the derived
lattice vectors u = a1 - origin and v = a2 - origin are exposed for
downstream lattice calculations.
Tip
Run this exact notebook with the Colab badge above, or View or download this notebook on GitHub.
Pick the lattice points#
Click the origin, then a1, then a2 on the image below. Wheel-zoom and
drag-pan to line the click up with a specific feature, then drag an existing
point to nudge it. Use the Clear Points button to start over.
from quantem.widget import ChooseLattice
widget = ChooseLattice(image, cmap="inferno", title="Synthetic atomic lattice")
widget
Read back the picked points#
origin, a1, and a2 are the raw (row, col) clicks; u and v are the
derived lattice vectors a1 - origin and a2 - origin. All five are None
until enough points are placed. Click the three points above first, then run
the cell below yourself (it is skipped during the automated docs build since
it depends on a live click).
print(f"origin: {tuple(round(x, 2) for x in widget.origin)}")
print(f"u: {tuple(round(x, 2) for x in widget.u)}")
print(f"v: {tuple(round(x, 2) for x in widget.v)}")
widget.points_array returns the same picks as an (n, 2) NumPy array, and
widget.clear_points() (or the Clear Points button) resets them.