graintrace.hedm_stitching_techniques#

HEDM scan-stitching techniques (region-based, naive) and support utilities.

Region-based multi-scan HEDM z-stitching (RegionBaseStitching).

class graintrace.hedm_stitching_techniques.region_base_stitching.RegionBaseStitching(scan_files, output_csv, position_tolerance, orientation_tolerance, radius_tolerance, weights, min_neighbors=5, orientation_convention='bunge', orientation_units='degrees', symmetry='432', output_column=None, refine_extents=False, tess_weighted=True, update_centroid=False, tess_dir=None, neper_env=None, xy_bounding_box=None)[source]#

Bases: object

Iteratively stitch overlapping HEDM scan layers into one grain set.

Parameters:
  • scan_files (List[str])

  • output_csv (str)

  • position_tolerance (float)

  • orientation_tolerance (float)

  • radius_tolerance (float)

  • weights (Dict[str, float])

  • min_neighbors (int)

  • orientation_convention (str)

  • orientation_units (str)

  • symmetry (str)

  • output_column (Optional[List[str]])

  • refine_extents (bool)

  • tess_weighted (bool)

  • update_centroid (bool)

  • tess_dir (Optional[str])

  • neper_env (Optional[Dict[str, str]])

  • xy_bounding_box (Optional[List[float]])

run(zlo, zhi, overlap_fraction)[source]#

Entry point: load and sort scans, then iteratively stitch S0 → S01 → S012 → … and write the final output.

Parameters:
Return type:

GrainSet

Per-grain cell geometry from a Neper tessellation, for HEDM stitching.

Given a set of grain centroids (one scan or a stitched accumulator), build a (Laguerre / power) Voronoi tessellation at the measured centroids, with no CVT relaxation, and read back each grain’s true polyhedral z-extent [Zmin, Zmax] and volume centroid. This replaces the equivalent-sphere z +/- GrainRadius approximation used by the region classifier for elongated / anisotropic grains.

graintrace.hedm_stitching_techniques.scan_tessellation.default_neper_env()[source]#

Subprocess environment for a user-installed NEPER.

Resolves the neper binary via graintrace.neper_env (NEPER env var -> tools.json -> PATH) and puts its bin/lib directories on PATH / LD_LIBRARY_PATH so a self-built NEPER finds its GSL/OpenBLAS libs. Falls back to a plain os.environ copy when NEPER cannot be located.

Return type:

dict

graintrace.hedm_stitching_techniques.scan_tessellation.compute_cell_geometry(df, bbox, weighted=True, coord_cols=('X', 'Y', 'Z'), radius_col='GrainRadius', work_dir=None, env=None, neper_bin='neper', keep_files=False)[source]#

Tessellate df’s grains inside bbox and return per-grain cell geometry.

The tessellation is a (Laguerre when weighted) Voronoi diagram of the exact measured centroids; -morphooptistop iter=0 disables CVT relaxation so cells stay anchored at the grains. Cell i corresponds to input row i (the same seed-order assumption VoronoiMeshBuilder relies on for orientation mapping).

Parameters:
  • df (DataFrame) – grain table with coord_cols (and radius_col when weighted).

  • bbox (Sequence[float]) – domain [xlo, xhi, ylo, yhi, zlo, zhi]. z should be the scan FOV window so that a cell touching the z-limit means the grain is truncated.

  • weighted (bool) – Laguerre weight = effective grain volume (4/3)*pi*r**3.

  • work_dir (str | None) – scratch dir for Neper I/O (a temp dir is used and removed if None).

  • env (dict | None) – subprocess env (defaults to default_neper_env()).

  • coord_cols (Sequence[str])

  • radius_col (str)

  • neper_bin (str)

  • keep_files (bool)

Returns:

DataFrame indexed like df with columns Zmin, Zmax, Xc, Yc, Zc, Vol.

Return type:

DataFrame