{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Compare E4CV 4-circle orientation with SPEC fourc\n", "\n", "Following the E4CV example (consult the example for geometry\n", "details), compare the orientation matix and\n", "positioning operations with **hklpy** (and **libhkl**) and **SPEC**.\n", "\n", "Information from a **SPEC** data file will be used for the comparison.\n", "\n", "----\n", "\n", "Note: This example is available as a\n", "[Jupyter notebook](https://jupyter.org/) from the **hklpy** source\n", "code website: https://github.com/bluesky/hklpy/tree/main/docs/source/examples/notebooks" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In SPEC *fourc* geometry (https://certif.com/spec_help/fourc.html):\n", "\n", "name | mnemonic | description\n", "----- | ----- | -----\n", "2theta | tth | Detector arm rotation\n", "Omega | om | Rotates sample circles\n", "Chi | chi | Sample tilt\n", "Phi | phi | Sample rotation\n", "\n", "The provided SPEC data file names these motors: `tth`, `th`, `chi`, `phi`\n", "so this example will use the same names to help the comparison." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# mapping of axis names between hklpy and SPEC\n", "AXIS_NAME_MAP = dict(\n", " # E4CV fourc\n", " tth='tth', # Detector arm rotation\n", " omega='th', # Rotates chi around horizontal axis\n", " chi='chi', # TODO: Rotates phi around beam axis # TODO: is this correct?\n", " phi='phi', # Sample rotation around horizontal axis (when phi is co-linear with omega)\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read the SPEC scan from the data file\n", "\n", "The SPEC file provides all the information needed here. The\n", "[*spec2nexus*](https://github.com/prjemian/spec2nexus) \n", "(python) package can read the file and parse the content into useful \n", "structures, including deducing the diffractometer geometry in many cases." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============ =========================================================================================================================================================\n", "term value \n", "============ =========================================================================================================================================================\n", "SPEC file LNO_LAO \n", "scan # 14 \n", "SPEC scanCmd hklscan 1.00133 1.00133 1.00133 1.00133 2.85 3.05 200 -400000 \n", "geometry fourc \n", "mode Omega equals zero \n", "lattice LatticeParameters3D(a=3.781726143, b=3.791444574, c=3.79890313, alpha=90.2546203, beta=90.01815424, gamma=89.89967858) \n", "wavelength 1.239424258 \n", "reflection 1 Reflections3D(h=0.0, k=0.0, l=2.0, wavelength=1.239424258, angles=OrderedDict([('tth', 38.09875), ('th', 19.1335), ('chi', 90.0135), ('phi', 0.0)])) \n", "reflection 2 Reflections3D(h=1.0, k=1.0, l=3.0, wavelength=1.239424258, angles=OrderedDict([('tth', 65.644), ('th', 32.82125), ('chi', 115.23625), ('phi', 48.1315)]))\n", "[UB] [[-1.65871244e+00 9.82002413e-02 -3.89705578e-04] \n", " [-9.55499031e-02 -1.65427863e+00 2.42844486e-03] \n", " [ 2.62981891e-04 9.81574682e-03 1.65396181e+00]] \n", "============ =========================================================================================================================================================\n", "\n" ] } ], "source": [ "import pyRestTable\n", "from spec2nexus.spec import SpecDataFile\n", "\n", "specfile = SpecDataFile(\"resources/LNO_LAO_s14.dat\")\n", "specscan = specfile.getScan(14)\n", "\n", "spec_d = specscan.diffractometer\n", "spec_d.UB = spec_d.geometry_parameters[\"ub_matrix\"][2]\n", "\n", "terms = {\n", " \"SPEC file\": specfile.specFile,\n", " \"scan #\": specscan.scanNum,\n", " \"SPEC scanCmd\": specscan.scanCmd,\n", " \"geometry\": spec_d.geometry_name,\n", " \"mode\": spec_d.mode,\n", " \"lattice\": spec_d.lattice,\n", " \"wavelength\": spec_d.wavelength,\n", " \"reflection 1\": spec_d.reflections[0],\n", " \"reflection 2\": spec_d.reflections[1],\n", " \"[UB]\": spec_d.UB,\n", "}\n", "tbl = pyRestTable.Table()\n", "tbl.labels = \"term value\".split()\n", "for k, v in terms.items():\n", " tbl.addRow((k, v))\n", "print(tbl)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot the (_hkl_) trajectories in the scan" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgA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+q9lbV08Dn8E9d01JV25t/7weupjNu9zV7v8f2gN8/uB4OnbOAm6rqPnBezkKvOejvzxlI8m7gzcA7qikMarYG/Evz+Wbge8BJg+vl3DfJ69l5OQNJFgNvA64aa1vo89KQ3CnUW5/kxGbV6RzgmgH3aWg0+5c+D3ynqj7V1b6q67S3Are1v1bjJTmyKX4kyZHAGXTG7Rrg3c1p7wb+fDA9HErjVkWclzPWaw5eA5yT5PAkJwLrgW8NoH9DI8mZwAeAt1TVrq72lU2RKUmeR2cs7x5ML4fDJK9n5+XMvB64s6q2jTUs9Hm5eNAdGLSmwvhC4GvAIuDSqrp9wN0aJqcB7wRuHbtkDPBh4Nwkp9D5E9c9wK8OonND5jjg6s77DhYDl1fVV5PcCHwpyfuAfwJ+aYB9HBpJltK5ak333PuE83JySa4ATgdWJNkGfAS4iAnmYFXdnuRLwB10tg5c4BUEntVjLD8EHA5c17zWb6iq84HXAB9LsgfYC5xfVdMtVJv3eozl6RO9np2Xk5toLKvq8+xbvwELfF4u+EvASZIkSW1ut5AkSZJaDMmSJElSiyFZkiRJajEkS5IkSS2GZEmSJKnFkCxJkiS1GJIlSZKklv8f10PCgWIOMnEAAAAASUVORK5CYII=", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "%matplotlib inline\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# plot the h, k, & l vs. point number\n", "fig, axes = plt.subplots(3, 1, figsize=(12, 6))\n", "fig.subplots_adjust(hspace=0.4, wspace=0.2)\n", "\n", "plt.suptitle('Desired HKL trajectory')\n", "axes[0].plot(specscan.data[\"H\"])\n", "axes[0].set_title(\"h\")\n", "axes[1].plot(specscan.data[\"K\"])\n", "axes[1].set_title(\"k\")\n", "axes[2].plot(specscan.data[\"L\"])\n", "axes[2].set_title(\"l\")\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup the *E4CV* diffractometer in *hklpy*" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "from hkl import SimulatedE4CV\n", "from hkl import Lattice" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use the `hkl.geometries.SimulatedE4CV()` class. All is prebuilt." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "class Diffractometer(SimulatedE4CV):\n", " pass" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "fourc = Diffractometer(\"\", name=\"fourc\")\n", "fourc.calc.physical_axis_names = {\n", " # E4CV: local\n", " 'omega': 'th',\n", " 'chi': 'chi',\n", " 'phi': 'phi',\n", " 'tth': 'tth',\n", " }\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "HklSample(name='LNO_LAO', lattice=LatticeTuple(a=3.781726143, b=3.791444574, c=3.79890313, alpha=90.2546203, beta=90.01815424, gamma=89.89967858), ux=Parameter(name='None (internally: ux)', limits=(min=-180.0, max=180.0), value=0.0, fit=True, inverted=False, units='Degree'), uy=Parameter(name='None (internally: uy)', limits=(min=-180.0, max=180.0), value=0.0, fit=True, inverted=False, units='Degree'), uz=Parameter(name='None (internally: uz)', limits=(min=-180.0, max=180.0), value=0.0, fit=True, inverted=False, units='Degree'), U=array([[1., 0., 0.],\n", " [0., 1., 0.],\n", " [0., 0., 1.]]), UB=array([[ 1.66146225e+00, -2.89938471e-03, 5.11196668e-04],\n", " [ 0.00000000e+00, 1.65721725e+00, 7.34922202e-03],\n", " [ 0.00000000e+00, 0.00000000e+00, 1.65394723e+00]]), reflections=[])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# add the sample to the calculation engine\n", "fourc.calc.new_sample(\n", " specfile.specFile,\n", " lattice=Lattice(\n", " a=spec_d.lattice.a, \n", " b=spec_d.lattice.b, \n", " c=spec_d.lattice.c,\n", " alpha=spec_d.lattice.alpha, \n", " beta=spec_d.lattice.beta, \n", " gamma=spec_d.lattice.gamma)\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Test *hklpy* with the **UB** orientation matrix from **SPEC**\n", "\n", "Using the UB matrix as provided in the SPEC data file, \n", "compute the forward reflection positions and compare with\n", "those calculated by **libhkl**." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[-1.65871244e+00 9.82002413e-02 -3.89705578e-04]\n", " [-9.55499031e-02 -1.65427863e+00 2.42844486e-03]\n", " [ 2.62981891e-04 9.81574682e-03 1.65396181e+00]]\n", "[[-9.55499053e-02 -1.65427875e+00 2.42825603e-03]\n", " [ 2.63161907e-04 9.81566638e-03 1.65396189e+00]\n", " [-1.65871254e+00 9.82003048e-02 -3.89644168e-04]]\n", "(002) : PosCalcE4CV(th=23.915206114843656, chi=89.91480547663566, phi=99.11611601203889, tth=47.83041222968731)\n", "(113) : PosCalcE4CV(th=42.331294286006255, chi=115.20291094237977, phi=48.13306144010148, tth=84.66258857201251)\n" ] } ], "source": [ "# get the UB matrix from the SPEC data\n", "# SPEC's UB first row moved (via numpy slicing) to last row for hklpy\n", "fourc.UB.put(spec_d.UB[[1,2,0], :])\n", "print(spec_d.UB)\n", "print(fourc.UB.get())\n", "\n", "# calculate angles with hklpy using the SPEC UB matrix\n", "fourc.engine.mode = \"bissector\"\n", "fourc.calc[\"phi\"].limits = (-50, 100)\n", "fourc.calc[\"tth\"].limits = (-2, 180)\n", "print(\"(002) :\", fourc.forward((0, 0, 2)))\n", "print(\"(113) :\", fourc.forward((1, 1, 3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define a custom reporting function to format the output table." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "def add_ref_to_table(tbl, r):\n", " sol = fourc.forward((r.h, r.k, r.l))\n", " nm = f\"{r.h:.0f} {r.k:.0f} {r.l:.0f}\"\n", " # print(nm, sol)\n", " for sm in AXIS_NAME_MAP.values():\n", " row = [f\"({nm})\", sm]\n", " v_hklpy = getattr(sol, sm)\n", " v_spec = r.angles[sm]\n", " row.append(f\"{v_hklpy:.5f}\")\n", " row.append(f\"{v_spec:.5f}\")\n", " row.append(f\"{v_hklpy-v_spec:.5f}\")\n", " tbl.addRow(row)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For each of the orientation reflections used in the SPEC file,\n", "report the computed motor positions for each reflection for \n", "E4CV and SPEC. We'll only pick positions where $2\\theta\\ge 0$." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "======= ===== ========= ========= ==========\n", "(hkl) motor E4CV SPEC difference\n", "======= ===== ========= ========= ==========\n", "(0 0 2) tth 47.83041 38.09875 9.73166 \n", "(0 0 2) th 23.91521 19.13350 4.78171 \n", "(0 0 2) chi 89.91481 90.01350 -0.09869 \n", "(0 0 2) phi 99.11612 0.00000 99.11612 \n", "(1 1 3) tth 84.66259 65.64400 19.01859 \n", "(1 1 3) th 42.33129 32.82125 9.51004 \n", "(1 1 3) chi 115.20291 115.23625 -0.03334 \n", "(1 1 3) phi 48.13306 48.13150 0.00156 \n", "======= ===== ========= ========= ==========\n", "\n" ] } ], "source": [ "# Compare these angles with those from SPEC\n", "\n", "tbl = pyRestTable.Table()\n", "tbl.labels = \"(hkl) motor E4CV SPEC difference\".split()\n", "r1, r2 = spec_d.reflections\n", "\n", "fourc.engine.mode = \"bissector\"\n", "fourc.calc[\"tth\"].limits = (-2, 180)\n", "add_ref_to_table(tbl, r1)\n", "\n", "# print(r2)\n", "add_ref_to_table(tbl, r2)\n", "\n", "print(tbl)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that the angles do not match between *E4CV* and *SPEC*,\n", "even if we re-arrange the rows as we did above. Can't just\n", "use the UB matrix from the one program in the other\n", "software.\n", "\n", "Need to add the orientation reflections (with wavelength),\n", "then compute the UB matrix. Follow in the section below." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup the **UB** orientation matrix using *hklpy*\n", "\n", "Compute the UB matrix using *hklpy* (& *libhkl*)." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "========= ===================================================\n", "term value \n", "========= ===================================================\n", "SPEC [UB] [[-1.65871244e+00 9.82002413e-02 -3.89705578e-04] \n", " [-9.55499031e-02 -1.65427863e+00 2.42844486e-03] \n", " [ 2.62981891e-04 9.81574682e-03 1.65396181e+00]]\n", "E4CV [UB] [[-9.55498634e-02 -1.65427875e+00 2.42844498e-03] \n", " [ 2.63111155e-04 9.81585901e-03 1.65396189e+00] \n", " [-1.65871254e+00 9.82002627e-02 -3.89705597e-04]]\n", "========= ===================================================\n", "\n" ] } ], "source": [ "fourc.calc.wavelength = 1.239424258 # Angstrom\n", "\n", "refs = [\n", " fourc.calc.sample.add_reflection(\n", " r.h, r.k, r.l, \n", " position=fourc.calc.Position(\n", " tth=r.angles[\"tth\"],\n", " th=r.angles[\"th\"],\n", " chi=r.angles[\"chi\"],\n", " phi=r.angles[\"phi\"],\n", " )\n", " )\n", " for r in spec_d.reflections\n", "]\n", "\n", "fourc.calc.sample.compute_UB(*refs)\n", "\n", "tbl = pyRestTable.Table()\n", "tbl.labels = \"term value\".split()\n", "tbl.addRow((\"SPEC [UB]\", spec_d.UB))\n", "tbl.addRow((\"E4CV [UB]\", fourc.UB.get()))\n", "print(tbl)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Report the results, as before, and compare with table above." ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "==================== =========================================================================\n", "term value \n", "==================== =========================================================================\n", "energy, keV 10.003370322932636 \n", "wavelength, angstrom 1.239424258 \n", "position DiffractometerPseudoPos(h=-0.0, k=0.0, l=0.0) \n", "sample name LNO_LAO \n", "[U] [[-5.75094968e-02 -9.98327391e-01 5.92267768e-03] \n", " [ 1.58361191e-04 5.92337392e-03 9.99982444e-01] \n", " [-9.98344947e-01 5.75094251e-02 -1.82553939e-04]] \n", "[UB] [[-9.55498634e-02 -1.65427875e+00 2.42844498e-03] \n", " [ 2.63111155e-04 9.81585901e-03 1.65396189e+00] \n", " [-1.65871254e+00 9.82002627e-02 -3.89705597e-04]] \n", "lattice [ 3.78172593 3.7914443 3.79890295 90.25465556 90.01815877 89.89967654]\n", "==================== =========================================================================\n", "\n", "sample\tHklSample(name='LNO_LAO', lattice=LatticeTuple(a=3.781725931569308, b=3.79144430103082, c=3.798902949497184, alpha=90.25465555509926, beta=90.01815876717824, gamma=89.89967653973522), ux=Parameter(name='None (internally: ux)', limits=(min=-180.0, max=180.0), value=-90.01045975373877, fit=True, inverted=False, units='Degree'), uy=Parameter(name='None (internally: uy)', limits=(min=-180.0, max=180.0), value=0.3393464183946019, fit=True, inverted=False, units='Degree'), uz=Parameter(name='None (internally: uz)', limits=(min=-180.0, max=180.0), value=93.2969283549115, fit=True, inverted=False, units='Degree'), U=array([[-5.75094968e-02, -9.98327391e-01, 5.92267768e-03],\n", " [ 1.58361191e-04, 5.92337392e-03, 9.99982444e-01],\n", " [-9.98344947e-01, 5.75094251e-02, -1.82553939e-04]]), UB=array([[-9.55498634e-02, -1.65427875e+00, 2.42844498e-03],\n", " [ 2.63111155e-04, 9.81585901e-03, 1.65396189e+00],\n", " [-1.65871254e+00, 9.82002627e-02, -3.89705597e-04]]), reflections=[(h=0.0, k=0.0, l=2.0), (h=1.0, k=1.0, l=3.0)], reflection_measured_angles=array([[0. , 0.44139322],\n", " [0.44139322, 0. ]]), reflection_theoretical_angles=array([[0. , 0.44081129],\n", " [0.44081129, 0. ]])))\n" ] } ], "source": [ "tbl = pyRestTable.Table()\n", "tbl.labels = \"term value\".split()\n", "tbl.addRow((\"energy, keV\", fourc.calc.energy))\n", "tbl.addRow((\"wavelength, angstrom\", fourc.calc.wavelength))\n", "tbl.addRow((\"position\", fourc.position))\n", "tbl.addRow((\"sample name\", fourc.sample_name.get()))\n", "tbl.addRow((\"[U]\", fourc.U.get()))\n", "tbl.addRow((\"[UB]\", fourc.UB.get()))\n", "tbl.addRow((\"lattice\", fourc.lattice.get()))\n", "print(tbl)\n", "\n", "print(f\"sample\\t{fourc.calc.sample}\")" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "======= ===== ========= ========= ==========\n", "(hkl) motor E4CV SPEC difference\n", "======= ===== ========= ========= ==========\n", "(0 0 2) tth 38.08407 38.09875 -0.01468 \n", "(0 0 2) th 19.12616 19.13350 -0.00734 \n", "(0 0 2) chi 90.01350 90.01350 0.00000 \n", "(0 0 2) phi 0.00000 0.00000 0.00000 \n", "(1 1 3) tth 65.63700 65.64400 -0.00700 \n", "(1 1 3) th 32.81850 32.82125 -0.00275 \n", "(1 1 3) chi 115.20291 115.23625 -0.03334 \n", "(1 1 3) phi 48.13305 48.13150 0.00155 \n", "======= ===== ========= ========= ==========\n", "\n" ] } ], "source": [ "# Compare these angles with those from SPEC\n", "# fourc.calc[\"phi\"].limits = (-1, 100)\n", "tbl = pyRestTable.Table()\n", "tbl.labels = \"(hkl) motor E4CV SPEC difference\".split()\n", "r1, r2 = spec_d.reflections\n", "fourc.calc[\"tth\"].limits = (-2, 180)\n", "\n", "fourc.engine.mode = \"constant_phi\"\n", "fourc.phi.move(0)\n", "add_ref_to_table(tbl, r1)\n", "\n", "fourc.engine.mode = \"bissector\"\n", "add_ref_to_table(tbl, r2)\n", "\n", "print(tbl)" ] } ], "metadata": { "interpreter": { "hash": "cd09a60d4ca96784847e6d28c64916bc86a437fe6be574606d07ffca69ac8887" }, "kernelspec": { "display_name": "Python 3.9.12 ('training_2022')", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 4 }