import numpy as np
import matplotlib.pyplot as plt
from defdap.quat import Quat
import defdap.ebsd as ebsd
from defdap.plotting import PolePlot
%matplotlib qt
EbsdFilePath = "/Users/mbcx9ma4/Dropbox (The University of Manchester)/Beta Reconstruction/data/triple_point/ZrNb_triplepoint_alpha"
EbsdMap = ebsd.Map(EbsdFilePath, "hexagonal")
EbsdMap.buildQuatArray()
boundaryMisOri = 3.
EbsdMap.findBoundaries(boundDef=boundaryMisOri)
EbsdMap.findGrains(minGrainSize=2)
Loaded EBSD data (dimensions: 285 x 276 pixels, step size: 5.0 um) Finding grains...new flood 7 Done
%timeit EbsdMap.findGrains(minGrainSize=2)
Done 2.3 s ± 30.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
EbsdMap.plotEulerMap(plotGBs=False)
<defdap.plotting.MapPlot at 0x1c22dabc18>
plt.figure()
plt.imshow(-EbsdMap.boundaries)
<matplotlib.image.AxesImage at 0x1c20239780>
plt.figure()
plt.imshow(EbsdMap.misOriY > 8.)
<matplotlib.image.AxesImage at 0x1c275cbda0>
boundaryPoints = np.where(EbsdMap.misOriX > boundaryMisOri)
boundarySegmentsX = []
for i, j in zip(*boundaryPoints):
boundarySegmentsX.append( ((j+0.5, i-0.5), (j+0.5, i+0.5)) )
boundaryPoints = np.where(EbsdMap.misOriY > boundaryMisOri)
boundarySegmentsY = []
for i, j in zip(*boundaryPoints):
boundarySegmentsY.append( ((j-0.5, i+0.5), (j+0.5, i+0.5)) )
boundaryPoints = np.where(EbsdMap.boundaries == -1)
boundarySegments = []
for i, j in zip(*boundaryPoints):
boundarySegments.append( ((j-0.5, i+0.5), (j+0.5, i+0.5)) )
boundarySegments.append( ((j+0.5, i-0.5), (j+0.5, i+0.5)) )
import pylab as pl
from matplotlib import collections as mc
# plt.figure()
# plt.imshow(-EbsdMap.boundaries)
# EbsdMap.plotEulerMap()
EbsdMap.locateGrainID()
ax = plt.gca()
boundarySegments = boundarySegmentsX + boundarySegmentsY
lc = mc.LineCollection(boundarySegments, colors=(0,0,0,1), linewidths=2)
ax.add_collection(lc)
ax.autoscale()
EbsdMap.plotGrainMap(plotColourBar=True)
<defdap.plotting.MapPlot at 0x1c2402a588>
boundariesX = EbsdMap.misOrix > 3.
plt.imshow(boundariesX)
<matplotlib.image.AxesImage at 0x1c241f1470>
-boundariesX.astype(int)
array([[ 0, 0, -1, ..., -1, 0, 0], [-1, 0, 0, ..., 0, 0, 0], [-1, 0, -1, ..., -1, 0, 0], ..., [ 0, -1, -1, ..., -1, -1, 0], [ 0, -1, 0, ..., -1, -1, 0], [-1, 0, -1, ..., 0, -1, 0]])
edge = [(1, 2), (3, 4)]
x, y = edge.pop(0)
print(x)
print(y)
print(edge)
1 2 [(3, 4)]