API Reference

class ebsdlab.ebsd.EBSD(fileName)

Bases: object

Class to allow for read EBSD data.

Uses quaternions and symmetries but not orientations

addScaleBar(fileName=None, site='BL', barLength=None, scale=-1, alpha=0.5)

Add scale-bar to image

Parameters:
  • fileName – if given, save to file

  • site – where to put the scale bar<br> bottom-left “BL” (default)<br> bottom-right “BR”<br> top-left “TL”<br> top-right “TR”

  • barLength – length of scale bar. It is calculate if not given

  • scale – of font and rectangle. Default: widthInPixel / 16, which is for a 1024x786 image = 64

  • alpha – transparency of scale bar background

addSymbol(x, y, fileName=None, scale=1.0, colorCube='black')

TODO: use version in ebsd_Orientation Add symbol of crystal orientation (symmetry and rotation) to IPF at given location

Parameters:
  • x – x-coordinate

  • y – y-coordinate

  • fileName – export to file

  • scale – scale of symbol

  • colorCube – color of symbol

calcKAM(layers=1)

calculate Kerner Average Misorientation in DEGREES (because user focused)

Parameters:

layers – number of neighboring layers used for KAM (more: slower)

cropVMask(xmin=None, ymin=None, xmax=None, ymax=None)

crop visible area

Parameters:
  • xmin – minimum x-coordinate

  • ymin – minimum y-coordinate

  • xmax – maximum x-coordinate

  • ymax – maximum y-coordinate

loadANG(fileName=None)

Load .ang file: filename saved in self. No need to use it

loadCRC(fileName=None)

Load .crc file; filename saved in self. No need to use it. Copied from mtex and translated into python

loadOSC(fileName=None)

Load .osc file; filename saved in self. No need to use it. Copied from mtex and translated into python Warning: SEMsignal not parsed correctly

loadTXT(fileName=None, update=False)

read txt file and possibly update data. Warning, this resets the mask to the one of the file

Update makes more sense if you have original data and update it with some partial information, since the partial information is incomplete (stepSize, width and height are in many cases wrong). Update will keep the old data and overwrite the new. THIS IS SLOWER THAN CREATING NEW

Parameters:
  • fileName – fileName to load (partition data from OIM)

  • update – update data or read new (read-new: default)

loadVoid(rotation)

rotation angles in degree

maskCI(CI)

masked all points off, which have a CI less than: good points=False, bad points=True

Parameters:

CI – critical CI

maskReset()

reset mask

neighbors(idx=None, layers=1)

identify neighboring indexes

Parameters:
  • idx – index to find [if None: calculate all]

  • layers – number of neighboring layers

Returns:

array of neighbors; invalid points have a value=-10

plot(vector, widthPixel=None, vmax='', vmin='', interpolationType='nearest', cmap=None, show=True, cbar=True)

given a class-vector, plot the vector as an image<br> the x and y are given by the class-vector x and y

Parameters:
  • vector – vector to be plotted as a 2D image

  • widthPixel – rescale to horizontal size of the image [default: optimal pixel width]

  • vmax – rescale z-scale to maximal value

  • vmin – rescale z-scale to minimal value

  • interpolationType – interpolation type [default: “nearest” next-neighbor]

plotIPF(direction='ND', widthPixel=None, fileName=None, interpolationType='nearest')

plot Inverse Pole Figure (IPF)

Parameters:
  • direction – default..”ND”, “RD”, “TD”

  • widthPixel – horizontal size of the image [default: optimal size based on data]

  • interpolationType – interpolation type [default: “nearest”]

  • fileName – save to file instead of showing

plotPF(axis=[1, 0, 0], points=False, fileName=None, color='#1f77b4', alpha=1.0, show=True, density=256, size=2, proj2D='up-left', vmin=0.0, vmax=1.0)

plot pole figure

Projection onto 2D: cooradinate systems are given as xDirection-yDirection (z follows) - down-right: [default in text books, mTex] RD = x = down; TD = y = right; ND = z = outOfPlane - up-left: [default in OIM and here] RD = x = up; TD = y = left; ND = z = outOfPlane

Parameters:
  • axis – axis to plot: default: axis=1,0,0

  • points – plot individual points [default], or plot distribution

  • fileName – if given, save to file

  • color – plot color

  • alpha – alpha transparency

  • show – show figure [default], False for subsequent plotting

  • density – how many points to plot on the distribution

  • size – points: point size; distribution: amount of smoothing: higher more smoothing

  • proj2D – orientation of 2D projection: [down-right, up-left, None]

  • vmin – minimum value plotted, used as cut-off for transparency

  • vmax – max. used in color coding, allows to focus on minor texture

plotRGB(rgb, widthPixel=256, interpolationType='nearest', fileName=None)

given a RGB vector (same size as the other class vectors) plot the vector as an image<br> the x and y are given by the class-vector x and y USED INTERNALLY

Parameters:
  • rgb – matrix [3, classVectorSize] to be plotted as a 2D image

  • widthPixel – horizontal size of the image [default: 256 pixel]

  • interpolationType – interpolation type [default: “nearest”]

  • fileName – save to file instead of showing

removePointsOutsideMask()

set all data-points outside of mask to invalid such that after export to OIM, it will be read there as non-existing points

setVMask(every=1)

mask every kth point off, for fast plotting, does not influence results in any way

Parameters:

every – use only every k-th point. Improves plotting speed. every=1 resets.

writeANG(fileName)

write body of ang file

Parameters:

fileName – file name

class ebsdlab.orientation.Orientation(quaternion=Q(r=+1.000000, i=<+0.000000, +0.000000, +0.000000>), Rodrigues=None, angleAxis=None, matrix=None, Eulers=None, random=False, symmetry=None)

Bases: object

Orientation class: combination of material symmetry and specific rotation

IPFcolor(axis, proper=False)

color of inverse pole figure for given axis

Parameters:
  • axis – axis of pole figure (ND=001)

  • proper – considers only vectors with z >= 0, hence uses two neighboring SSTs to determine if in SST. i.e. allows more positive results, rgb-value does not depend on this

Returns:

vector of color (rgb)

property angleAxis
asAngleAxis(degrees=False)
asEulers(notation='bunge', degrees=False, standardRange=False)
asMatrix()
asQuaternion()
asRodrigues()
classmethod average(orientations, multiplicity=[])

Return the average orientation

ref: F. Landis Markley, Yang Cheng, John Lucas Crassidis, and Yaakov Oshman,

Averaging Quaternions, Journal of Guidance, Control, and Dynamics, Vol. 30, No. 4 (2007), pp. 1193-1197. doi: 10.2514/1.28949

Usage:
  • a = Orientation(Eulers=np.radians([10, 10, 0]), symmetry=’hexagonal’)

  • b = Orientation(Eulers=np.radians([20, 0, 0]), symmetry=’hexagonal’)

  • avg = Orientation.average([a,b])

Parameters:
  • cls – class method (void)

  • orientations – list of orientations

  • multiplicity

Returns:

average orientation (not rotation) in radians

copy()
disorientation(other, SST=True)

Disorientation between myself and given other orientation.

Rotation axis falls into SST if SST == True.

(Currently requires same symmetry for both orientations. Look into A. Heinz and P. Neumann 1991 for cases with differing sym.)

Args:

other: other orientation SST: True (rotation axis falls into SST); False

Returns:

disorientation quaternion, idx of equivalent orientation1, idx of equivalent orientation2, num. of conjugated

doctest
eps
equivalentOrientations(who=[])
equivalentQuaternions(who=[])
property eulers
inFZ()

Check whether given Rodrigues vector falls into fundamental zone of own symmetry.

property infz

Check whether given Rodrigues vector falls into fundamental zone of own symmetry.

inversePole(axis, proper=False, SST=True)

axis rotated according to orientation (using crystal symmetry to ensure location falls into SST)

Parameters:
  • axis – vector in crystal orientation, e.g. [100]

  • proper – considers only vectors with z >= 0, hence uses two neighboring SSTs to determine if in SST. i.e. allows more positive results, rgb-value does not depend on this

  • SST – iterate through all equivalent and find the one in the SST

Returns:

vector of axis

property matrix
plot(poles=None, unitCell=True, cos=True, annotate=False, plot2D=None, scale=2, fileName=None)

Plot rotated unit-cell in 3D, and possibly the pole-figure and specific poles

Projection onto 2D: cooradinate systems are given as xDirection-yDirection (z follows) - down-right: [default in text books] RD = x = down; TD = y = right; ND = z = outOfPlane - up-left: [default in OIM] RD = x = up; TD = y = left; ND = z = outOfPlane

Parameters:
  • poles – if given (e.g. [1,0,0]), plot pole-figure and the corresponding poles

  • unitCell – plot unit cell

  • cos – plot coordinate system

  • annotate – annotate poles in pole figure (requires poles given)

  • plot2D – do a normal projection onto 2D plane: [down-right, up-left, None]

  • scale – scale of pole-figure dome over crystal

  • fileName – fileName for image output (if given, image not shown)

plot2D
plotLine(ax, start, delta, color='k', lw=1, ls='solid', markerSize=None)

Plot one line using given projection

Parameters:
  • ax – axis to plot into

  • start – start coordinate

  • delta – delta cooradinate (end-start)

  • color – color

  • lw – line width

  • ls – line style “solid”,’dashed’

  • markerSize – size of marker (only used for non-lines: delta>0)

plotUnit(ax, xlabel, ylabel, zlabel, x=0, y=0, z=0, s=1)

Coordinate systems: see plotLine

Parameters:
  • ax – axis to used for plotting

  • xlabel – x-label

  • ylabel – y-label

  • zlabel – z-label

  • x – x-coordinate of origin

  • y – y-coordinate of origin

  • z – z-coordinate of origin

  • s – scale

project(x, y, z)

down-right: y, -x up-left : -y, x right-up : x,y left-down: -x,-y 3D : x,y,z

quaternion
reduced()

Transform orientation to fall into fundamental zone according to symmetry

related(relationModel, direction, targetSymmetry=None)

Related

Models:
  • KS from S. Morito et al./Journal of Alloys and Compounds 5775 (2013) S587-S592 DOES THIS PAPER EXISTS?

  • GT from Y. He et al./Journal of Applied Crystallography (2006). 39, 72-81

  • GT’ from Y. He et al./Journal of Applied Crystallography (2006). 39, 72-81

  • NW from H. Kitahara et al./Materials Characterization 54 (2005) 378-386

  • Pitsch from Y. He et al./Acta Materialia 53 (2005) 1179-1190

  • Bain from Y. He et al./Journal of Applied Crystallography (2006). 39, 72-81

Parameters:
  • relationModel

  • direction

  • targetSymmetry

Returns:

vector

property rodrigues
symmetry
toScreen(equivalent=True)

print Euler angles and HKL /UVW

Parameters:

equivalent – print also equivalent orientations

class ebsdlab.symmetry.Symmetry(symmetry=None)

Bases: object

copy()
equivalentQuaternions(quaternion, who=[])

List of symmetrically equivalent quaternions based on own symmetry.

inDisorientationSST(R)

Check whether given Rodrigues vector (of misorientation) falls into standard stereographic triangle of own symmetry.

Determination of disorientations follow the work of A. Heinz and P. Neumann: Representation of Orientation and Disorientation Data for Cubic, Hexagonal, Tetragonal and Orthorhombic Crystals Acta Cryst. (1991). A47, 780-789

inFZ(R)

Check whether given Rodrigues vector falls into fundamental zone of own symmetry.

inSST(vector, proper=False, color=False)

Check whether given vector falls into standard stereographic triangle of own symmetry.

Parameters:
  • vector – hkl vector tested/converted to rbg; considers only this vector, no crystal orientation

  • proper – considers only vectors with z >= 0, hence uses two neighboring SSTs to determine if in SST. i.e. allows more positive results, rgb-value does not depend on this

  • color – if true, return also color

Returns:

whether in SST (if requested) inverse pole figure color if in SST in RGB values

lattices = [None, 'orthorhombic', 'tetragonal', 'hexagonal', 'cubic']
standardTriangle(fileName=None, show=True, stepSize=0.01)

Plot standard triangle with background, discrete points in color, save to file, add text

Corner points of triangle - x=0.41421 =sqrt(2)-1 -> [110] corner at (0.41421,0) - [111] corner at (0.366025403784,0.366025403784)

Parameters:
  • fileName – save to file

  • show – True [default] shows figure, else not

  • stepSize – plotting accuracy: lower value=better quality

symmetryQuats(who=[])

List of symmetry operations as quaternions.

unitCell()

Return unit cell edges

xyToHKL(inPlane)

convert xy (coordinates in projection plane (-1<x<1,-1<y<1)) -> hkl

required for plotting the standardTriangle

Theory: - unscaled vector (x; y; 1) has to be scaled by l such that the scaled vector - unit_vector_Z has the unit length - scaled: ( xl; yl; l) - | (xl; yl; l-1) | =!=1 - -> l(x^2+y^2+1)=2 #2 is a random number - hkl = scaled - unit_vector_Z = (xl; yl; l-1)

Parameters:

inPlane – vector coordinates in the plane of the stereograhic projection plane

Returns:

hkl vector

class ebsdlab.quaternion.Quaternion(quatArray=[1.0, 0.0, 0.0, 0.0])

Bases: object

asAngleAxis(degrees=False)

Returns: tuple(angle,axis)

asEulers(notation='bunge', degrees=False, standardRange=False, round=8)

conversion of ACTIVE rotation to Euler angles taken from.

Melcher, A.; Unser, A.; Reichhardt, M.; Nestler, B.; Pötschke, M.; Selzer, M. Conversion of EBSD data by a quaternion based algorithm to be used for grain structure simulations Technische Mechanik 30 (2010) pp 401–413

asList()
asM()
asMatrix()
asRodrigues()
conjugate()
conjugated()
copy()
classmethod fromAngleAxis(angle, axis)
classmethod fromEulers(eulers, type='Bunge')
classmethod fromIdentity()
classmethod fromMatrix(m)

Modified Method to calculate Quaternion from Orientation Matrix

Source: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/

classmethod fromRandom(randomSeed=None)
classmethod fromRodrigues(rodrigues)
homomorph()
homomorphed()
identity()
inverse()
inversed()
magnitude()
magnitude_squared()
classmethod new_interpolate(q1, q2, t)

Interpolation

see http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20070017872_2007014421.pdf for (another?) way to interpolate quaternions

normalize()
normalized()
class ebsdlab.rodrigues.Rodrigues(vector=array([0., 0., 0.]))

Bases: object

asAngleAxis()
asQuaternion()