# Simulated 4D-STEM data: tilt failures in polarisation analysis

Data accompanying:

> F. G. Hardy, N. Schnitzer, M. Palos, G. Topore, A. Walsh, M. S. Conroy,
> *Quantitatively Probing the Tilt Angle Failures in 4D-STEM Polarisation Analysis* (2026). 

Multislice simulations (abTEM 1.0.8, 300 kV) of position-averaged CBED patterns from three ferroelectrics:

- **PTO**: PbTiO₃, P4mm, zone axis [100], structure ICSD-35844
- **BTO**: BaTiO₃, P4mm, zone axis [100], structure ICSD-34903
- **Boracite**: Cu₃B₇O₁₃Cl, Pca2₁, zone axis [110] then rotated −45° about z, DFT-relaxed structure

The boracite structure is included as `cu2-ortho-sym.cif`. The PTO and BTO structures are ICSD
entries, which cannot be redistributed; obtain them from the ICSD using the accession numbers above.

All data files are NumPy `.npz` archives. Load them with `np.load(path)`.

---

## Files

- `cu2-ortho-sym.cif`: boracite structure (Pca2₁, DFT relaxed)
- `PTO_long_range_tilt.npz`, `BTO_long_range_tilt.npz`, `boracite_long_range_tilt.npz`: tilt along P,
  −2.5 to +2.5°, 0.0625° steps, 81 tilts (BTO 80, +2.1875° missing)
- `PTO_short_range_tilt.npz`, `BTO_short_range_tilt.npz`, `boracite_short_range_tilt.npz`: tilt along P,
  −0.6 to +0.6°, 0.03° steps, 41 tilts
- `PTO_tilt_grid.npz`, `BTO_tilt_grid.npz`, `Boracite_tilt_grid.npz`: 2D tilt maps, `tilt_y` × `tilt_x`,
  each −0.6 to +0.6°, 9 × 9
- `thickness_series.zip`: zero tilt, exit planes every 5 nm from 5 to 60 nm, for each material

The short-range files are the data behind the main tilt figures and the tilt-failure table. The
thickness-series files are the data behind the thickness figure.

---

## Common conventions (read these first)

1. **Cropped patterns.** The simulations used a 4096 × 4096 grid. Beyond the 2/3 antialiasing
   bandlimit (radius 1365 px) the intensity is numerical noise (about 10⁻¹⁴ of the total), so the
   patterns are cropped to the central **2732 × 2732** px (original pixels 682–3413) and stored as
   float32, which is the precision abTEM produced. Each file stores `crop_offset_px = 682` and
   `original_shape_px = 4096`. To get original pixel coordinates, add 682.

   To fit the repository size limit, the stored patterns are also (i) set to exactly zero outside the
   antialias aperture (an ellipse of radius ≈1336 × 1317 px for PTO; these pixels hold < 10⁻⁶ of the
   total intensity, all numerical leakage), and (ii) rounded to 16 mantissa bits (relative change
   ≤ 1.5 × 10⁻⁵ per pixel), then stored with LZMA zip compression. `np.load` reads them as normal. The
   Kikuchi metric and Friedel-pair asymmetries used in the paper change by < 10⁻³ px and < 10⁻³
   percentage points respectively.
2. **Pattern centre** (direct beam) is at index `N/2` exactly: 1366 in the cropped arrays, 2048 in the original.
3. **Axes.** Arrays are indexed `[k_x, k_y]` (abTEM convention), so **array axis 0 is lab x and carries
   the polar axis** in every dataset. Checked from the antialias-aperture ellipticity: axis-0/axis-1
   radius ratio 1.015 for PTO, 1.008 for BTO and 1.000 for boracite (square cell). The simulation
   code calls this axis "y" (`tilt_y`, `com_y`).
4. **Tilt.** `tilt_y` rotates the specimen so the pattern moves along axis 0, i.e. **along P**.
   `tilt_x` moves it along axis 1 (perpendicular to P). Units are degrees.
5. **Mirror about the centre.** Row `r` maps to `N − r`. For a half-open box `[lo, hi)` the mirror is
   `[N + 1 − hi, N + 1 − lo)`.
6. **Polarisation direction.** In PTO and boracite, P points towards **higher** axis-0 index (+x).
   In BTO it points towards **lower** index. To compare BTO with the others, use `y(t) → −y(−t)`.

---

## Tilt files (`*_long_range_tilt.npz`, `*_short_range_tilt.npz`, `*_tilt_grid.npz`)

Keys (shape in brackets):

- `diffraction_images` (n_y, n_x, 2732, 2732), float32: position-averaged CBED pattern at each tilt
- `tilt_y_values` (n_y): tilt along P, degrees
- `tilt_x_values` (n_x): tilt perpendicular to P, degrees (`[0.0]` for the 1D sweeps)
- `horizontal_boxes_box1_coords` (n_y, n_x, 4): Kikuchi ROI `(row_lo, row_hi, col_lo, col_hi)` in cropped
  coordinates. In the grids it moves with tilt
- `horizontal_boxes_box2_coords` (n_y, n_x, 4): **superseded**. Mirror of box 1 using `N − hi`, which is
  one pixel off. Recompute it (convention 5)
- `horizontal_boxes_com_y_displacement` (n_y, n_x): **superseded**. The original Kikuchi metric, which has
  the mirror error and a centroid-midpoint error. Do not use it
- `horizontal_boxes_intensity_asymmetry`, `horizontal_boxes` (n_y, n_x): in-simulation scores from the
  original metric, kept for provenance
- `crop_offset_px`, `original_shape_px` (scalars): 682, 4096

The paper's signals are recomputed from `diffraction_images`. The corrected Kikuchi metric is given in the
minimal example below. The Friedel-pair metric is
`(I_box1 − I_box2)/(I_box1 + I_box2)` over boxes around the 00l disk rows. In the cropped frame, the Kikuchi ROI is
`(118, 718, 1306, 1426)` and its mirror is `(2015, 2615, 1306, 1426)`.

Simulation parameters (also given in the paper's Methods): 300 kV, 0.8 mrad convergence semi-angle,
zero defocus, frozen phonons (40 configurations), full-angle detector, and 30 × 30 × 154 unit cells
(PTO, BTO) or 7 × 7 × 40 (boracite).
The RMS thermal displacements are PTO Pb 0.1068, Ti 0.0872, O 0.0503 Å; BTO Ba 0.0785, Ti 0.0703,
O 0.0656 Å; boracite 0.1 Å for all atoms.

## Thickness series (`thickness_series.zip`)

One 60 nm multislice calculation per frozen-phonon configuration, with the exit wave recorded every 5 nm.
Zero tilt, 20 configurations, 2 × 2 scan over the cell, 1.0 Å slices. The zip holds one set of the files
below for each material (PTO, BTO, Boracite). Full settings are in each material's `parameters.txt`.

`mean_patterns.npz`:

- `patterns` (12, 2732, 2732), float32: mean pattern at each depth
- `depths` (12): exit-plane depth, Å (nearest slice boundary to 50, 100, …, 600 Å)
- `n_configs` (scalar): 20

`config_###.npz` (one per frozen-phonon configuration):

- `disks` (12, 3): Friedel-pair asymmetry (%) per depth for the three disk boxes in `parameters.txt`, as
  computed during the run
- `kikuchi` (12): corrected Kikuchi metric (Å⁻¹) per depth, as computed during the run
- `seed`, `depths`: phonon seed and depths

The `config_###.npz` signals are aligned to P (+ = brighter on the side P points to). The box coordinates in
`parameters.txt` are in the small cropped disk-pattern frame noted there, not in the 2732 px frame. The paper's
thickness figure recomputes all signals from `mean_patterns.npz`.

---

## Minimal example

```python
import numpy as np

d = np.load("PTO_short_range_tilt.npz")
P, t = d["diffraction_images"][:, 0], d["tilt_y_values"]
N = P.shape[-1]                              # 2732, centre at N/2

def kikuchi_com(p, lo=118, hi=718, c0=1306, c1=1426):
    """Centroid of the union of the ROI and its exact mirror, px from centre, along axis 0."""
    tot = w = 0.0
    for a, b in ((lo, hi), (N + 1 - hi, N + 1 - lo)):
        r = p[a:b, c0:c1].sum(axis=1, dtype=np.float64)
        tot += (r * np.arange(a, b)).sum()
        w += r.sum()
    return tot / w - N / 2

y = np.array([kikuchi_com(p) for p in P])
```

## Contact

Fintan G. Hardy, Imperial College London (f.hardy24@imperial.ac.uk)
