upxo.pxtal.twinned_simple_3d.subsetting_2d module
subsetting_2d.py
Rectangular sub-domain extraction from a 2D EBSD grain-label field:
moving-rectangle tile generation and cropping. 2D sibling of
subsetting.py (which does the same for 3D cuboids) – reuses that
module’s axis-interval math rather than duplicating it.
- upxo.pxtal.twinned_simple_3d.subsetting_2d.generate_subset_tiles_2d(lgi_shape, start_pct, length_pct, stride_pct, overflow_policy='clip')[source]
Build the full set of rectangular subset tiles for a 2D EBSD grain- label field, per a moving-rectangle sweep.
- Parameters:
start_pct (dict {'x': float, 'y': float}) – Percentages of the ORIGINAL domain extent along each axis.
length_pct (dict {'x': float, 'y': float}) – Percentages of the ORIGINAL domain extent along each axis.
stride_pct (dict {'x': float, 'y': float}) – Percentages of the ORIGINAL domain extent along each axis.
overflow_policy ('clip' or 'skip')
- Returns:
list of dict, each ({‘index’: (i, j),) – ‘pct’: {‘x’: (s, e), ‘y’: (s, e)}, ‘px’: {‘x’: (x0, x1), ‘y’: (y0, y1)}}
’px’ bounds are array-index, end-exclusive, ready for direct slicing
of an (ny, nx)-shaped array.
- upxo.pxtal.twinned_simple_3d.subsetting_2d.crop_lgi_2d(lgi, tile)[source]
Crop a 2D grain-label field to tile’s pixel bounds.
- upxo.pxtal.twinned_simple_3d.subsetting_2d.subset_centroid_um(tile, lgi_shape, step_um)[source]
Physical (x, y) centroid of a tile, in the same units as step_um (typically microns), rounded to 2 decimal places – the centroid of the ORIGINAL (un-cropped) domain’s coordinate system, not the crop’s own local coordinates, so tiles from different subsets remain directly comparable by position.