pyextal.hdf5io

HDF5-based I/O for pre-refinement data.

Replaces the per-stage .npy file family with a single HDF5 file per dataset.

Layout

{sample}.h5 ├── attrs: crystal_dat, acquisition_prefix, date ├── raw/ dp, variance, g_vectors └── pre_refinement/

├── attrs: thickness, scale, background, gl, rotation, grid_shape ├── simgrid (n_rows, n_cols, 3) ├── templates (n_beams, n_rows, n_cols) ├── variance (n_beams, n_rows, n_cols) ├── roi_regions (n_regions, 4, 2) ├── g_include (n_beams, 3) └── allshift (n_shifts, 2)

Classes

Functions

save_raw(h5path, dp, variance, g_vectors, *[, prefix, ...])

Write raw LARBED measurement into /raw of an HDF5 file.

save_pre_refinement(h5path, roi, fine, g_include)

Write pre-refinement outputs from a LARBEDROI + FineOptimize run to HDF5.

load_pre_refinement(h5path)

Load pre-refinement outputs.

_replace(grp, name, data)

Write (or overwrite) a compressed dataset inside an HDF5 group.

Module Contents

class pyextal.hdf5io.PreRefinementResult

Bases: tuple

simgrid
templates
variance
roi_regions
geometry
g_include
grid_shape
pyextal.hdf5io.save_raw(h5path, dp, variance, g_vectors, *, prefix='', crystal_dat='', date='')

Write raw LARBED measurement into /raw of an HDF5 file.

Parameters:
  • h5path (path-like)

  • dp ((n_beams, ny, nx) array)

  • variance ((n_beams, ny, nx) array)

  • g_vectors ((n_beams, 3) int array — Miller indices)

  • prefix (optional provenance strings)

  • crystal_dat (optional provenance strings)

  • date (optional provenance strings)

pyextal.hdf5io.save_pre_refinement(h5path, roi, fine, g_include)

Write pre-refinement outputs from a LARBEDROI + FineOptimize run to HDF5.

Replaces the 6 np.save calls in the notebook export cell. The arrays are stored in 2D spatial form (n_rows, n_cols) so the file is self-describing.

Parameters:
  • h5path (path-like)

  • roi (LARBEDROI (must have had selectROI called — simGrid, templates, variance present))

  • fine (FineOptimize (must have been run — fine.thickness, fine.errorFunc.scale/.background))

  • g_include (list of (h,k,l) tuples — the reflections included in the ROI)

pyextal.hdf5io.load_pre_refinement(h5path)

Load pre-refinement outputs.

Returns:

simgrid (n_rows, n_cols, 3) templates (n_beams, n_rows, n_cols) variance (n_beams, n_rows, n_cols) roi_regions (n_regions, 4, 2) geometry dict — thickness, scale, background, gl, rotation, allshift g_include (n_beams, 3) int array grid_shape (n_rows, n_cols)

Return type:

PreRefinementResult namedtuple with fields

pyextal.hdf5io._replace(grp, name, data)

Write (or overwrite) a compressed dataset inside an HDF5 group.