texture Module

The texture module provide some utilities to generate, analyse and plot crystallographic textures.

class pymicro.crystal.texture.PoleFigure(microstructure=None, lattice=None, axis='Z', hkl='111', proj='stereo', verbose=False)

Bases: object

A class to create pole figures.

A pole figure is a useful tool to plot multiple crystal orientations, either in the sample coordinate system (direct pole figure) or alternatively plotting a particular direction in the crystal coordinate system (inverse pole figure).

__init__(microstructure=None, lattice=None, axis='Z', hkl='111', proj='stereo', verbose=False)

Create an empty PoleFigure object associated with a Microstructure.

Warning

Any crystal structure is now supported (you have to set the proper crystal lattice) but it has only really be tested for cubic.

Parameters
  • microstructure – the Microstructure containing the collection of orientations to plot (None by default).

  • lattice – the crystal Lattice.

  • axis (str) – the pole figure axis (‘Z’ by default), vertical axis in the direct pole figure and direction plotted on the inverse pole figure.

  • hkl (str) – slip plane family (‘111’ by default)

  • proj (str) – projection type, can be either ‘stereo’ (default) or ‘flat’

  • verbose (bool) – verbose mode (False by default)

get_orientations()

Get the list of orientations in the PoleFigure.

Returns

a list of Orientation instances.

set_hkl_poles(hkl='111')

Set the pole (aka hkl planes) list to to use in the PoleFigure.

The list of poles can be given by the family type or directly by a list of HklPlanes objects.

Params str/list hkl

slip plane family (‘111’ by default)

set_map_field(field_name, field=None, field_min_level=None, field_max_level=None, lut='hot')

Set the PoleFigure to color poles with the given field.

This method activates a mode where each symbol in the pole figure is color coded with respect to a field, which can be either the grain id, or a given field given in form of a list. If the grain volume or strain. For the grain id, the color is set according the each grain id in the Microstructure and the rand_cmap() function. For a given field, the color is set from the lookup table and according to the value in the given list. The list must contain a record for each grain. Minimum and maximum value to map the field values and the colors can be specify, if not they are directly taken as the min() and max() of the field.

Parameters
  • field_name (str) – The field name, could be ‘grain_id’, ‘ipf’, ‘grain_size’ or any other name describing the field.

  • field (list) – A list containing a record for each grain.

  • field_min_level (float) – The minimum value to use for this field.

  • field_max_level (float) – The maximum value to use for this field.

  • lut (str) – A string describing the colormap to use (among matplotlib ones available).

Raises

ValueError – If the given field does not contain enough values.

plot_pole_figures(plot_sst=True, display=True, save_as='pdf')

Plot and save a picture with both direct and inverse pole figures.

Parameters
  • plot_sst (bool) – controls wether to plot the full inverse pole figure or only the standard stereographic triangle (True by default).

  • display (bool) – display the plot if True, else save a picture of the pole figures (True by default)

  • save_as (str) – File format used to save the image such as pdf or png (‘pdf’ by default)

micro = Microstructure(name = 'AlLi_sam8')
micro.grains.append(Grain(11, Orientation.from_euler(np.array([262.364, 16.836, 104.691]))))
Al_fcc = Lattice.face_centered_cubic(0.405) # not really necessary since default lattice is cubic
pf = PoleFigure(microstructure=micro, proj='stereo', lattice=Al_fcc, hkl='111')
pf.mksize = 12
pf.set_map_field('grain_id')
pf.pflegend = True # this works well for a few grains
pf.plot_pole_figures()
AlLi_sam8_pole_figure

A 111 pole figure plotted for a single crystal orientation.

plot_crystal_dir(c_dir, **kwargs)

Function to plot a crystal direction on a pole figure.

Parameters
  • c_dir – A vector describing the crystal direction.

  • kwargs (dict) – a dictionnary of keyword/values to control the plot, it should at least contain a reference to a pyplot axes to draw the pole using keyword ‘ax’.

Raises

ValueError – if the projection type is not supported

plot_line_between_crystal_dir(c1, c2, ax=None, steps=11, col='k')

Plot a curve between two crystal directions.

The curve is actually composed of several straight lines segments to draw from direction 1 to direction 2.

Parameters
  • c1 – vector describing crystal direction 1

  • c2 – vector describing crystal direction 2

  • ax – a reference to a pyplot ax to draw the line

  • steps (int) – number of straight lines composing the curve (11 by default)

  • col – line color (black by default)

plot_pf_background(ax, labels=True)

Function to plot the background of the pole figure.

Parameters
  • ax – a reference to a pyplot ax to draw the backgroud.

  • labels (bool) – add lables to axes (True by default).

plot_pf_dir(c_dir, **kwargs)

Plot a crystal direction in a direct pole figure.

Parameters
  • c_dir – a vector describing the crystal direction.

  • kwargs (dict) – a dictionnary of keyword/values to control the plot, it should at least contain a reference to a pyplot axes to draw the pole using keyword ‘ax’.

plot_pf(ax=None, mk='o', ann=False)

Create the direct pole figure.

Parameters
  • ax – a reference to a pyplot ax to draw the poles.

  • mk – marker used to plot the poles (disc by default).

  • ann (bool) – Annotate the pole with the coordinates of the vector if True (False by default).

create_pf_contour(ax=None, ang_step=10)

Compute the distribution of orientation and plot it using contouring.

This plot the distribution of orientation in the microstructure associated with this PoleFigure instance, as a continuous distribution using angular bining with the specified step. the distribution is constructed at runtime by discretizing the angular space and counting the number of poles in each bin. Then the plot_pf_contour method is called to actually plot the data.

Warning

This function has not been tested properly, use at your own risk.

Parameters
  • ax – a reference to a pyplot ax to draw the contours.

  • ang_step (int) – angular step in degrees to use for constructing the orientation distribution data (10 degrees by default)

plot_pf_contour(ax, x, y, values)

Plot the direct pole figure using contours.

Warning

This function has not been tested properly, use at your own risk.

sst_symmetry(v)

Transform a given vector according to the lattice symmetry associated with the pole figure.

This function transform a vector so that it lies in the smallest symmetry equivalent zone.

Parameters

v – the vector to transform.

Returns

the transformed vector.

static sst_symmetry_cubic(z_rot)

Transform a given vector according to the cubic symmetry.

This function transform a vector so that it lies in the unit SST triangle.

Parameters

z_rot – vector to transform.

Returns

the transformed vector.

get_color_from_field(grain)

Get the color of the given grain according to the chosen field.

This function will return the color associated with the given grain. Depending on how the pole figure has been configured (see the set_map_field function), it will be obtained from:

  • the grain id, according to the Microstructure.rand_cmap function

  • ipf the colour will reflect the orientation according to the IPF

    coloring scheme

  • the field value mapped on a pyplot color map if the lut field of

    the PoleFigure instance is a string.

  • a color directly read from the lut field; in this case the field

    value must reflect the category of the given grain.

Parameters

grain – the Grain instance.

Returns

the color as a 3 element numpy array representing the rgb values.

plot_sst(**kwargs)

Create the inverse pole figure in the unit standard triangle.

Parameters
  • ax – a reference to a pyplot ax to draw the poles.

  • mk – marker used to plot the poles (square by default).

  • ann (bool) – Annotate the pole with the coordinates of the vector if True (False by default).

plot_ipf(**kwargs)

Create the inverse pole figure for direction Z.

Parameters
  • ax – a reference to a pyplot ax to draw the poles.

  • mk – marker used to plot the poles (square by default).

  • ann (bool) – Annotate the pole with the coordinates of the vector if True (False by default).

static plot(orientations, **kwargs)

Plot a pole figure (both direct and inverse) for a list of crystal orientations.

Parameters

orientations – the list of crystalline Orientation to plot.

static plot_euler(phi1, Phi, phi2, **kwargs)

Directly plot a pole figure for a single orientation given its three Euler angles.

PoleFigure.plot_euler(10, 20, 30)
Parameters
  • phi1 (float) – first Euler angle (in degree).

  • Phi (float) – second Euler angle (in degree).

  • phi2 (float) – third Euler angle (in degree).

class pymicro.crystal.texture.TaylorModel(microstructure)

Bases: object

A class to carry out texture evolution with the Taylor model.

Briefly explain the full constrained Taylor model [ref 1938].

__init__(microstructure)
compute_step(g, check=True)