defdap.ebsd module

class defdap.ebsd.Map(*args, **kwargs)[source]

Bases: Map

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

step_size

Step size in micron.

Type:

float

phases

List of phases.

Type:

list of defdap.crystal.Phase

mis_ori

Map of misorientation.

Type:

numpy.ndarray

mis_ori_axis

Map of misorientation axis components.

Type:

list of numpy.ndarray

origin

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

Type:

tuple(int)

data
Must contain after loading data (maps):
phasenumpy.ndarray

1-based, 0 is non-indexed points

euler_anglenumpy.ndarray

stored as (3, y_dim, x_dim) in radians

Generated data:
orientationnumpy.ndarray of defdap.quat.Quat

Quaterion for each point of map. Shape (y_dim, x_dim).

grain_boundaries : BoundarySet phase_boundaries : BoundarySet grains : numpy.ndarray of int

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.

KAMnumpy.ndarray

Kernal average misorientaion map.

GNDnumpy.ndarray

GND scalar map.

Nye_tensornumpy.ndarray

3x3 Nye tensor at each point.

Derived data:

Grain list data to map data from all grains

Type:

defdap.utils.Datastore

MAPNAME = 'ebsd'
load_data(file_name, data_type=None)[source]

Load in EBSD data from file.

Parameters:
  • file_name (pathlib.Path) – Path to EBSD file

  • data_type (str, {'OxfordBinary', 'OxfordText', 'EdaxAng', 'PythonDict'}) – 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 crystal_sym

Crystal symmetry of the primary phase.

Returns:

Crystal symmetry

Return type:

str

property c_over_a

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 num_phases
property primary_phase

Primary phase of the EBSD map.

Returns:

Primary phase

Return type:

defdap.crystal.Phase

property scale
rotate_data()[source]

Rotate map by 180 degrees and transform quats accordingly.

calc_euler_colour(map_data, phases=None, bg_colour=None)[source]
calc_ipf_colour(map_data, direction, phases=None, bg_colour=None)[source]
plot_euler_map(phases=None, bg_colour=None, **kwargs)[source]

Plot an orientation map in Euler colouring

Parameters:
Return type:

defdap.plotting.MapPlot

plot_ipf_map(direction, phases=None, bg_colour=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 direction.

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

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

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

Return type:

defdap.plotting.MapPlot

plot_phase_map(**kwargs)[source]

Plot a phase map.

Parameters:

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

Return type:

defdap.plotting.MapPlot

calc_kam()[source]

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

calc_nye()[source]

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

calc_quat_array()[source]

Build quaternion array

filter_data(misori_tol=5)[source]
find_boundaries(misori_tol=10)[source]

Find grain and phase boundaries

Parameters:

misori_tol (float) – Critical misorientation in degrees.

build_neighbour_network()[source]

Construct a list of neighbours

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

Plot phase boundary map.

Parameters:
Return type:

defdap.plotting.MapPlot

plot_boundary_map(**kwargs)[source]

Plot grain boundary map.

Parameters:

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

Return type:

defdap.plotting.MapPlot

find_grains(min_grain_size=10)[source]

Find grains and assign IDs.

Parameters:

min_grain_size (int) – Minimum grain area in pixels.

plot_grain_map(**kwargs)[source]

Plot a map with grains coloured.

Parameters:

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

Return type:

defdap.plotting.MapPlot

calc_grain_av_oris()[source]

Calculate the average orientation of grains.

calc_grain_mis_ori(calc_axis=False)[source]

Calculate the misorientation within grains.

Parameters:

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

plot_mis_ori_map(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

calc_average_grain_schmid_factors(load_vector, slip_systems=None)[source]

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

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

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

calc_rdr()[source]

Calculates Relative Displacent Ratio values for all grains

plot_average_grain_schmid_factors_map(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(grain_id, ebsdMap, group_id)[source]

Bases: Grain

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

ebsd_map

EBSD map this grain is a member of.

Type:

defdap.ebsd.Map

owner_map

EBSD map this grain is a member of.

Type:

defdap.ebsd.Map

phase_id
Type:

int

phase
Type:

defdap.crystal.Phase

data
Must contain after creating:
pointlist of tuples

(x, y)

Generated data:

GROD : numpy.ndarray

GROD_axis : numpy.ndarray

Derived data:

Map data to list data from the map the grain is part of

Type:

defdap.utils.Datastore

mis_ori_listlist

MisOri at each point in grain.

mis_ori_axis_listlist

MisOri axes at each point in grain.

ref_oridefdap.quat.Quat

Average ori of grain

average_mis_ori

Average mis_ori of grain.

average_schmid_factorslist

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

slip_trace_angleslist

Slip trace angles in screen plane.

slip_trace_inclinationslist

Angle between slip plane and screen plane.

property crystal_sym

Temporary

calc_average_ori()[source]

Calculate the average orientation of a grain.

build_mis_ori_list(calc_axis=False)[source]

Calculate the misorientation within given grain.

Parameters:

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

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

Plot the average grain orientation on an IPF.

Parameters:
Return type:

defdap.plotting.PolePlot

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

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

Parameters:
Return type:

defdap.plotting.PolePlot

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

Plot an unit cell of the average grain orientation.

Parameters:
plot_mis_ori(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.plot_grain_data().

Return type:

defdap.plotting.GrainPlot

calc_average_schmid_factors(load_vector, slip_systems=None)[source]

Calculate Schmid factors for grain, using average orientation.

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

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

calc_rdr()[source]

Calculate Relative Displacement Ratio values.

property slip_traces

Returns list of slip trace angles.

Returns:

Slip trace angles based on grain orientation in calc_slip_traces.

Return type:

list

print_slip_traces()[source]

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

calc_slip_traces(slip_systems=None)[source]

Calculates list of slip trace angles based on grain orientation.

Parameters:

slip_systems (defdap.crystal.SlipSystem, optional) –

class defdap.ebsd.BoundarySet(ebsd_map, points_x, points_y)[source]

Bases: object

classmethod from_image(ebsd_map, image_x, image_y)[source]
classmethod from_boundary_segments(b_segs)[source]
property points
property image_x
property image_y
property image
property lines
static boundary_points_to_lines(*, boundary_points_x=None, boundary_points_y=None)[source]
class defdap.ebsd.BoundarySegment(ebsdMap, grain1, grain2)[source]

Bases: object

addBoundaryPoint(point, kind, owner_grain)[source]
boundary_point_pairs(kind)[source]

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

property boundary_point_pairs_x

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

property boundary_point_pairs_y

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

property boundary_lines

Return line points along this boundary segment

misorientation()[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]

Interactive tool to set origin of each EBSD map.

Parameters:

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

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.