upxo.pxtal.twinned_simple_3d.fast_cleaning module
Optional numba kernels for the small-grain and spike removal of the MC
temporal slices (TwinnedSimple3DBase.clean_temporal_slices).
They give the same labels and counts as the numpy code, in a fraction of the
time. numba is optional: numba_available() says whether it is installed
and resolve_backend() turns a requested backend into the one used.
- upxo.pxtal.twinned_simple_3d.fast_cleaning.resolve_backend(backend: str = 'auto') str[source]
‘numba’ or ‘numpy’ for a requested backend.
'auto'is numba when it is installed, else numpy;'numpy'is the numpy code;'numba'raisesImportErrorif numba is not installed.
- upxo.pxtal.twinned_simple_3d.fast_cleaning.merge_small_grains(lgi, min_grain_size, max_passes=50)[source]
Merge every grain of at most
min_grain_sizevoxels into its largest face neighbour (lowest id on a tie), repeated until none is left to merge.Same result as the numpy loop of
clean_temporal_slices. Returns(lgi, n_merged)with a new label array. Needs numba.
- upxo.pxtal.twinned_simple_3d.fast_cleaning.remove_spikes(lgi, same_count_threshold=1)[source]
Reassign spike voxels (at most
same_count_thresholdface neighbours of their own grain) to the neighbouring grain with most faces, asStructureCleaner3D._fast_clean_spikesdoes. Returns(lgi, n_removed)with a new label array. Needs numba.