upxo.pxtal.twinned_simple_3d.subsetting module
subsetting.py
Cuboidal sub-volume extraction from a cleaned twinned 3D structure: tile generation, cropping, and descriptive statistics for a selected subset.
Ported from pxtal/twinned_simple_3d/gui/pages_subset.py (previously
only reachable through SubsetExtractionPage – none of the logic
here has any GUI/Tkinter dependency).
- class upxo.pxtal.twinned_simple_3d.subsetting.SubsetCleaner(lgi_clean, twin_role_clean, twin_parent_of_clean, all_quats_clean)[source]
Bases:
objectMinimal duck-typed stand-in for StructureCleaner3D, exposing just the 4 attributes downstream consumers (e.g. Abaqus export, 3D visualization) actually read: lgi_clean/twin_role_clean/ twin_parent_of_clean/all_quats_clean.
is_subset=True marks this as a produced crop rather than a genuine StructureCleaner3D, so callers can tell the two apart.
- is_subset = True
- upxo.pxtal.twinned_simple_3d.subsetting.generate_subset_tiles(lgi_shape, start_pct, n_cuboids, length_pct, stride_pct, overflow_policy)[source]
Build the full set of cuboid subset tiles for a cleaned 3D structure.
- Parameters:
start_pct (dict {'x': float, 'y': float, 'z': float}) – Percentages of the ORIGINAL domain length along each axis.
length_pct (dict {'x': float, 'y': float, 'z': float}) – Percentages of the ORIGINAL domain length along each axis.
stride_pct (dict {'x': float, 'y': float, 'z': float}) – Percentages of the ORIGINAL domain length along each axis.
n_cuboids (dict {'x': int, 'y': int, 'z': int})
overflow_policy ('clip' or 'skip')
- Returns:
list of dict, each ({‘index’: (i, j, k),) – ‘pct’: {‘x’: (s, e), ‘y’: (s, e), ‘z’: (s, e)}, ‘vox’: {‘x’: (v0, v1), ‘y’: (v0, v1), ‘z’: (v0, v1)}}
’vox’ bounds are array-index, end-exclusive, ready for direct slicing
of an (nz, ny, nx)-shaped array.
- upxo.pxtal.twinned_simple_3d.subsetting.crop_cleaner(source, tile)[source]
Crop a StructureCleaner3D-like
source(lgi_clean/ twin_role_clean/twin_parent_of_clean/all_quats_clean) totile’s voxel bounds, returning a SubsetCleaner with only the grain ids present in the crop.
- upxo.pxtal.twinned_simple_3d.subsetting.compute_subset_stats(cropped, voxel_size, units)[source]
Descriptive-statistics bundle for a cropped subset: constituent- region volume fractions, boundary/internal grain counts, and mean/std grain size (sphere-equiv. diameter), aspect ratio, and coordination number.