upxo.pxtal.fm_steel_3d.hierarchy_queries module

Lookups over the PAG / packet / block / sub-block hierarchy of a pipeline state.

The functions take any pipeline state that has the attributes they read; attributes that are missing count as empty. The levels are 'pag', 'block', 'subblock' and 'grain'. A packet is identified by the id of its grain.

upxo.pxtal.fm_steel_3d.hierarchy_queries.pag_of_items(fm_state) → Tuple[dict, dict, dict][source]

(grain_to_pag, block_to_pag, subblock_to_pag): the PAG each grain, block and sub-block belongs to. Blocks of grains without a PAG, and sub-blocks of such blocks, are left out.

upxo.pxtal.fm_steel_3d.hierarchy_queries.phase_of_items(fm_state, level: str, ids: Iterable) → Dict[source]

{id: phase name} for the items of one level.

A PAG listed in retained_austenite_pag_ids is retained austenite and every other PAG is martensite. A block or sub-block takes the phase of its PAG (martensite when it has none). A grain takes the phase of its PAG; without a PAG it is retained austenite if it is an isolated grain and martensite otherwise.

upxo.pxtal.fm_steel_3d.hierarchy_queries.voxels_for_level(fm_state, level: str, item_id) → ndarray[source]

Voxel coordinates (n, 3) of one item; empty if the item is unknown.

A PAG is the union of its grains.

upxo.pxtal.fm_steel_3d.hierarchy_queries.orientations_for_level(fm_state, level: str) → dict[source]

{id: (phi1, Phi, phi2)} stored on the state for a level ('pag', 'block', 'subblock' or 'grain'); empty for any other.

upxo.pxtal.fm_steel_3d.hierarchy_queries.collect_ids_and_orientations(fm_state, level: str, orientations: dict, restrict_axis: str | None = None, restrict_idx: int | None = None, scope_ids: Iterable | None = None)[source]

Ids with an orientation, and their Euler angles as an (n, 3) array.

Parameters:
  • orientations (dict) – {id: (phi1, Phi, phi2)} of the level.

  • restrict_axis ({'X', 'Y', 'Z'}, optional)

  • restrict_idx (int, optional) – With restrict_axis, keep only the items that have a voxel in the slice restrict_idx along that axis (ignored when negative).

  • scope_ids (iterable, optional) – Keep only these ids.

Returns:

(ids, eulers)

Return type:

list and float64 array, in the order of orientations.

upxo.pxtal.fm_steel_3d.hierarchy_queries.packet_ids_for_pags(fm_state, pag_ids: Iterable) → Set[int][source]

Packets (grain ids) of the given PAGs.

upxo.pxtal.fm_steel_3d.hierarchy_queries.pag_ids_for_blocks(fm_state, block_ids: Iterable) → Set[source]

PAGs the given blocks belong to.

upxo.pxtal.fm_steel_3d.hierarchy_queries.packet_ids_for_blocks(fm_state, block_ids: Iterable) → Set[source]

Packets (grain ids) the given blocks belong to.

upxo.pxtal.fm_steel_3d.hierarchy_queries.block_ids_for_subblocks(fm_state, subblock_ids: Iterable) → Set[source]

Blocks the given sub-blocks belong to.

upxo.pxtal.fm_steel_3d.hierarchy_queries.pag_ids_for_subblocks(fm_state, subblock_ids: Iterable) → Set[source]

PAGs the given sub-blocks belong to.

upxo.pxtal.fm_steel_3d.hierarchy_queries.packet_ids_for_subblocks(fm_state, subblock_ids: Iterable) → Set[source]

Packets (grain ids) the given sub-blocks belong to.

upxo.pxtal.fm_steel_3d.hierarchy_queries.resolve_packet_grain_id(fm_state, pag_id, local_idx) → int | None[source]

Grain id (= packet id) whose local ordinal within pag_id is local_idx, or None if there is none.