upxo.pxtal.fm_steel_3d.visualization_maps module

Label maps of the FM steel hierarchy for visualisation, at full and rescaled resolution.

build_visualization_data returns, for a structure that has PAGs, blocks and orientations (and optionally sub-blocks):

  • the grain, PAG, block-index and block-id maps and, with sub-blocks, the sub-block id map;

  • the same maps resampled by a scale factor (*_rs);

  • the packet-index map of the blocks (with sub-blocks);

  • for sub-blocks, the colour of each sub-block id, with one hue per parent block and the lightness varying between the sub-blocks of a block.

Block and sub-block ids are assigned in a random order fixed by the seed, so that neighbouring ids differ visibly.

upxo.pxtal.fm_steel_3d.visualization_maps.label_groups_in_random_order(template: ndarray, groups: dict, seed: int)[source]

Grid shaped like template in which the voxels of each group carry one label.

groups maps a group key to its voxel coordinates (n, 3). The groups receive the labels 1..n in an order drawn from default_rng(seed); voxels in no group are 0.

Returns:

(grid, labels)

Return type:

the grid and the list of labels, in the order of groups.

upxo.pxtal.fm_steel_3d.visualization_maps.subblock_family_colours(label_to_subblock: Dict[int, str], block_to_subblocks: dict, n_subblocks: int, seed: int, saturation: float = 0.82) → ndarray[source]

RGB colour per sub-block label; row 0 and unknown labels stay black.

Sub-blocks of one block share a hue (the hues of the blocks are shuffled with default_rng(seed)); within a block the value rises from 0.30 to 0.90 with the position of the sub-block, and is 0.60 for a block with a single sub-block.

upxo.pxtal.fm_steel_3d.visualization_maps.packet_index_grid(template: ndarray, blocks: dict, grain_to_plane_idx: dict) → ndarray[source]

Grid in which each block carries the packet index (plane index + 1) of its grain.

The grain id is the third underscore-separated field of the block id.

upxo.pxtal.fm_steel_3d.visualization_maps.build_visualization_data(fm_pag, fm_blocks, fm_orientations, fm_final, *, seed: int = 42, rescale_factor: float = 1.0, rescale_method: str = 'nearest', domain_length: float = 100.0, subblock_mode: bool = False, family_colours: bool = False, log: Callable[[str], None] | None = None) → dict[source]

Label maps of the hierarchy for visualisation.

Parameters:
  • fm_pag – State with PAGs: clusters_dict, n_pags and, as _parent, the base structure (lgi, n_grains).

  • fm_blocks – State with all_blocks (block id -> voxel coordinates).

  • fm_orientations – State with all_blocks and the base structure’s grain_to_plane_idx as _parent (used for the packet map in sub-block mode).

  • fm_final – The state the maps are made for: the sub-block state in sub-block mode (all_subblocks, block_to_subblocks_map), otherwise the orientation state. It is returned as fm_state.

  • seed (int) – Block ids use seed and seed + 35, sub-block ids seed + 70 and the sub-block hues seed + 71.

  • rescale_factor – Passed to grid_ops.rescale_grid_3d.

  • rescale_method – Passed to grid_ops.rescale_grid_3d.

  • domain_length (float) – Length of the domain along x; voxel_size_rs is this divided by the rescaled number of voxels along x.

  • log (callable(str), optional) – Receives progress messages.

Returns:

  • dict with the keys fm_state, grain_id_map, pag_id_map, block_idx_map,

  • block_fid_map, subblock_fid_map, grain_id_map_rs, pag_id_map_rs,

  • block_fid_map_rs, subblock_fid_map_rs, fid_to_rgb, fid_to_sb_id,

  • packet_id_map_rs, voxel_size_rs, n_blocks and

  • isolated_grain_orientations. Entries that do not apply (sub-block

  • entries without sub-blocks) are None.