morphogen.viz.figures

Figures of microstructures, automata, optimizations, frames of beams and textures (matplotlib, optional extra [plot]). Figures are built without pyplot (matplotlib.figure.Figure): they work headless and can be saved with fig.savefig(path).

morphogen.viz.figures.as_array(source, shape=None, *, labels: bool = False) → ndarray[source]

3D array of a microstructure (voxelized on shape or its own lattice), of a voxel image or of an array; labels takes the cell labels of the structure.

morphogen.viz.figures.slices_figure(source, *, shape=None, labels: bool = False, title: str | None = None)[source]

Middle sections normal to x, y and z (one image for planar structures).

morphogen.viz.figures.field_figure(data, *, cmap='viridis', clim=None, title: str | None = None, label: str = '')[source]

Middle sections normal to x, y and z of a field on a voxel grid (one for planar grids), on one colour range with a colour bar titled label.

morphogen.viz.figures.mesh_figure(mesh, *, axis: int = 2, position: float | None = None, values=None, cmap='viridis', label: str = '', title: str | None = None)[source]

The cut of a tetrahedral mesh by a plane normal to axis (through the middle of its box, or at the coordinate position): the polygons of the elements that the plane crosses, in the colours of their phases or coloured by values (one per element, with a colour bar titled label), their edges drawn — the elements of a conforming mesh following the interfaces. See mesh_section() for the polygons.

morphogen.viz.figures.mesh_section(mesh, axis: int = 2, position: float | None = None)[source]

The cut of the elements of a tetrahedral mesh by the plane normal to axis at the coordinate position (the middle of its box by default): the polygons (3 or 4 points each, in the two other coordinates, in order around them) and the indices of their elements. Their areas sum to the section of the mesh: a face that lies in the plane is the cut of the element below it.

morphogen.viz.figures.path_figure(result, *, title: str | None = None)[source]

Curves of a loading path (PathResult): the macroscopic stresses that vary against the strain component that varies most (in finite strains, the true stresses against the logarithmic strains), and the mean cumulated plastic strain against time when the materials yield.

morphogen.viz.figures.tiled_figure(source, *, tiles: int = 3, shape=None, title: str | None = None, axis=None)[source]

Periodic tiling (tiles x tiles) of the middle sections of a cell: those normal to x, y and z (the x-y section alone for a planar structure), or the one normal to axis (0, 1 or 2).

morphogen.viz.figures.surface_figure(source, *, shape=None, phase: int = 1, title: str | None = None)[source]

3D view of the boundary of a phase (marching cubes with scikit-image, voxel faces otherwise).

morphogen.viz.figures.history_figure(history: dict, keys=None, *, title: str | None = None)[source]

Curves of a history (automaton, optimization…) against its first column.

morphogen.viz.figures.kinetics_figure(micro, domain=None)[source]

Transformed fraction against time of a nucleation-growth structure, with the Avrami law.

morphogen.viz.figures.softening_figure(studies, *, title: str | None = None)[source]

Replicas of networks of non-identical beams (Softening, one or a list, a mode each): the mean E / E_0 of the replicas against the coefficient of variation with its standard errors (filled: corrected by the control variate; open: the plain mean) and the second-order mean 1 - s CV²; the scatter σ_E² / E_0² of the replicas against v CV² (its standard error for normal draws) and the diagonal.

morphogen.viz.figures.VECTOR_BEAMS = 2000

The beams of a frame drawn as vectors at most in its vector files (.svg, .pdf); those of larger frames are rasterized there (the axes, the colour bar and the texts not)

morphogen.viz.figures.FRAME_SCALES = ('linear', 'symmetric', 'log')

The scales of the values of the beams of frame_figure()

morphogen.viz.figures.frame_figure(frame, values=None, *, scale: str = 'linear', label: str = '', title: str | None = None)[source]

The beams of a periodic frame as segments in its cell (a Frame in its plane, a SpaceFrame in an orthographic 3D view), each cut where it leaves the cell and its pieces brought back by the periods, with the outline of the cell; coloured by one value per beam (values, the colour bar titled label; none: the beams alone), the strongest drawn widest and on top, on a scale: linear (from zero), symmetric (about zero, as the axial forces of beam_forces(): tension red, compression blue) up to the 99th percentile of their magnitudes, or log (three decades below the largest, as the energies of the beams). The beams of frames of more than VECTOR_BEAMS pieces are rasterized in the vector files.

morphogen.viz.figures.pole_figures_figure(figures, *, axes=('x', 'y'), cmap: str = 'viridis', vmax: float | None = None, title: str | None = None)[source]

Pole figures side by side (morphogen.texture.pole_figure(), one or several) on one colour range, in multiples of a random texture: the disc of each projection with the names axes of the first and second axes of the sample on its rim, the family and the largest density above it.

morphogen.viz.figures.ipf_key(ax, lattice: str = 'cubic', *, resolution: int = 240) → None[source]

Draws the colour key of the inverse pole figure maps of a lattice on ax: the fundamental sector with the colour of each direction of the crystal (morphogen.texture.direction_colours()) and the names of its corners.

morphogen.viz.figures.inverse_pole_figure_figure(figure, *, points=None, cmap: str = 'viridis', vmax: float | None = None, title: str | None = None)[source]

An inverse pole figure (morphogen.texture.inverse_pole_figure()): its density over the fundamental sector, in multiples of a random texture, with the names of the corners; points: directions of crystals (n, 3) drawn over it (morphogen.texture.inverse_poles(): the crystals one by one, or the way of one of them along a loading path).

morphogen.viz.figures.ipf_map_figure(ebsd, direction=(0.0, 0.0, 1.0), *, grains=None, title: str | None = None)[source]

An orientation map (morphogen.io.ebsd.EBSDMap) in the colours of the direction of each crystal along a direction of the sample (the third axis by default: the normal of the map), black where it was not indexed, in the axes of its image; with the boundaries of its grains (grains()) and the colour key of its lattice.

morphogen.viz.figures.disorientation_figure(angles, weights=None, *, lattice: str = 'cubic', bins: int = 21, title: str | None = None)[source]

The distribution of disorientations (degrees; weights: the lengths of the boundaries, morphogen.texture.boundary_disorientations()) as a histogram, with for cubic crystals the density of crystals at random (Mackenzie).

morphogen.viz.figures.save_gif(frames, path, *, fps: int = 8, kind: str = 'auto', scale: int = 4) → None[source]

Animated GIF of 2D frames (Pillow, installed with matplotlib).