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

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)

The misorientation profile

The xarray.Dataset structure

The profile is stored in a xarray.Dataset.

pr.ds
<xarray.Dataset>
Dimensions:  (d: 137)
Coordinates:
  * d        (d) float64 0.0 0.01654 0.03309 0.04963 ... 2.2 2.217 2.233 2.25
Data variables:
    mis2i    (d) float64 0.0 0.0 0.5585 0.5585 ... 0.6746 0.6746 1.083 1.083
    mis2p    (d) float64 nan 0.0 0.5585 0.0 0.0 ... 0.0 0.5335 0.0 0.4928 0.0
Attributes:
    start:      [ 9.51651515 20.64949675]
    end:        [10.64205628 18.70144481]
    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')