Misorientation profile¶
In this notebook, we will perform a misorientation profile analysis.
import xarrayaita.loadData_aita as lda #here are some function to build xarrayaita structure
import xarrayaita.aita as xa
import xarray as xr
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
%matplotlib widget
Load your data¶
# path to data and microstructure
path_data='orientation_test.dat'
path_micro='micro_test.bmp'
data=lda.aita5col(path_data,path_micro)
data
<xarray.Dataset> Dimensions: (uvecs: 2, x: 1000, y: 2500) Coordinates: * x (x) float64 0.0 0.02 0.04 0.06 0.08 ... 19.92 19.94 19.96 19.98 * y (y) float64 49.98 49.96 49.94 49.92 49.9 ... 0.06 0.04 0.02 0.0 Dimensions without coordinates: uvecs Data variables: orientation (y, x, uvecs) float64 2.395 0.6451 5.377 ... 0.6098 0.6473 quality (y, x) int64 0 90 92 93 92 92 94 94 ... 96 96 96 96 96 97 97 96 micro (y, x) float64 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 grainId (y, x) int64 1 1 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1 1 Attributes: date: Thursday, 19 Nov 2015, 11:24 am unit: millimeters step_size: 0.02 path_dat: orientation_test.dat
- uvecs: 2
- x: 1000
- y: 2500
- x(x)float640.0 0.02 0.04 ... 19.94 19.96 19.98
array([ 0. , 0.02, 0.04, ..., 19.94, 19.96, 19.98])
- y(y)float6449.98 49.96 49.94 ... 0.04 0.02 0.0
array([4.998e+01, 4.996e+01, 4.994e+01, ..., 4.000e-02, 2.000e-02, 0.000e+00])
- orientation(y, x, uvecs)float642.395 0.6451 ... 0.6098 0.6473
array([[[2.39476627, 0.64507369], [5.37718489, 1.04999008], [5.38905313, 1.05627326], ..., [2.05826679, 0.49654617], [5.65731024, 0.94160513], [5.68523551, 1.03218772]], [[5.35955707, 1.15837502], [5.35885894, 1.12975162], [5.3613024 , 1.11701072], ..., [2.07659274, 0.52063172], [5.64753639, 0.94073247], [5.67912685, 1.04143796]], [[5.36304773, 1.23045712], [5.36165146, 1.23132979], [2.38656322, 0.57246799], ..., ... ..., [0.62378067, 0.625526 ], [0.61784656, 0.61994095], [0.61645029, 0.61400683]], [[0.68085294, 1.12399204], [0.68050388, 1.12730816], [0.67840948, 1.13900187], ..., [0.64123397, 0.62954026], [0.62430427, 0.63529985], [0.61575216, 0.62203535]], [[0.67701322, 1.13236962], [0.67753682, 1.13690747], [0.67840948, 1.13149695], ..., [0.63652158, 0.61418136], [0.61645029, 0.63948864], [0.60981804, 0.64734262]]])
- quality(y, x)int640 90 92 93 92 92 ... 96 96 97 97 96
array([[ 0, 90, 92, ..., 0, 85, 90], [81, 82, 83, ..., 0, 84, 89], [81, 80, 3, ..., 0, 79, 88], ..., [90, 91, 91, ..., 95, 95, 95], [91, 92, 91, ..., 95, 95, 95], [92, 92, 91, ..., 97, 97, 96]])
- micro(y, x)float640.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
array([[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]])
- grainId(y, x)int641 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
array([[1, 1, 1, ..., 1, 1, 1], [1, 1, 1, ..., 1, 1, 1], [1, 1, 1, ..., 1, 1, 1], ..., [1, 1, 1, ..., 1, 1, 1], [1, 1, 1, ..., 1, 1, 1], [1, 1, 1, ..., 1, 1, 1]])
- date :
- Thursday, 19 Nov 2015, 11:24 am
- unit :
- millimeters
- step_size :
- 0.02
- path_dat :
- orientation_test.dat
It is recommended to filter the data :
data.aita.filter(75)
Extract profile¶
The function xa.interactive_misorientation_profile
is displaying a figure on which you can click to choose the begining and the end of the profil.
Once you click on Extract profile
, it returns you a xarray.Dataset
with the results.
help(data.aita.interactive_misorientation_profile)
Help on method interactive_misorientation_profile in module xarrayaita.aita:
interactive_misorientation_profile(res=0, degre=True) method of xarrayaita.aita.aita instance
Interactive misorientation profile for jupyter notebook
:param res: step size of the profil
:type res: float
:param degre: return mis2o and mis2p in degre overwise in radian (default: true)
:type degre: bool
pr=data.aita.interactive_misorientation_profile(res=0.1)
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
The profile¶
The xarray.Dataset
structure¶
The profile are store in a xarray.Dataset
.
pr.ds
<xarray.Dataset> Dimensions: (d: 151) Coordinates: * d (d) float64 0.0 0.02222 0.04445 0.06667 ... 3.267 3.289 3.311 3.334 Data variables: mis2i (d) float64 0.0 0.2105 0.5186 0.2499 ... 48.3 48.14 48.02 47.96 mis2p (d) float64 nan 0.2105 0.333 0.4801 ... 0.2202 0.8002 0.2017 0.8033 Attributes: start: [ 7.41712772 19.70789339] end: [10.75046106 19.66460335] step_size: 0.1 unit: millimeters
- d: 151
- d(d)float640.0 0.02222 0.04445 ... 3.311 3.334
array([0. , 0.022224, 0.044448, 0.066672, 0.088896, 0.11112 , 0.133345, 0.155569, 0.177793, 0.200017, 0.222241, 0.244465, 0.266689, 0.288913, 0.311137, 0.333361, 0.355586, 0.37781 , 0.400034, 0.422258, 0.444482, 0.466706, 0.48893 , 0.511154, 0.533378, 0.555602, 0.577827, 0.600051, 0.622275, 0.644499, 0.666723, 0.688947, 0.711171, 0.733395, 0.755619, 0.777843, 0.800067, 0.822292, 0.844516, 0.86674 , 0.888964, 0.911188, 0.933412, 0.955636, 0.97786 , 1.000084, 1.022308, 1.044533, 1.066757, 1.088981, 1.111205, 1.133429, 1.155653, 1.177877, 1.200101, 1.222325, 1.244549, 1.266773, 1.288998, 1.311222, 1.333446, 1.35567 , 1.377894, 1.400118, 1.422342, 1.444566, 1.46679 , 1.489014, 1.511239, 1.533463, 1.555687, 1.577911, 1.600135, 1.622359, 1.644583, 1.666807, 1.689031, 1.711255, 1.73348 , 1.755704, 1.777928, 1.800152, 1.822376, 1.8446 , 1.866824, 1.889048, 1.911272, 1.933496, 1.95572 , 1.977945, 2.000169, 2.022393, 2.044617, 2.066841, 2.089065, 2.111289, 2.133513, 2.155737, 2.177961, 2.200186, 2.22241 , 2.244634, 2.266858, 2.289082, 2.311306, 2.33353 , 2.355754, 2.377978, 2.400202, 2.422426, 2.444651, 2.466875, 2.489099, 2.511323, 2.533547, 2.555771, 2.577995, 2.600219, 2.622443, 2.644667, 2.666892, 2.689116, 2.71134 , 2.733564, 2.755788, 2.778012, 2.800236, 2.82246 , 2.844684, 2.866908, 2.889133, 2.911357, 2.933581, 2.955805, 2.978029, 3.000253, 3.022477, 3.044701, 3.066925, 3.089149, 3.111373, 3.133598, 3.155822, 3.178046, 3.20027 , 3.222494, 3.244718, 3.266942, 3.289166, 3.31139 , 3.333614])
- mis2i(d)float640.0 0.2105 0.5186 ... 48.02 47.96
array([ 0. , 0.21047147, 0.51860866, 0.24994511, 0.47422769, 0.8109127 , 0.42280189, 0.48774911, 0.30937424, 0.31642254, 0.44024002, 0.44636357, 0.70942809, 0.31306088, 0.34712218, 0.30746364, 0.54660021, 0.53894547, 0.52274158, 0.49654213, 0.33088842, 0.3633697 , 0.70233708, 0.50191394, 0.72514897, 2.25373653, 3.7672019 , 4.2050089 , 2.68025702, 1.04481052, 1.32970084, 1.31314701, 2.67586026, 2.8050165 , 1.86934312, 1.23369843, 0.9780755 , 0.72949924, 0.86967751, 0.67375012, 0.45369622, 0.4297881 , 2.42054688, 3.02062311, 1.31377815, 0.60502183, 0.88881402, 1.95977218, 3.83091752, 4.33025131, 4.07038438, nan, nan, nan, nan, nan, nan, 46.92534081, 46.74928818, 46.67620632, 46.80185929, 46.74479758, 46.75177154, 46.75983372, 46.76412983, 46.92696279, 47.11108467, 46.99623015, 47.20019019, 47.25901904, 46.88291772, 46.78532266, 46.93257856, 46.9512104 , 46.97662812, 47.23797603, 47.44842195, 47.3446779 , 47.11723227, 47.01551077, 46.91652563, 46.96426425, 46.90214606, 46.99858043, 47.04303285, 47.01802267, 47.0249954 , 47.01563146, 46.94206029, 47.12599105, 47.04312371, 47.03879476, 47.03466676, 46.98754403, 47.08473573, 47.13141998, 47.12414324, 47.29877417, 47.37634601, 47.16340542, 47.10541078, 47.28317756, 47.58693848, 47.35124135, 47.09166521, 47.27425979, 47.33561319, 47.21707041, 47.10690391, 47.14961269, 47.11822182, 47.09056771, 47.08591848, 47.14479101, 47.08424842, 47.12373929, 48.70702352, 48.65940367, 48.84960104, 48.84176818, 48.80942924, 48.79278756, 48.65819517, 49.10766464, 49.39654498, 49.18488782, 48.7263905 , 48.72947912, 49.19296141, 48.84876125, 48.53634214, 48.37980176, 48.37475848, 48.20845004, 48.16018141, 48.32560545, 48.30926817, 48.33602993, 48.3958823 , 48.49279681, 48.68817575, 48.25493324, 48.24637203, 48.13752367, 48.13160609, 48.25002679, 48.25002679, 48.29962821, 48.13752367, 48.0168527 , 47.95639957])
- mis2p(d)float64nan 0.2105 0.333 ... 0.2017 0.8033
array([ nan, 0.21047147, 0.33299297, 0.48008807, 0.35747849, 0.34742751, 0.61993594, 0.34787982, 0.21313426, 0.19352756, 0.2316424 , 0.0219974 , 0.35298255, 0.52000005, 0.08146485, 0.12550525, 0.37285314, 0.00998986, 0.03138219, 0.08808284, 0.30683732, 0.06603199, 0.64105939, 0.22478223, 0.40461453, 1.56501362, 1.51352479, 0.44091063, 1.52940983, 1.66384701, 0.31123093, 0.47160233, 1.45762998, 0.28707789, 0.94780631, 0.63752434, 0.26147999, 0.28060925, 0.1602665 , 0.23074072, 0.26146743, 0.06276438, 2.06884933, 0.66423308, 1.71322219, 0.75568142, 0.29483151, 1.19451153, 1.92505838, 0.50142643, 0.28003073, nan, nan, nan, nan, nan, nan, nan, 0.52661334, 0.36524043, 0.25271162, 0.07307852, 0.11137806, 0.10151223, 0.24141879, 0.22541517, 1.43043062, 0.56248984, 0.44891203, 1.32429051, 1.20238434, 0.74020941, 0.33977558, 0.16999964, 0.33569997, 0.38528151, 1.28110445, 0.5311928 , 0.51559563, 0.53119095, 0.95004091, 0.20173333, 0.24630808, 0.09705169, 0.31997978, 0.48651517, 0.05999938, 0.07220178, 0.18765229, 0.45959268, 0.08525721, 0.18195726, 0.25141184, 0.25062585, 0.11924959, 0.17206302, 0.59323342, 1.15054569, 1.07239154, 1.37026215, 0.33047644, 0.22592286, 1.70150196, 0.2947569 , 1.33242782, 0.20712574, 0.79125831, 0.13158338, 0.69023119, 0.09617845, 0.25000027, 0.02844088, 0.4829311 , 0.8411697 , 0.63024998, 0.74191628, 3.87764687, 0.32907082, 0.92999996, 0.21324513, 0.20021422, 0.17100085, 0.54070723, 1.32297467, 0.49054707, 0.64430354, 0.72147171, 1.62666859, 1.32958404, 2.36813846, 1.43026742, 0.28228421, 0.0723562 , 0.47714417, 0.43086756, 0.2629323 , 0.06593249, 0.35189834, 1.36503975, 1.25118156, 0.47916611, 2.67270948, 0.29359074, 0.56007426, 0.12307264, 0.46144753, 0. , 0.22019043, 0.80020848, 0.20169101, 0.8032787 ])
- start :
- [ 7.41712772 19.70789339]
- end :
- [10.75046106 19.66460335]
- step_size :
- 0.1
- unit :
- millimeters
The dimensions
d
is the position along the profilemis2i
variable is the misorientation angle with the initial pointmis2p
variable is the misorientation with the previous point
In the attributes you can find the starting point, the ending point, the step size and the unit.
Plot the results¶
plt.figure()
pr.ds.mis2i.plot(label='mis2i')
pr.ds.mis2p.plot(label='mis2p')
plt.ylabel('Angle (°)')
plt.legend()
plt.grid()
Replot the position of the profile¶
If you want to replot the position of the profile all the information needed are available in the dataSet
.
data['OrientationSemi']=data.orientation.uvecs.calc_colormap()
plt.figure(figsize=(5,10))
data.OrientationSemi.plot.imshow()
plt.plot(pr.ds.start[0],pr.ds.start[1],'sk')
plt.plot(pr.ds.end[0],pr.ds.end[1],'ok')
plt.plot([pr.ds.start[0],pr.ds.end[0]],[pr.ds.start[1],pr.ds.end[1]],'-k')
plt.axis('equal')
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
(-0.01, 19.990000000000002, -0.010000000000001563, 49.99000000000001)