-
Notifications
You must be signed in to change notification settings - Fork 4
/
ebsd.doctest
307 lines (275 loc) · 10.9 KB
/
ebsd.doctest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/** \file
\brief Tutorials for ebsd
\section tutorials Tutorials
\subsection example1 Example: Read EBSD data and plot the ND IPF
- plot confidence index (CI). Mask out all points with a CI less than 0.1. Initially all points are present in the mask, i.e. they are shown. By masking out points, these are removed from the mask.
- plot inverse pole figure in normal direction
- play with different options (1024pixel to see speed of plotting)
- setVMask: for fast plotting;
- pole figure (PF) in the [1,0,0] direction. The OIM software has the top left corner has coordinate origin
\verbatim
>>> from ebsd import EBSD
>>> from verifyAll import doctestImage
>>> e = EBSD("Examples/EBSD.ang", doctest=True)
Load .ang file: Examples/EBSD.ang
Read file with step size: 0.2 0.2
Optimal image pixel size: 103
Number of points: 23909
>>> e.plot(e.CI)
>>> doctestImage("ebsd_1")
doctest 1
>>> e.maskCI( 0.1 )
>>> e.plot( e.CI )
>>> doctestImage("ebsd_2")
doctest 1
>>> e.plotIPF()
>>> doctestImage("ebsd_3")
doctest 1
>>> e.plotIPF(1024)
>>> doctestImage("ebsd_4")
doctest 1
>>> e.addScaleBar()
>>> doctestImage("ebsd_5")
doctest 1
>>> e.setVMask(4) # use only every 4th point, increases plotting speed
>>> e.plotIPF(1024)
>>> doctestImage("ebsd_6")
doctest 1
>>> e.cropVMask(0,0,10,10) # show only a section of the image, increases plotting speed
>>> e.plotIPF(1024)
>>> doctestImage("ebsd_7")
doctest 1
>>> e.plotPF([1,0,0])
>>> doctestImage("ebsd_8")
doctest 1
>>> e.plotPF([1,0,0],points=True)
>>> doctestImage("ebsd_9")
doctest 1
\endverbatim
\image html ebsd_py_ND.png
\subsection example2 Example: Interaction with OIM Software to update grain information from different file
How to export txt-file from OIM that can be read:
- Partition->export-> grain file -> use "grain file type 1" (saves a txt file)
- Partition->export-> partition data -> save as .ang
Warning: This is example input file does not exist, anymore. Not tested
\verbatim
> e = EBSD("Examples/Test.ang")
> e.loadTXT("Examples/TestB.txt")
> e.maskCI(0.1)
> e.removePointsOfMask()
> e.writeANG("ebsd.ang")
\endverbatim
Which can then be read in OIM again
\subsection example3 Compare with OIM software and verify pole-figure
\verbatim
>>> import numpy as np
>>> from ebsd import EBSD
>>> from ebsd_Orientation import Orientation
>>> e = EBSD("Examples/EBSD.ang", doctest=True)
Load .ang file: Examples/EBSD.ang
Read file with step size: 0.2 0.2
Optimal image pixel size: 103
Number of points: 23909
>>> e.maskCI( 0.001 )
>>> e.plotIPF('ND') #doctest: +SKIP
>>> e.cropVMask(xmin=18,ymin=12,ymax=17)
>>> e.plotIPF('ND') #doctest: +SKIP
\endverbatim
Inspect the original data at x,y = 20.1,14.38 um <br>
line 8785 from EBSD.ang <br>
5.55763 2.18448 3.83349 20.10000 14.37602 3653.496 0.482 0 1 1.104 <br>
\verbatim
>>> print (np.degrees([ 5.55763, 2.18448, 3.83349]))
[318.4287431 125.16148443 219.64279781]
>>> e.cropVMask(xmin=20,xmax=20.2,ymin=14.3,ymax=14.4)
>>> e.y[e.vMask] #verify y: correct if rounding accounted for
array([14.37602])
>>> angle = e.quaternions[e.vMask].asEulers().flatten()
>>> print (np.round(np.degrees(angle))) #convert to only positive values
[ -42. 125. -140.]
>>> print (np.round(np.degrees(angle)+np.array([360,0,360])))
[318. 125. 220.]
\endverbatim
Plot correct unit cells and pole-figures using the orientation-class
\verbatim
>>> o = Orientation(Eulers=angle, symmetry="cubic")
>>> o.doctest=True
>>> o.toScreen() #first item is one looking for #doctest: +SKIP
>>> o.plot(plot2D='up-left')
>>> doctestImage("ebsd_10")
doctest 1
>>> o.plot(poles=[1,0,0],plot2D='up-left',scale=1.5)
>>> doctestImage("ebsd_11")
doctest 1
\endverbatim
Create artificial ebsd pattern to check PF
\verbatim
>>> e = EBSD('void318.|125.|219.6|0|2', doctest=True)
Void mode 318.|125.|219.6|0|2
Euler angles: 5.55 2.18 3.83 | distribution: 0.0 | numberPerAxis: 2.0
Read file with step size: 1.0 1.0
Optimal image pixel size: 1
Number of points: 4
>>> e.plotPF(size=5)
>>> doctestImage("ebsd_12")
doctest 1
>>> e.plotPF(points=True)
>>> doctestImage("ebsd_13")
doctest 1
\endverbatim
Finally, inspect pole-figure of data and compare OIM software, mTex and this python code
\verbatim
>>> e = EBSD("Examples/EBSD.ang", doctest=True)
Load .ang file: Examples/EBSD.ang
Read file with step size: 0.2 0.2
Optimal image pixel size: 103
Number of points: 23909
>>> e.maskCI( 0.001 )
>>> e.plotPF(size=1) #doctest: +SKIP
>>> e.plotPF() #doctest: +SKIP
>>> e.plotPF(proj2D='down-right')
>>> doctestImage("ebsd_14")
doctest 1
\endverbatim
\htmlonly
<table border=1>
<tr><td><center>description</center></td>
<td><center>OIM software</center></td>
<td><center>mTex software</center></td>
<td><center>this python code</center></td></tr>
<tr><td><center>IPF ND*</center> </td>
<td><image src="HTMLInputStatic/ebsd_OIM_ND.bmp" height=300px></td>
<td><image src="HTMLInputStatic/ebsd_mTex_ND.png" height=300px></td>
<td><image src="HTMLInputStatic/ebsd_py_ND.png" height=300px></td></tr>
<tr><td><center>IPF RD</center> </td>
<td><image src="HTMLInputStatic/ebsd_OIM_RD.bmp" height=300px></td>
<td><center>I cannot produce</center></td>
<td><image src="HTMLInputStatic/ebsd_py_RD.png" height=300px></td></tr>
<tr><td><center>PF [100]</center> </td>
<td><image src="HTMLInputStatic/ebsd_OIM_PF001.bmp" height=200px></td>
<td><image src="HTMLInputStatic/ebsd_mTex_PF100_xNorthzOutOfPlane.png" height=200px></td>
<td><image src="HTMLInputStatic/ebsd_py_PF100.png" height=200px></td></tr>
<tr><td><center>PF [100] contour</center> </td>
<td><center>I cannot produce</center></td>
<td><image src="HTMLInputStatic/ebsd_mTex_PF100Contour_xNorthzOutOfPlane.png" height=200px></td>
<td><image src="HTMLInputStatic/ebsd_py_PF100Contour.png" height=200px></td></tr>
<tr><td><center>PF [111]</center> </td>
<td><image src="HTMLInputStatic/ebsd_OIM_PF111.bmp" height=200px></td>
<td><image src="HTMLInputStatic/ebsd_mTex_PF111_xNorthzOutOfPlane.png" height=200px></td>
<td><image src="HTMLInputStatic/ebsd_py_PF111.png" height=200px></td></tr>
</table>
Issues from mTex:
<ul>
<li>.bmp (left): low color number when exporting from external window. .png works (right)<br>
<image src="HTMLInputStatic/ebsd_mTex_ND.bmp" height=300px>
<image src="HTMLInputStatic/ebsd_mTex_ND.png" height=300px>
<li>Explicitly select x-axis as North and z-axis as outOfPlane; normal orientation has different result, although it should be the same<br>
<image src="HTMLInputStatic/ebsd_mTex_PF100Contour_xNorthzOutOfPlane.png" height=200px>
<image src="HTMLInputStatic/ebsd_mTex_PF100Contour_org.png" height=200px>
</ul>
\endhtmlonly
\subsection example4 Average orientation in file, does not make sence for this multi-grain case
averaging takes lots of time: Orientation.average()
\verbatim
>>> from ebsd_Orientation import Orientation
>>> from ebsd import EBSD
>>> Orients = []
>>> e = EBSD("Examples/EBSD.ang", doctest=True)
Load .ang file: Examples/EBSD.ang
Read file with step size: 0.2 0.2
Optimal image pixel size: 103
Number of points: 23909
>>> for i in range(len(e.x)):
... Orients.append(Orientation(quaternion=e.quaternions[i], symmetry="cubic"))
>>> avg = Orientation.average( Orients)
>>> print ("Average orientation",np.round(avg.asEulers(degrees=True, standardRange=True),0)) #doctest: +SKIP
\endverbatim
\subsection compare Compare the three software for bicrystal
\htmlonly
<table border=1>
<tr><td><center>description</center></td>
<td><center>OIM software</center></td>
<td><center>mTex software</center></td>
<td><center>this python code</center></td></tr>
<tr><td><center>IPF ND*</center> </td>
<td><image src="HTMLInputStatic/bc_OIM_ND.bmp" width=300px></td>
<td><image src="HTMLInputStatic/bc_mTex_ND.png" width=300px></td>
<td><image src="HTMLInputStatic/bc_py_ND.png" width=300px></td></tr>
<tr><td><center>IPF RD</center> </td>
<td><image src="HTMLInputStatic/bc_OIM_RD_y.bmp" width=300px></td>
<td><center>I cannot produce</center></td>
<td><image src="HTMLInputStatic/bc_py_RD.png" width=300px></td></tr>
<tr><td><center>PF [100]</center> </td>
<td><image src="HTMLInputStatic/bc_OIM_PF.bmp" height=200px></td>
<td><image src="HTMLInputStatic/bc_mTex_PF.png" height=200px></td>
<td><image src="HTMLInputStatic/bc_py_PF.png" height=200px></td></tr>
</table>
\endhtmlonly
Python code
\verbatim
>>> from ebsd import EBSD
>>> e = EBSD("Examples/EBSD.ang", doctest=True)
Load .ang file: Examples/EBSD.ang
Read file with step size: 0.2 0.2
Optimal image pixel size: 103
Number of points: 23909
>>> e.cropVMask(ymin=35)
>>> e.plotIPF("ND",fileName="doctest.png")
>>> e.addSymbol(5,37, scale=2)
>>> e.addSymbol(18,37, scale=2,fileName="doctest.png")
>>> doctestImage("ebsd_16")
doctest 1
>>> e.plotIPF("RD",fileName="pythonRD.png")
>>> e.addSymbol(5,37, scale=2)
>>> e.addSymbol(18,37, scale=2,fileName="pythonRD.png")
>>> doctestImage("ebsd_17")
doctest 1
>>> e.plotIPF("TD",fileName="pythonTD.png")
>>> e.addSymbol(5,37, scale=2)
>>> e.addSymbol(18,37, scale=2,fileName="pythonTD.png")
>>> doctestImage("ebsd_18")
doctest 1
>>> e.plotPF( fileName="pythonPF.png")
\endverbatim
please, note, the last image is not colored. This is not implemented yet. TODO
\section mTex how to run mTex
\verbatim
>> startup_mtex
>> import_wizard('ebsd')
% and select EBSD.osc
% select plotting convention 5: x-to-right; y-to-bottom
% select "convert Euler 2 Spacial Referecence Frame"
% save to workspace variable
>> csCopper = ebsd('Cu').CS;
>> plot(ebsd('Cu'),ebsd('Cu').orientations,'coordinates','on')
>> cS = crystalShape.cube(ebsd.CS)
>> region = [0 35 50 50];
>> ebsdC = ebsd(inpolygon(ebsd,region))
>> plot(ebsdC('Cu'),ebsdC('Cu').orientations,'coordinates','on')
>> plotPDF(ebsd('Cu').orientations, Miller({1 0 0},csCopper))
% select xNorth zOutOfPlane as axis in mTex
>> plotPDF(ebsd('Cu').orientations, Miller({1 1 1},csCopper))
>> odf = calcODF(ebsd('Cu').orientations)
>> plotPDF(odf,Miller({1 0 0},csCopper) )
\endverbatim
If separate window: save as png, because bmp colorscale is broken
- if not separet window: save as bmp, because png crops sections off
select xNorth zOutOfPlane as axis in mTex
- compare to original which should be the same
\section data Data that exists and can be used for plotting in plot:
- OIM software:
- e.phi1, e.PHI, e.phi2 : Euler angles saved as quaternions
- e.x, e.y : x,y coordinates
- e.IQ, e.CI, e.phaseID : Image Quality, confidence index (bad=0 ... good=1) , phase id
- e.SEMsignal : SEM signal
- e.fit :
- Oxford:
- bc: band contrast
\section developerHints Hints for developers
- run ./verifyAll.py after all changes to verify the code and create the html-documentation
- git commands
- git add -A
- git gui
- git commit -m "solved symbolic link issue"
- git push -u origin master
*/