defdap.ebsd module

class defdap.ebsd.Map(fileName, dataType=None)[source]

Bases: Map

Class to encapsulate an EBSD map and useful analysis and plotting methods.

xDim

Size of map in x direction.

Type:

int

yDim

Size of map in y direction.

Type:

int

stepSize

Step size in micron.

Type:

float

eulerAngleArray

Euler angles for eaxh point of the map. Shape (3, yDim, xDim).

Type:

numpy.ndarray

bandContrastArray

Band contrast for each point of map. Shape (yDim, xDim).

Type:

numpy.ndarray

quatArray

Quaterions for each point of map. Shape (yDim, xDim).

Type:

numpy.ndarray of defdap.quat.Quat

phaseArray

Map of phase ids. 1-based, 0 is non-indexed points

Type:

numpy.ndarray

phases

List of phases.

Type:

list of defdap.crystal.Phase

boundaries

Map of boundaries. -1 for a boundary, 0 otherwise.

Type:

numpy.ndarray

phaseBoundaries

Map of phase boundaries. -1 for boundary, 0 otherwise.

Type:

numpy.ndarray

grains

Map of grains. Grain numbers start at 1 here but everywhere else grainID starts at 0. Regions that are smaller than the minimum grain size are given value -2. Remnant boundary points are -1.

Type:

numpy.ndarray

misOri

Map of misorientation.

Type:

numpy.ndarray

misOriAxis

Map of misorientation axis components.

Type:

list of numpy.ndarray

kam

Map of KAM.

Type:

numpy.ndarray

origin

Map origin (x, y). Used by linker class where origin is a homologue point of the maps.

Type:

tuple(int)

GND

GND scalar map.

Type:

numpy.ndarray

Nye

3x3 Nye tensor at each point.

Type:

numpy.ndarray

loadData(fileName, dataType=None)[source]

Load in EBSD data from file.

Parameters:
  • fileName (str) – Path to EBSD file, including name, excluding extension.

  • dataType (str, {'OxfordBinary', 'OxfordText'}) – Format of EBSD data file.

save(file_name, data_type=None, file_dir='')[source]

Save EBSD map to file.

Parameters:
  • file_name (str) – Name of file to save to, it must not already exist.

  • data_type (str, {'OxfordText'}) – Format of EBSD data file to save.

  • file_dir (str) – Directory to save the file to.

property crystalSym

Crystal symmetry of the primary phase.

Returns:

Crystal symmetry

Return type:

str

property cOverA

C over A ratio of the primary phase

Returns:

C over A ratio if hexagonal crystal structure otherwise None

Return type:

float or None

property numPhases
property primaryPhase

Primary phase of the EBSD map.

Returns:

Primary phase

Return type:

defdap.crystal.Phase

property scale
rotateData()[source]

Rotate map by 180 degrees and transform quats accordingly.

plotBandContrastMap(**kwargs)[source]

Plot band contrast map

kwargs

All arguments are passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

plotEulerMap(phases=None, **kwargs)[source]

Plot an orientation map in Euler colouring

Parameters:
Return type:

defdap.plotting.MapPlot

plotIPFMap(direction, backgroundColour=None, phases=None, **kwargs)[source]

Plot a map with points coloured in IPF colouring, with respect to a given sample direction.

Parameters:
  • direction (np.array len 3) – Sample directiom.

  • backgroundColour (np.array len 3) – Colour of background (i.e. for phases not plotted).

  • phases (list of int) – Which phases to plot IPF data for.

  • kwargs – Other arguments passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

plotPhaseMap(**kwargs)[source]

Plot a phase map.

Parameters:

kwargs – All arguments passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

calcKam()[source]

Calculates Kernel Average Misorientaion (KAM) for the EBSD map, based on a 3x3 kernel. Crystal symmetric equivalences are not considered. Stores result in self.kam.

plotKamMap(**kwargs)[source]

Plot Kernel Average Misorientaion (KAM) for the EBSD map.

Parameters:

kwargs – All arguments are passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

calcNye()[source]

Calculates Nye tensor and related GND density for the EBSD map. Stores result in self.Nye and self.GND. Uses the crystal symmetry of the primary phase.

plotGNDMap(**kwargs)[source]

Plots a map of geometrically necessary dislocation (GND) density

Parameters:

kwargs – All arguments are passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

checkDataLoaded()[source]

Checks if EBSD data is loaded

Returns:

True if data loaded

Return type:

bool

buildQuatArray(force=False)[source]

Build quaternion array

Parameters:

force (bool, optional) – If true, re-build quaternion array

filterData(misOriTol=5)[source]
findBoundaries(boundDef=10)[source]

Find grain and phase boundaries

Parameters:

boundDef (float) – Critical misorientation.

buildNeighbourNetwork()[source]

Construct a list of neighbours

plotPhaseBoundaryMap(dilate=False, **kwargs)[source]

Plot phase boundary map.

Parameters:
Return type:

defdap.plotting.MapPlot

plotBoundaryMap(**kwargs)[source]

Plot grain boundary map.

Parameters:

kwargs – All arguments are passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

findGrains(minGrainSize=10)[source]

Find grains and assign IDs.

Parameters:

minGrainSize (int) – Minimum grain area in pixels.

plotGrainMap(**kwargs)[source]

Plot a map with grains coloured.

Parameters:

kwargs – All arguments are passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

floodFill(x, y, grainIndex, points_left)[source]

Flood fill algorithm that uses the x and y boundary arrays to fill a connected area around the seed point. The points are inserted into a grain object and the grain map array is updated.

Parameters:
  • x (int) – Seed point x for flood fill

  • y (int) – Seed point y for flood fill

  • grainIndex (int) – Value to fill in grain map

  • points_left (numpy.ndarray) – Boolean map of the points that have not been assigned a grain yet

Returns:

currentGrain – New grain object with points added

Return type:

defdap.ebsd.Grain

calcGrainAvOris()[source]

Calculate the average orientation of grains.

calcGrainMisOri(calcAxis=False)[source]

Calculate the misorientation within grains.

Parameters:

calcAxis (bool) – Calculate the misorientation axis if True.

plotMisOriMap(component=0, **kwargs)[source]

Plot misorientation map.

Parameters:
  • component (int, {0, 1, 2, 3}) – 0 gives misorientation, 1, 2, 3 gives rotation about x, y, z

  • kwargs – All other arguments are passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

calcAverageGrainSchmidFactors(loadVector, slipSystems=None)[source]

Calculates Schmid factors for all slip systems, for all grains, based on average grain orientation.

Parameters:
  • loadVector – Loading vector, e.g. [1, 0, 0].

  • slipSystems (list, optional) – Slip planes to calculate Schmid factor for, maximum of all planes calculated if not given.

plotAverageGrainSchmidFactorsMap(planes=None, directions=None, **kwargs)[source]

Plot maximum Schmid factor map, based on average grain orientation (for all slip systems unless specified).

Parameters:
  • planes (list, optional) – Plane ID(s) to consider. All planes considered if not given.

  • directions (list, optional) – Direction ID(s) to consider. All directions considered if not given.

  • kwargs – All other arguments are passed to defdap.plotting.MapPlot.create().

Return type:

defdap.plotting.MapPlot

class defdap.ebsd.Grain(grainID, ebsdMap)[source]

Bases: Grain

Class to encapsulate a grain in an EBSD map and useful analysis and plotting methods.

ebsdMap

EBSD map this grain is a member of.

Type:

defdap.ebsd.Map

ownerMap

EBSD map this grain is a member of.

Type:

defdap.ebsd.Map

phaseID
Type:

int

phase
Type:

defdap.crystal.Phase

quatList

List of quats.

Type:

list

misOriList

MisOri at each point in grain.

Type:

list

misOriAxisList

MisOri axes at each point in grain.

Type:

list

refOri

Average ori of grain

Type:

defdap.quat.Quat

averageMisOri

Average misOri of grain.

averageSchmidFactors

List of list Schmid factors (grouped by slip plane).

Type:

list

slipTraceAngles

Slip trace angles in screen plane.

Type:

list

slipTraceInclinations

Angle between slip plane and screen plane.

Type:

list

property plotDefault
property crystalSym

Temporary

addPoint(coord, quat)[source]

Append a coordinate and a quat to a grain.

Parameters:
calcAverageOri()[source]

Calculate the average orientation of a grain.

buildMisOriList(calcAxis=False)[source]

Calculate the misorientation within given grain.

Parameters:

calcAxis (bool) – Calculate the misorientation axis if True.

plotRefOri(direction=array([0, 0, 1]), **kwargs)[source]

Plot the average grain orientation on an IPF.

Parameters:
Return type:

defdap.plotting.PolePlot

plotOriSpread(direction=array([0, 0, 1]), **kwargs)[source]

Plot all orientations within a given grain, on an IPF.

Parameters:
Return type:

defdap.plotting.PolePlot

plotUnitCell(fig=None, ax=None, plot=None, **kwargs)[source]

Plot an unit cell of the average grain orientation.

Parameters:
plotMisOri(component=0, **kwargs)[source]

Plot misorientation map for a given grain.

Parameters:
  • component (int, {0, 1, 2, 3}) – 0 gives misorientation, 1, 2, 3 gives rotation about x, y, z.

  • kwargs – All other arguments are passed to defdap.ebsd.plotGrainData().

Return type:

defdap.plotting.GrainPlot

calcAverageSchmidFactors(loadVector, slipSystems=None)[source]

Calculate Schmid factors for grain, using average orientation.

Parameters:
  • loadVector (numpy.ndarray) – Loading vector, i.e. [1, 0, 0]

  • slipSystems (list, optional) – Slip planes to calculate Schmid factor for. Maximum for all planes used if not set.

property slipTraces

Returns list of slip trace angles.

Returns:

Slip trace angles based on grain orientation in calcSlipTraces.

Return type:

list

printSlipTraces()[source]

Print a list of slip planes (with colours) and slip directions

calcSlipTraces(slipSystems=None)[source]

Calculates list of slip trace angles based on grain orientation.

Parameters:

slipSystems (defdap.crystal.SlipSystem, optional) –

class defdap.ebsd.BoundarySegment(ebsdMap, grain1, grain2)[source]

Bases: object

addBoundaryPoint(point, kind, ownerGrain)[source]
boundaryPointPairs(kind)[source]

Return pairs of points either side of the boundary. The first point is always in grain1

property boundaryPointPairsX

Return pairs of points either side of the boundary. The first point is always in grain1

property boundaryPointPairsY

Return pairs of points either side of the boundary. The first point is always in grain1

property boundaryLines

Return line points along this boundary segment

misorientation()[source]
static boundary_points_to_lines(*, boundary_points_x=None, boundary_points_y=None)[source]
class defdap.ebsd.Linker(ebsd_maps)[source]

Bases: object

Class for linking multiple EBSD maps of the same region for analysis of deformation.

ebsd_maps

List of ebsd.Map objects that are linked.

Type:

list(ebsd.Map)

List of grain link. Each link is stored as a tuple of grain IDs (one from each map stored in same order of maps).

Type:

list(tuple(int))

plots

List of last opened plot of each map.

Type:

list(plotting.MapPlot)

set_origin(**kwargs)[source]

Interacive tool to set origin of each EBSD map.

Parameters:

kwargs – Keyword arguments passed to defdap.ebsd.Map.plotDefault()

click_set_origin(event, plot)[source]

Event handler for clicking to set origin of map.

Parameters:
start_linking()[source]

Start interactive grain linking process of each EBSD map.

click_grain_guess(event, plot)[source]

Guesses grain position in other maps, given click on one.

Parameters:

Make a link between the EBSD maps after clicking.

Reset links.

set_ref_ori_from_master()[source]

Loop over each map (not first/reference) and each link. Sets refOri of linked grains to refOri of grain in first map.

update_misori(calc_axis=False)[source]

Recalculate misorientation for linked grain (not for first map)

Parameters:

calc_axis (bool) – Calculate the misorientation axis if True.