LazyLEED

Documentation

Analysis of low-energy electron diffraction (LEED) patterns: simulate the spot pattern of one or more 2D lattices, find and refine the spots in a measured image, and fit the device calibration, lattice parameters and epitaxy matrices with full error propagation. The same analysis works on Fourier-transformed STM images, in a separate workspace. It is a Python rebuild of an older MATLAB program. The physics model is kept compatible with it, but the code and the interface are new.

Workflow

The analysis steps are panels that are all visible at the same time, not a next/previous wizard. You can go back and forth freely.

Where What
Left: Structures Any number of lattices. Each is defined either by lattice parameters (a, b, γ, φ) or by an epitaxy matrix on a reference structure (V = M·V_ref). Further settings: rotational/mirror domains, glide planes, multiple scattering, colour, unit cell.
Centre: Viewer Image with live overlay: simulation, unit cells, refined spots, residual vectors, indices. Tools: Navigate (V), Align (A: drag to move · Shift-drag to rotate · Alt-drag to scale), Centre (C), Circle centre fit (O), Add/Remove spot (S/X). Arrow keys move the centre, [ ] rotate, - = scale.
Right: Experiment & device Beam energy, calibration factor, energy offset, centre, rotation. Auto-align searches rotation, scale and centre around the current values (align roughly by hand first).
Right: Image Display (brightness, contrast, gamma, log, colour maps) and analysis preprocessing (invert, median, difference-of-Gaussians background removal).
Right: Spot detection Per-structure fit box, search, background, rejection criteria. Then Find & refine spots.
Right: Lattice fit Presets or free choice of any parameter, followed by Run fit and Apply to model.
Right: Epitaxy analysis Fitted matrix with errors and classification (commensurate / higher-order commensurate / on-line coincident / incommensurate).
Bottom drawer Spot table (toggle spots), full fit report, real-space view of the lattices, log.

A typical iteration is: align roughly, refine spots, fit the calibration on the substrate, apply, refine again, fit the lattice or epitaxy matrix, apply. Try File → Load demo pattern for a synthetic pattern with known ground truth.

Energy from the file name. When an image is opened, a beam energy written in its name is used automatically: …_E=80(5)eV.png (the digit in brackets is the decimal, i.e. 80.5 eV), E=80.5eV, 80,5eV, E_80p5, LEED 96 eV. The log says when this happened. Switch it off with Energy from file name in the Experiment & device card.

Files: projects are saved as .leed (a zip containing JSON and the image). Legacy .soj, .dev, .sim and .emm files are imported directly. Exports: spot table (CSV), fit report (TXT), device calibration (JSON), view (PNG).

Distortion calibration

LEED images are distorted: the projection onto the screen, the camera optics and stray fields give a radially symmetric distortion (pincushion or barrel), sometimes a compressed image axis, and smaller asymmetric parts. In addition, the set beam energy differs from the true kinetic energy. LazyLEED corrects both following F. Sojka, M. Meissner, C. Zwick, R. Forker, T. Fritz, Rev. Sci. Instrum. 84, 015111 (2013).

Calibration is a separate workspace (header switch Analysis | Distortion calibration, amber accent), with its own image, structures and spots, so it never interferes with an analysis:

  1. Calibration pattern. Open an image of a well-known surface (Si(111)-7×7 is ideal: many sharp spots), recorded at the same sample distance as the measurements, and choose the reference surface.
  2. Radial distortion. Refine the spots, then Fit distortion. This fits nine parameters: lattice centre, rotation, scaling, D = a·s³ + b·s⁵ (s normalised to the image size), the distortion centre and the y/x axis ratio. Refine and fit again until the rms is stable; the simulation now follows the distorted spots. The Distortion grid layer shows the map.
  3. Asymmetric distortion (optional). The remaining deviations are approximated by a smoothing multiquadric RBF field. The smoothing is chosen by cross-validation, and the field is shown as vectors.
  4. Energy calibration (optional). Load images of the calibration sample at several energies, refine the spots and Add this image for each. Fit CF and E₀ then fits scal(E) = CF/√(E_set + E₀).

For a whole energy series, use Add image series… and select all images at once. The energy of each image is read from its file name, the pattern is followed from the previous image, the spots are refined, and the image is added. Then run Joint fit of all images. This fits one radial distortion for all images, because the distortion belongs to the device and not to the energy, with centre, rotation and scaling per image. The asymmetric field is built from the pooled residuals; its smoothing is chosen by leave-one-image-out validation, so it only keeps what is reproducible from image to image. Finally, CF and E₀ are fitted with the scaling of every image re-determined on the complete model. This is much more robust than one image when the spots are weak or broad. 5. Profile. Preview the corrected image, Save profile (JSON), and Use for analysis.

In the analysis workspace, the Distortion correction card switches the correction on or off. When it is on, spots are refined on the resampled, distortion-free image, and CF and E₀ come from the profile. Profiles are stored in .leed projects and can be loaded for later sessions with the same device. File → Load demo pattern from a distorted device together with the synthetic Si(111)-7×7 example in the calibration workspace shows the whole procedure on data with a known truth.

Publication figure

Export → Publication figure… (LEED analysis workspace) creates a figure ready for a paper, as PDF, SVG (text stays editable) or PNG:

  • Left: the pattern, cut to the screen. The screen circle is detected automatically and can be corrected in the dialog.
  • The upper half (above the (0,0) beam) shows the simulated spots of the chosen structures; the lower half shows the bare measurement.
  • The beam energy is written on the electron gun.
  • The image uses the current colour map and display settings.
  • Right: the results of the last fit. For each structure: the lattice parameters a, b, γ, φ (and the area). Then the epitaxy matrices. Then the type of coincidence, with the lowest-order coincidence. Errors are 1σ, written in brackets in the last digits: 2.8902(12) Å is 2.8902 ± 0.0012 Å. The error is rounded to one significant digit, or two if it starts with 1.
  • Layout: side by side for double-column width (170 mm); image above the parameters for single column (85 mm). Font size, marker size, line width, white or black background and a dividing line between the halves are options. The dialog shows a live preview.

STM images (Fourier analysis)

The STM workspace (header switch, teal accent) is separate from the LEED workspaces: its own image, structures, spots and fits. Switching back and forth keeps each workspace as it was. Opening an .sxm file anywhere switches to it automatically.

  1. Open STM image. Nanonis .sxm files are read directly: all channels and directions, the scan size, bias, setpoint and comment. Backward and upward scans are put into display orientation. Plain images (PNG/TIFF) also work, but you have to enter the scan size yourself.
  2. Processing (STM card): * channel; * background: plane, line median, plane + line median, or 2nd-order surface; * window: Hann, Hamming, Blackman, Tukey or none; * zero padding ×1–8; * FFT field: the central part of the transform that is kept; * intensity scaling, set separately for the display (default log |F|) and for the spot fits (default √|F|, whose spot profiles stay close to Gaussians).

Switch between Fourier transform and Real space. In real space, the lattices are drawn as points and unit cells over the topography; click to move their origin. 3. Scale. There is no beam energy and no calibration factor to determine. The transform scale follows from the scan size: N·d/2π pixels per Å⁻¹, with N the transform size and d the pixel size. The (0,0) beam is the exact centre. Non-square pixels are resampled first. The fit box is adapted to the padding. 4. Analysis, exactly as for LEED: * define lattices and superstructure matrices; * align with Auto-align selected lattice, or by hand (the Align tool rotates and scales the selected lattice, the transform stays fixed); * refine the spots; * fit, then run the epitaxy analysis.

In this workspace the fit presets keep the transform fixed and fit a, b, γ, φ and the matrices. Scanner calibration fits scale and rotation on a lattice you know. The result is shown as the effective scan size and is kept when you change the processing. 5. Moiré or superstructure satellites around the atomic spots are covered by multiple scattering (sums with the reference spots) of the superstructure.

STM projects are saved as .leed files, which contain the real-space data, and open in the STM workspace. Synthetic example loads a test image with a known lattice and superstructure.

Automatic indexing

Auto-index (header, LEED analysis and STM workspaces) opens a separate tool. While it is open, the right panel shows its three steps and the viewer shows only peaks and solutions. The analysis is not changed until you add a solution, so patterns with several structures can be explored without risk.

The method follows J. Simbrunner, J. Domke, F. Sojka, D. Knez, R. Resel, T. Fritz, R. Forker, Phys. Rev. B 104, 195402 (2021):

  • For pairs of reciprocal vectors (g₁, g₂), the vectors 2π G⁻¹ m (m integer) give tentative real-space cells. These are reduced to the 2D Niggli cell (a ≤ b, b|cos γ| ≤ a/2).
  • Each cell is tested against all reflections: A·g/2π must be integer.
  • The best cell is refined by least squares over all its reflections, with errors.
  • The search is repeated on the remaining reflections, which finds rotational and mirror domains and further lattices.
  1. Peaks. Local maxima of the band-pass filtered image, with sub-pixel positions. Maxima on streaks are rejected. The region around the (0,0) beam and beyond the screen can be excluded. Click in the image to add or remove peaks. For LEED, centre, calibration factor and energy must be set (best with the distortion correction); for STM the scale comes from the scan size.
  2. Search. Set the range of the cell vectors and two tolerances: * index tolerance: the deviation of A·g/2π from integers; * position tolerance in px: keeps small cells from collecting neighbouring satellites.

Optionally choose a known substrate. Its reflections are assigned first, satellites g_ads + g_sub count as multiple scattering, and epitaxy matrices with errors and their classification are given. 3. Solutions. Solutions with the same a, b, γ form one lattice type. You can add it as one structure: the rotational and mirror domains are recognised, and with a substrate it is added as an epitaxy matrix on it. You can also add a single orientation. Solutions with only three independent reflections are marked weak. Other cells explaining similar sets of reflections (e.g. superlattices) are listed.

Every tentative cell is refined from the inside out before it is scored, so large cells such as Si(111)-7×7 are found directly. For a moiré or superstructure, restrict the vector range to find the primary lattice first, add it, then search again with it as substrate (the satellites then count as multiple scattering).

Display and export

  • Colour maps: grey, bone, hot, inferno, magma, plasma, viridis, cividis, ice, cubehelix, turbo, twilight, and the diverging maps cool–warm and red–blue (useful after background subtraction). They can be reversed, combined with brightness/contrast/gamma/log, and shown with a colour bar.
  • Vector export (Export → SVG / PDF): the view or the whole image, with all visible overlays as vectors (spots, unit cells, indices, residuals, distortion grid), an optional legend, a 1 Å⁻¹ scale bar, a colour bar and a title. The diffraction image is embedded as a bitmap in the chosen colour map. SVG opens in Inkscape or Illustrator; PDF goes directly into LaTeX. No extra packages are needed.

Fitting

There is one spot-position model, and any subset of its parameters can be free:

  • device: centre x/y, rotation, calibration factor (pattern scale = CalFac/√(E+E₀))
  • each lattice structure: |a₁|, |a₂|, γ, φ (option: b tied to a)
  • each matrix structure: M₁₁, M₁₂, M₂₁, M₂₂ relative to its reference
  • mirror-domain axis

Fitting the reference (substrate) lattice and the matrices of all overlayers at the same time ("joint" preset) is supported. Residuals are the x/y deviations of all accepted spots. Errors are 1σ from the Jacobian (scaled by the residual variance), and are propagated to derived quantities: lattice parameters for matrix structures, epitaxy matrices for lattice structures, cell areas and det M. Degenerate parameter combinations (e.g. CalFac together with all lattice lengths) are flagged, and strong correlations are listed.

The presets reproduce the legacy fit options: CF → calibration, L1 → lattice, L4 → lattice_tied, E1/E2 → epitaxy/epitaxy_rot.

The epitaxy classification follows R. Forker, M. Meissner, T. Fritz, Soft Matter 13, 1748 (2017). It is based on the dimensionality of reciprocal-space coincidences G_a(h_a,k_a) = G_s(h_s,k_s), i.e. M·(h_s,k_s)ᵀ ∈ ℤ², tested within max(tolerance, n·σ).