upxo.pxtalops.temporalPatcher module

class upxo.pxtalops.temporalPatcher.patcher_pixvox(**kwargs)[source]

Bases: object

A multi-functional orchastrator class using orchastrator functions calling functions for 2D/3D pixellated/voxellated grain structure modification to enable the generation of following features / class of grain structures, with statistical representativeness: (1) Grain strucuture class

(1.a) Welded grain structures (gs) (1.b) Banded gs (1.c) Multi-modla gs (1.d) Additively manufactured gs

Usage

from upxo.pxtalops.temporalPatcher import patcher_pixvox

Class methods

  • by_UPXO_mcgs: Use the UPXO MCGS objects for base and patches(s).

  • by_lfi: Use the Local Feature Indeix Images for base and patches(s).

  • by_mcgsgen: Generate and choose the base and patch gs.

Slot varaibles

gsbase: upxo.pxtal.mcgs2_temporal_slice.(mcgs2_grain_structure, mcgs3_grain_structure)

UPXO base grain structure (gs) object. The gs object which is to be modified.

gspatchers: dict

UPXO patch gs object. The gs object which is used to modify. Keys will be patchID values, whcih coud be same as instance numbers, valued with upxo.pxtal.mcgs2_temporal_slice.mcgs2_grain_structure object for 2D and upxo.pxtal.mcgs2_temporal_slice.mcgs3_grain_structure for 3D.

lfib: np.ndarray

Local Feature Index (LFI) of base gs. LFI to be modified. Note: LFI is the gs data image to be modified. Shape: (R, C) for 2D and (P, R, C) for 3D.

lfip: dict

Dictionary of Local Feature Index of patch gs. LFI to used to modify lgib. Shape: (R, C) for 2D and (P, R, C) for 3D. Keys will be instance / patchID number, and values will the lfi artay.

eab: np.ndarray

Pixel/Voxel mapped Euler angles of base gs. Shape: (Nf, 3), where Nf is the number of features.

eap: dict

Dictionary of Pixel/Voxel mapped Euler angles of patcher gs. Shape: (Nf, 3), where Nf is the number of features.

targetDistr: np.ndarray

Target grain size probability density distribution.

constraints: dict

Dictionary of permitrted contraint specifications.

ninstances: int

Number of patched instances.

dim: int

Dimensionality

base_distr: np.ndarray

Cell (i.e. grain) size distriburtion, just a list of number of pixels/voxels.

patch_distr: np.ndarray, dict

If creation by gsgen, dict, else np.ndarray. If dict, keys will be patch IDs.

base_neigh_fid: dict

Dictionary of central fid valued with neighbouring fids, for base gs.

patch_neigh_fid: dict

Dictionary of central fid valued with neighbouring fids, for patch gs.

patchIds: np.ndarray

Patched gs IDs starting from 1, will be np.arange(1, ninstance+1)

patchIDTsliceMap: dict

Dictionary of patchIDs and their corresponding temporal slice in case of creation by gsgen.

patched_gs: dict

Dictionary of patched gs details. Keys will be ‘lfi’, ‘distr’, ‘neigh_fid’, ‘mesh’, etc, valued appropriately.

lfi_patched: dict

Dictionary of patched lfi. Keys will be patchIDs, valued with patched lfi.

fids_patched: dict

Dictionary of patched fids. Keys will be patchIDs, valued with patched fids.

neigh_fid_patched: dict

Dictionary of patched neigh_fid. Keys will be patchIDs, valued with patched neigh_fids.

conn: int

Connectivity for connected component analysis. 4 for 2D and 6 for 3D.

dashboards: dict

Dictionary of input dashboard paths. Keys will be ‘base’ and ‘patch’, valued with the input dashboard paths.

patchDomainShape: str

Shape of the patch domain. ‘polygonal’ for 2D and ‘polyhedral’ for 3D.

vizCtrls: dict

Dictionary of visualization controls.

a: float

unit_length in microns (actually, unit pixel / voxel size in microns).

gsbase
gspatchers
lfib
lfip
base_neigh_fid
patch_neigh_fid
targetDistr
ninstances
constraints
dim
dashboards
patchIds
patchIDTsliceMap
patchDomainShape
lfi_patched
fids_patched
neigh_fid_patched
classmethod by_UPXO_mcgs(base_grain_structure=None, patch_grain_structure=None, target_distribution=None, ninstances=None, constraints=None, dim=None)[source]

By upxo mcgs.

classmethod by_lgi(base_lfi=None, patch_lfi=None, target_distribution=None, ninstances=None, constraints=None, dim=None)[source]

By lgi.

classmethod by_mcgsgen(temporalPath='self', base_input_dashboard=None, patch_input_dashboard=None, basetslice=10, patchtslices=5, target_distribution=None)[source]
Parameters:
  • temporalPath (str) – Specify whether patch comes from the same temporal set. If ‘self’, the basetslice^th temporal slice of base gs temporal set will be used as the base gs. patchtslice^th temporal slie of patch gs temporal set will be used as patcher gs if ‘cross’. Options include ‘self’, ‘cross’. Defaults to ‘self’.

  • base_input_dashboard (str) – Defaults to None. Example input: ‘C:..customGSGen1.xls’

  • patch_input_dashboard (str) – Defaults to None. Example input: ‘C:..customGSGen2.xls’

  • basetslice (int) – Temporal slice for base gs selection.

  • patchtslices (int, np.ndarray, list, tuple) – Temporal slice(s) for patch gs selection. In caxse of multyiplre temporal slice specifiction, multiple instances will be created.

  • target_distribution (np.ndarray) – Target grain size probability density distribution.

  • randomize_lfi (bool) – Specify where the lfi IDs must be randomly shuffled. Improves visualization.

patch(lfib=None, lfip=None, patchDomain='rectangular', remove_small_features=False, niterations=4, recharEveryMerge=False, recursionLimit=100, threshold=10, constraints={})[source]

Patch.

find_small_fids(lfi, threshold)[source]

Find small fids.

shuffleLFIIDs(lfi)[source]

Shufflelfiids.

set_connectivity()[source]

Set or update connectivity.

reindex_lfi(lfi)[source]

Reindex lfi.

find_neighs(lfi)[source]

Find neighs.

get_feature_sizes(lfi)[source]

Return the feature sizes.

detect_islands(neigh_fids)[source]

Detect islands.

merge_islands(lfi, islands, neigh_fids)[source]

Merge islands.

find_grains_in_patch(lfi, patch_polygon)[source]

Find grains in patch.

find_external_neighs(grains_in_patch, neigh_fids)[source]

Find external neighs.

find_largest_external_neighs(external_neighs, patchedLGI)[source]

Find largest external neighs.

patch_rectangular(lfib=None, lfip=None, remove_small_features=False, niterations=4, recharEveryMerge=False, threshold=10, constraints={}, recursionLimit=100)[source]
constraints={‘xbound’: None, ‘ybound’: None, ‘cellPropagation’: OPTIONS-1A,

‘propagationProb’: 0.5}

OPTIONS-1A:
  1. b2p: cells in base at polygon boundary will enter patch domain. Here, cells in patch domain at polygon boundary will be merged with largest adjacent cells of base domain. You may want to prefer this if patch domain has smaller grains than base domain; as this would be closer to general physical observation.

  2. p2b: cells in patch at polygon boundary will enter base domain. Here, cells in base domain at polygon boundary will be merged with largest adjacent cells of patch domain. You may want to prefer this if base domain has smaller grains than patch domain; as this would be closer to general physical observation.

  3. bi-directional: propagationProb*100 percent b2p behaviour and (1-propagationProb)*100 percent p2b behaviour.

  4. none: polygon boundary will persist in patched grain structue.

Example call: self.patch(lfib, lfip, patchDomainShape=’rectangular’,
constraints={‘xbound’: [xmin, xmax], ‘ybound’: [ymin, ymax],

‘cellPropagation’: ‘b2p’, ‘propagationProb’: 0.5})

patch_circular(lfib=None, lfip=None, constraints=None)[source]
constraints={‘xcenter’: None, ‘ycenter’: None, ‘radius’: None, ‘cellPropagation’: OPTIONS-1A,

‘propagationProb’: 0.5}

OPTIONS-1A: All details same as rectangular patch, except that the patch domain will be circular instead of rectangular. Circular patch domain will be defined by center (xcenter, ycenter) and radius r.

merge_small_features_iterative(lfi, threshold, mode='smallest', max_iterations=100)[source]

Iteratively merges features smaller than threshold into neighbors. Uses while-loop to avoid recursion limits and improve stability.

merge_small_features_with_largest_neigh(lfi, threshold, neigh_fids, niterations=4, recharEveryMerge=False, recursionLimit=10)[source]

Merge small features with largest neigh.

patch_hexahedral(lfib=None, lfip=None, constraints={})[source]
constraints={‘xbound’: None, ‘ybound’: None, ‘zbound’: None,

‘cellPropagation’: OPTIONS-1A, ‘propagationProb’: 0.5}

OPTIONS-1A: OPTIONS-1A for ‘rectangular’.

patch_polygonal(lfib=None, lfip=None, constraints={})[source]

constraints={‘pol’: None, ‘polType’: ‘shapely’, ‘cellPropagation’: OPTIONS-1A, ‘propagationProb’: 0.5} OPTIONS-1A: OPTIONS-1A for ‘rectangular’.

patch_multiPolygonal(lfib=None, lfip=None, constraints={})[source]

constraints={‘mulpol’: None, ‘polType’: ‘shapely’, ‘cellPropagation’: OPTIONS-1A, ‘propagationProb’: 0.5} Where,

mulpol: A list of polygons, not a multi-polygon. OPTIONS-1: list of OPTIONS-1A for each polygon. Each OPTIONS-1A as previous.

patch_mis(lfib=None, lfip=None, constraints={})[source]

Patch mis.

patch_gidsNO(lfib=None, lfip=None, constraints={})[source]

Patch gidsno.

patch_simplified_weld_1(lfib=None, lfip=None, constraints={})[source]

Patch simplified weld 1.

patch_weld_3D(lfib=None, lfip=None, constraints={})[source]

H.L. Wei, J.W. Elmer, T. DebRoy, Crystal growth during keyhole mode laser welding, Acta Materialia, Volume 133, 2017, Pages 10-20, ISSN 1359-6454, https://doi.org/10.1016/j.actamat.2017.04.074. (https://www.sciencedirect.com/science/article/pii/S1359645417303634)

patch_multi_bead_weld_1(lfib=None, lfip=None, constraints={})[source]

Patch multi bead weld 1.

patch_multiline1_2d(lfib=None, lfip=None, constraints={})[source]
constraints={‘mullines’: None,

‘method’: ‘cut-off-radius’, ‘capradius’: 2, ‘maxWidth’: 4, ‘cellPropagation’: OPTIONS-1A, ‘propagationProb’: 0.5}

Where,
mulline: list of UPXO 2D multi-line objects. Below are its requirements:
  • Each multi-line object must have atleast 1 UPXO line.

  • The UPXO line must not have UPXO leanest / lean point definition.

  • Starting point of starting line and ending point of ending line must

    specify cap radius.

  • Each line must have atleast 1 intermediate UPXO point.

  • Each intermediate point must have a radius specified, which will be

    used to identify the pixels within this cut-off radius: this will only be considered if method is ‘cut-off-radius’.

method: Either ‘cut-off-radius’ or ‘polygonal’. If polygonal, more function

calls take place, to generate a buffer polygon using maxWidth and capradius.

cellPropagation: OPTIONS-1: As for ‘ractangular.

patch_multiline1_3d(lfib=None, lfip=None, constraints={})[source]

Similar to ‘mulline-1.2d’, but in 3D.

plot_lfi_2D(lfi, **kwargs)[source]

Visualise lfi 2D using Matplotlib or PyVista.

plotImage3D(im3d)[source]

Plotimage3d.

eab
eap
base_distr
patch_distr
patched_gs
conn
vizCtrls
a