{ "cells": [ { "cell_type": "markdown", "metadata": { "nbsphinx": "hidden", "pycharm": { "name": "#%% md\n" } }, "source": [ "This notebook is part of the `kikuchipy` documentation https://kikuchipy.org.\n", "Links to the documentation won't work from the notebook." ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "# Reference frames\n", "\n", "In this tutorial, we cover the reference frames most important to EBSD, chosen conventions in kikuchipy, and how they relate to conventions in the other softwares by Bruker Nano, EDAX TSL, EMsoft, and Oxford Instruments.\n", "We also test conversions between the conventions by indexing simulated patterns using Hough indexing (HI) from PyEBSDIndex.\n", "\n", "## Detector-sample geometry\n", "\n", "The figure below shows the [sample reference frame](#detector-sample-geometry) and the [detector reference frame](#detector-coordinates) used in kikuchipy, all of which are right handed.\n", "In short, the sample reference frame ($X_s$, $Y_s$, $Z_s$) is the one used by EDAX TSL, (RD, TD, ND), while the pattern center ($PC_x$, $PC_y$, $PC_z$) is the one used by Bruker Nano, ($PC_x$, $PC_y$, $DD$)." ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "In **a**, the electron beam interacts with the sample in the source point.\n", "The shortest distance from this point to the detector is called the projection or pattern center (PC).\n", "A part of the Kikuchi sphere, resulting from the beam-sample interaction, is projected onto the flat detector in the gnomonic projection, constituting the EBSD pattern (EBSP).\n", "A gnomonic coordinate system $CS_g$, ($X_g$, $Y_g$, $Z_g$) with (0, 0, 0) in the PC is defined for the detector plane.\n", "We also define a detector coordinate system $CS_d$, ($X_d$, $Y_d$, $Z_d$) for the detector plane with (0, 0, 0) in the upper left corner.\n", "The projection center coordinates ($PC_x$, $PC_y$, $PC_z$) are defined in this detector coordinate system:\n", "\n", "- $PC_x$ is measured from the left border of the detector in fractions of detector width.\n", "- $PC_y$ is measured from the top border of the detector in fractions of detector height.\n", "- $PC_z$ is the distance from the detector scintillator to the sample divided by pattern height.\n", "\n", "Orientations are defined in the Bunge convention with respect to the sample coordinate system $CS_s$, ($X_s$, $Y_s$, $Z_s$).\n", "The detector and sample viewed along the microscope $X$ axis are shown in **b**, with the three coordinate systems and the PC also shown.\n", "The scanned map is shown in **c**.\n", "Note the orientation of $CS_s$ and the sample \"Top\": the map is scanned from the bottom of the sample and upwards.\n", "Three tilt angles are defined: the sample tilt $\\sigma$ shown in **a** and **b**; the detector tilt $\\theta$ shown in **b**; the azimuthal angle $\\omega$ which is defined as the sample tilt angle around the $X_s$ axis, shown in a top view of the detector and sample along the microscope $Z$ axis in **d**." ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The above figure shows the EBSP in the [sample reference frame figure](#detector-sample-geometry) **a** as viewed from behind the screen towards the sample in (left) the gnomonic coordinate system with its origin (0, 0) in the PC, and in (right) the detector coodinate system with (0, 0) in the upper left pixel.\n", "The circles indicate the angular distance from the PC in steps of $10^{\\circ}$." ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## The EBSD detector\n", "\n", "All relevant parameters for the detector-sample geometry are stored in an [EBSDDetector](../reference/generated/kikuchipy.detectors.EBSDDetector.rst) instance.\n", "Let's first import necessary libraries and a small Nickel EBSD test data set" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "# Exchange inline for notebook or qt5 (from pyqt) for interactive plotting\n", "%matplotlib inline\n", "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "import kikuchipy as kp\n", "from orix.quaternion import Orientation, Rotation\n", "from orix.vector import Vector3d\n", "\n", "\n", "plt.rcParams[\"figure.figsize\"] = (15, 5)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Use kp.load(\"data.h5\") to load your own data\n", "s = kp.data.nickel_ebsd_small()\n", "s" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Then we can define a detector with the same parameters as the one used to acquire the small nickel data set" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "det = kp.detectors.EBSDDetector(\n", " shape=s.axes_manager.signal_shape[::-1],\n", " pc=[0.4221, 0.2179, 0.4954],\n", " px_size=70, # Microns\n", " binning=8,\n", " tilt=0,\n", " sample_tilt=70,\n", ")\n", "det" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "det.pc_tsl()" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Above, the PC was passed in the Bruker convention.\n", "Passing the PC in the EDAX TSL, Oxford, or EMsoft convention is also supported.\n", "The definitions of the conventions are given in the [EBSDDetector](../reference/generated/kikuchipy.detectors.EBSDDetector.rst) API reference, together with the conversion from PC coordinates in the EDAX TSL, Oxford, or EMsoft conventions to PC coordinates in the Bruker convention.\n", "\n", "The PC coordinates in the EDAX TSL, Oxford, or EMsoft conventions can be retreived via [EBSDDetector.pc_tsl()](../reference/generated/kikuchipy.detectors.EBSDDetector.pc_tsl.rst), [EBSDDetector.pc_oxford()](../reference/generated/kikuchipy.detectors.EBSDDetector.pc_oxford.rst), and [EBSDDetector.pc_emsoft()](../reference/generated/kikuchipy.detectors.EBSDDetector.pc_emsoft.rst), respectively.\n", "The latter requires the unbinned detector pixel size in microns and the detector binning to be given upon initialization." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "det.pc_emsoft()" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "The detector can be plotted to show whether the average PC is placed as expected using [EBSDDetector.plot()](../reference/generated/kikuchipy.detectors.EBSDDetector.plot.rst) (see its docstring for a complete explanation of its parameters)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "det.plot(pattern=s.inav[0, 0].data)" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "This will produce a figure similar to the right panel in the [detector coordinates figure](#detector-coordinates) above, without the arrows and colored labels.\n", "\n", "Multiple PCs with a 1D or 2D navigation shape can be passed to the `pc` parameter upon initialization, or they can be set directly.\n", "This gives the detector a navigation shape (not to be confused with the detector shape) and a navigation dimension (maximum of two)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "det.pc = np.ones([3, 4, 3]) * det.pc\n", "det.navigation_shape" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "det.navigation_dimension" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "det.navigation_size" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "det.pc = det.pc[0, 0]\n", "det.navigation_shape" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "