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(xoz_plane=False)
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
rotate around z-axis of phi1
rotate around x’-axis of phi
- Returns:
phi1 and phi, out[n,m,0]=phi1, out[n,m,1]=phi
- Return type:
np.array
- calcODF(nbr=0, bw=0.2)
Compute ODF
- Parameters:
nbr (int) – number of point selected for the Kernel Density Estimation KDE (default : 10000)
bw (float) – bandwidth for the KDE (default : 0.2)
- 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, plot_cm=True, plotOT=True, angle=array([30., 60.]), cline=10, ax=None, xoz_plane=False, cmap=<matplotlib.colors.ListedColormap object>, **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
ax (matplotlib.axes._subplots.AxesSubplot) – matplotlib axes to plot inside. if none create a new figure
xoz_plane (bool) – plot the pole figure in xOz plane if True. In xOy plane overwise.
Note
**kwargs
for plt.tricontourf
- plotly_ODF(nbr=10000, bw=0.2, plot_cm=True, plotOT=True, cf=True, cline=10, xoz_plane=False, res=400, add_dot=None, cmap='viridis')
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)
plotOT (bool) – plot eigenvectore of second order orientation tensor
cf (bool) – use contour filled plot
cline (int) – number or line for the contour filled plot
xoz_plane (bool) – plot the pole figure in xOz plane if True. In xOy plane overwise.
res (int) – resolution of the image
add_dot (int) – Number of orientation to print with dot on the image
cmap (string) – build in plotly colormap https://plotly.com/python/builtin-colorscales/
Note
**kwargs
for plt.tricontourf
- plotly_colormap(add_hover=False, **kwargs)
Plot colormap in plotly
- 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
- vector2plane(xoz_plane=False)
Project a 3D vector uvecs to the plane of the pole figure :param xa_uvecs: uvecs vector object :type xa_uvecs: uvecs :param xoz_plane: project in xoz plane :type xoz_plane: bool
- 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()
- xarrayuvecs.lut2d.plotly_lut(**kwargs)
Plot LUT using plotly
1.3. Plot ODF functions
- xarrayuvecs.odfplot.ODF_background(color, fig=None, contourf=True, cline=10, xoz_plane=True, cmap='Greys', **kwargs)
Print background image on Pole Figure
- Parameters:
ori (np.array) – orientation in the plane dim=(n,2)
color (np.array) – value associated with each orientation dim=(n)
fig (plotly.graph_objs._figure.Figure) –
contourf (bool) – use filled contour drawing
cline (int) – number of line for filled contour plot
cmap (string) – build in plotly colormap https://plotly.com/python/builtin-colorscales/
- xarrayuvecs.odfplot.ODF_template(res=400, xlabel='x', ylabel='y')
Create an circle with
- Parameters:
res (int) – resolution of the image
xlabel (string) – name of the x axis
ylabel (string) – name of the y axis
- xarrayuvecs.odfplot.add_orientation(proj_ori, fig=None, name=None, text=None, size=10, color='Black', symbol='circle', hovert=None)
Add orientations on a pole figure
- Parameters:
proj_ori (np.array) – projected point in the plane of projection dim=(n,2)
fig (plotly.graph_objs._figure.Figure) –
name (string) – name of the point
text (string) – text to print next to the point
size (int) – marker size
color (int) – marker color