1. Functions overview

1.1. uvecs xr.DataArray accessor

This is an object to take care of unit vector

class xarrayuvecs.uvecs.uvecs(xarray_obj)

This is a classe to work on unit vector in xarray environnement that respect the -1 symmetry (i.e. u is equivalent to -u)

Note

xarray does not support heritage from xr.DataArray may be the day it support it, we could move to it

OT2nd()

Compute the second order orientation tensor

Return eigvalue

eigen value w[i]

Rtype eigvalue

np.array

Returns

eigvector eigen vector v[:,i]

Return type

eigvector np.array

Note

eigen value w[i] is associate to eigen vector v[:,i]

__init__(xarray_obj)

Constructor for uvec. The univ vector u should be pass as azimuth and colatitude in radian Colatitude : angle between u-vector and z vector [0 pi/2] Azimuth : angle between the projection of u-vector in xOy plan and x-vector [0 2pi]

Parameters

xarray_obj (xr.DataArray) – dimention should be (n,m,2), xarray_obj[n,m,0]=azimuth , xarray_obj[n,m,1]=colatitude

__weakref__

list of weak references to the object (if defined)

azi_col()
Returns

the azimuth out[n,m,0] and colatitude out[n,m,0], dim (n,m,2)

Return type

np.array

bunge_euler()

This is from the Euler angle, Bunge convention

  1. rotate around z-axis of phi1

  2. rotate around x’-axis of phi

Returns

phi1 and phi, out[n,m,0]=phi1, out[n,m,1]=phi

Return type

np.array

calc_colormap(**kwargs)

Compute the colormap value

Parameters

nlut (int) – size of the lut (default:512)

Note

**kwargs for xarray_uvecs.lut2d.lut

calc_schmid(axis)

Compute the schimd sc=abs(cos(a)sin(a)) where a is the angle between c and axis

Parameters

axis (np.array) – axis from which you want to compute the schimd factor in cartesien coordinate (X,Y,Z)

inner_angle(other)

Compute the inner angle between to uvecs DataArray

Parameters
  • other – DataArray of same dimention than self and compatible with uvec

  • other – xr.DataArray

Returns

Return type

xr.DataArray

mis_angle(random=False)

Compute the misorientation with the neighbouring grain

Parameters

random (bool) – suffle the image and compute the angle

misorientation_profile(xx, yy, degre=True, method='nearest', **kwargs)

Extract value for xx,yy

Parameters
  • xx (np.array()) – x coordinate

  • yy (np.array()) – y coordinate

  • degre (bool) – Do you want the angle in degree (default:True)

Note

**kwargs for xr.sel

plotODF(nbr=10000, bw=0.2, projz=1, plotOT=True, angle=array([30.0, 60.0]), cline=10, **kwargs)

Plot the Orienation Density Function

Parameters
  • nbr (int) – number of point selected for the Kernel Density Estimation KDE (default : 10000)

  • bw (float) – bandwidth for the KDE (default : 0.2)

  • projz (int) – plan of projection (0 or 1) (default : 1)

  • plotOT (bool) – plot eigenvectore of second order orientation tensor

  • angle (np.array) – plot circle for given angle (default : np.array([30.,60.]))

  • cline (int) – number or line for the contourf

Note

**kwargs for plt.tricontourf

quiver(density=1, color_code=0, **kwargs)

Plot quiver map

Parameters
  • length (xr.DataArray) – give a length map for the quiver

  • density (float) – density of quiver plotted between 0 and 1

Note

**kwargs for xr.plot.quiver

xyz()

Return vectors in cartesian coordinate

Returns

out[n,m,0]=x, out[n,m,1]=u , out[n,m,2]=z

Return type

np.array

1.2. Colorwheel

xarrayuvecs.lut2d.cart2pol(x, y)

Convert cartesien coordinate x,y into polar coordinate rho, theta

Parameters
  • x (float) – x cartesian coordinate

  • y (float) – y cartesian coordinate

Returns

rho (radius), theta (angle)

Return type

float

Exemple
>>> rho,theta=cart2pol(x,y)
xarrayuvecs.lut2d.lut(nx=512, semi=False, circle=True)

Create a 2D colorwheel

Parameters
  • nx (int) – number of pixel for the colorwheel

  • circle (bool) – do you want create a black circle around

  • semi (bool) – do you want a semi LUT

Returns

lut

Return type

array of size [nx,nx,3]

Exemple
>>> lut2d=lut()
>>> plt.imshow(lut)
>>> plt.show()