defdap.hrdic module¶
-
class
defdap.hrdic.
Map
(path, fname, dataType=None)[source]¶ Bases:
defdap.base.Map
Class to encapsulate DIC map data and useful analysis and plotting methods.
-
corrVal
¶ Correlation value.
- Type:
-
ebsdMap
¶ EBSD map linked to DIC map.
- Type:
-
ebsdTransform
¶ Transform from EBSD to DIC coordinates.
- Type:
various
-
ebsdTransformInv
¶ Transform from DIC to EBSD coordinates.
- Type:
various
-
cropDists
¶ Crop distances (default all zeros).
- Type:
-
data
¶ - Must contain after loading data (maps):
- coordinatenumpy.ndarray
X and Y coordinates
- displacementnumpy.ndarray
X and Y displacements
- Derived data:
- fnumpy.ndarray
Components of the deformation gradient (0=x, 1=y).
- enumpy.ndarray
Components of the green strain (0=x, 1=y).
- max_shearnumpy.ndarray
Max shear component np.sqrt(((e11 - e22) / 2.)**2 + e12**2).
- Type:
-
property
original_shape
¶
-
property
crystalSym
¶
-
setScale
(micrometrePerPixel)[source]¶ Sets the scale of the map.
- Parameters:
micrometrePerPixel (float) – Length of pixel in original BSE image in micrometres.
-
property
scale
¶ Returns the number of micrometers per pixel in the DIC map.
-
printStatsTable
(percentiles, components)[source]¶ Print out a statistics table for a DIC map
- Parameters:
percentiles (list of float) – list of percentiles to print i.e. 0, 50, 99.
components (list of str) – list of map components to print i.e. e, f, max_shear.
-
setCrop
(xMin=None, xMax=None, yMin=None, yMax=None, updateHomogPoints=False)[source]¶ Set a crop for the DIC map.
- Parameters:
-
crop
(mapData, binning=None)[source]¶ Crop given data using crop parameters stored in map i.e. cropped_data = DicMap.crop(DicMap.data_to_crop).
- Parameters:
mapData (numpy.ndarray) – Bap data to crop.
binned (bool) – True if mapData is binned i.e. binned BSE pattern.
-
linkEbsdMap
(ebsdMap, transformType='affine', **kwargs)[source]¶ Calculates the transformation required to align EBSD dataset to DIC.
- Parameters:
ebsdMap (defdap.ebsd.Map) – EBSD map object to link.
transformType (str, optional) – affine, piecewiseAffine or polynomial.
kwargs – All arguments are passed to estimate method of the transform.
-
warpToDicFrame
(mapData, cropImage=True, order=1, preserve_range=False)[source]¶ Warps a map to the DIC frame.
- Parameters:
mapData (numpy.ndarray) – Data to warp.
cropImage (bool, optional) – Crop to size of DIC map if true.
order (int, optional) – Order of interpolation (0: Nearest-neighbor, 1: Bi-linear…).
preserve_range (bool, optional) – Keep the original range of values.
- Returns:
Map (i.e. EBSD map data) warped to the DIC frame.
- Return type:
-
warp_lines_to_dic_frame
(lines)[source]¶ Warp a set of lines to the DIC reference frame.
- Parameters:
lines (list of tuples) – Lines to warp. Each line is represented as a tuple of start and end coordinates (x, y).
- Returns:
List of warped lines with same representation as input.
- Return type:
list of tuples
-
property
boundaries
¶ Returns EBSD map grain boundaries warped to DIC frame.
-
property
boundaryLines
¶
-
property
phaseBoundaryLines
¶
-
generateThresholdMask
(mask, dilation=0, preview=True)[source]¶ Generate a dilated mask, based on a boolean array and previews the appication of this mask to the max shear map.
- Parameters:
mask (numpy.array(bool)) – A boolean array where points to be removed are True
dilation (int, optional) – Number of pixels to dilate the mask by. Useful to remove anomalous points around masked values. No dilation applied if not specified.
preview (bool) – If true, show the mask and preview the masked effective shear strain map.
Examples
To remove data points in dicMap where max_shear is above 0.8, use:
>>> mask = dicMap.data.max_shear > 0.8
To remove data points in dicMap where e11 is above 1 or less than -1, use:
>>> mask = (dicMap.data.e[0, 0] > 1) | (dicMap.data.e[0, 0] < -1)
To remove data points in dicMap where corrVal is less than 0.4, use:
>>> mask = dicMap.corrVal < 0.4
Note: correlation value data needs to be loaded seperately from the DIC map, see
defdap.hrdic.loadCorrValData()
-
plotMaxShear
(**kwargs)[source]¶ Plot a map of maximum shear strain.
- Parameters:
kwargs – All arguments are passed to
defdap.plotting.MapPlot()
.- Returns:
Plot containing map.
- Return type:
-
plotGrainAvMaxShear
(**kwargs)[source]¶ Plot grain map with grains filled with average value of max shear. This uses the max shear values stored in grain objects, to plot other data use
plotGrainAv()
.- Parameters:
kwargs – All arguments are passed to
defdap.base.Map.plotGrainDataMap()
.
-
findGrains
(algorithm=None, minGrainSize=10)[source]¶ Finds grains in the DIC map.
- Parameters:
algorithm (str {'warp', 'floodfill'}) – Use floodfill or warp algorithm.
minGrainSize (int) – Minimum grain area in pixels for floodfill algorithm.
-
floodFill
(x, y, grainIndex, points_left)[source]¶ Flood fill algorithm that uses the combined x and y boundary array 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:
-
runGrainInspector
(vmax=0.1, corrAngle=0, RDRlength=3)[source]¶ Run the grain inspector interactive tool.
- Parameters:
vmax (float) – Maximum value of the colour map.
corrAngle (float) – Correction angle in degrees to subtract from measured angles to account for small rotation between DIC and EBSD frames. Approximately the rotation component of affine transform.
RDRlength (int) – Length of lines perpendicular to slip trace used to calculate RDR.
-
-
class
defdap.hrdic.
Grain
(grainID, dicMap)[source]¶ Bases:
defdap.base.Grain
Class to encapsulate DIC grain data and useful analysis and plotting methods.
-
dicMap
¶ DIC map this grain is a member of
- Type:
-
ownerMap
¶ DIC map this grain is a member of
- Type:
-
ebsdGrain
¶ EBSD grain ID that this DIC grain corresponds to.
- Type:
-
ebsdMap
¶ EBSD map that this DIC grain belongs to.
- Type:
-
pointsList
¶ Start and end points for lines drawn using defdap.inspector.GrainInspector.
- Type:
-
groupsList
¶ Groups, angles and slip systems detected for lines drawn using defdap.inspector.GrainInspector.
-
plotMaxShear
(**kwargs)[source]¶ Plot a maximum shear map for a grain.
- Parameters:
kwargs – All arguments are passed to
defdap.base.plotGrainData()
.- Returns:
- Return type:
-
property
refOri
¶ Returns average grain orientation.
- Returns:
- Return type:
-
property
slipTraces
¶ Returns list of slip trace angles based on EBSD grain orientation.
- Returns:
- Return type:
-
calcSlipTraces
(slipSystems=None)[source]¶ Calculates list of slip trace angles based on EBSD grain orientation.
- Parameters:
slipSystems (defdap.crystal.SlipSystem, optional) –
-
calcSlipBands
(grainMapData, thres=None, min_dist=None)[source]¶ Use Radon transform to detect slip band angles.
- Parameters:
grainMapData (numpy.ndarray) – Data to find bands in.
thres (float, optional) – Normalised threshold for peaks.
min_dist (int, optional) – Minimum angle between bands.
- Returns:
Detected slip band angles
- Return type:
-