Misorientation profile#

In this notebook, we 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:      (y: 2500, x: 1000, uvecs: 2)
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

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_nb:

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 misorientation profile#

The xarray.Dataset structure#

The profile is stored in a xarray.Dataset.

pr.ds
<xarray.Dataset>
Dimensions:  (d: 152)
Coordinates:
  * d        (d) float64 0.0 0.01906 0.03812 0.05719 ... 2.821 2.84 2.859 2.878
Data variables:
    mis2i    (d) float64 0.0 0.2776 0.8072 1.263 ... 48.36 48.28 48.26 48.53
    mis2p    (d) float64 nan 0.2776 1.085 0.4696 ... 0.6716 0.02088 0.7134
Attributes:
    start:      [ 7.54050593 19.38682535]
    end:        [10.35435875 19.99288596]
    step_size:  0.1
    unit:       millimeters
  • The dimensions d are the position along the profile

  • mis2i variable is the misorientation angle relative to the initial point

  • mis2p variable is the misorientation relative to 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)