{ "cells": [ { "cell_type": "markdown", "id": "7fefb950-9158-4c62-b593-cda353ff5db1", "metadata": {}, "source": [ "# Demo of `LaPDXYDroopCorrect`" ] }, { "cell_type": "code", "execution_count": null, "id": "1bef64d2-1541-4dec-ac10-ebcf4cffe4b2", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "id": "63c23fe0-5407-40b9-a998-6f1581d6eb6d", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import sys\n", "\n", "plt.rcParams[\"figure.figsize\"] = [10.5, 0.56 * 10.5]" ] }, { "cell_type": "code", "execution_count": null, "id": "9e25f18e-6ce0-48b2-82ac-27c69b006a29", "metadata": {}, "outputs": [], "source": [ "try:\n", " from bapsf_motion.transform import LaPDXYDroopCorrect\n", "except ModuleNotFoundError:\n", " from pathlib import Path\n", "\n", " HERE = Path().cwd()\n", " BAPSF_MOTION = (HERE / \"..\" / \"..\" / \"..\" ).resolve()\n", " sys.path.append(str(BAPSF_MOTION))\n", " \n", " from bapsf_motion.transform import LaPDXYDroopCorrect" ] }, { "cell_type": "markdown", "id": "9acd2e98-622c-4d7b-9220-531e711f459a", "metadata": {}, "source": [ "Initialize our droop correct class `LaPDXYDroopCorrect`." ] }, { "cell_type": "code", "execution_count": null, "id": "120c8907-672f-4915-aa03-506dd91b1d18", "metadata": {}, "outputs": [], "source": [ "dc = LaPDXYDroopCorrect(\n", " (\"x\", \"y\"),\n", " pivot_to_feedthru=21.6,\n", ")" ] }, { "cell_type": "markdown", "id": "5fb681c2-cc91-4c64-bbb8-8497990a779a", "metadata": {}, "source": [ "Generate some sample points. We will consider these as the end locations of a drooping probe shaft with respect to the LaPD ball valve." ] }, { "cell_type": "code", "execution_count": null, "id": "e2f6f01a-43c1-42c1-b5ce-9c5a79868f70", "metadata": {}, "outputs": [], "source": [ "pivot_to_center = 65\n", "\n", "points = np.zeros((40, 2))\n", "points[0:10, 0] = pivot_to_center - np.linspace(-5, 5, num=10, endpoint=False)\n", "points[0:10, 1] = 5 * np.ones(10)\n", "points[10:20, 0] = pivot_to_center - 5 * np.ones(10)\n", "points[10:20, 1] = np.linspace(5, -5, num=10, endpoint=False)\n", "points[20:30, 0] = pivot_to_center - np.linspace(5, -5, num=10, endpoint=False)\n", "points[20:30, 1] = -5 * np.ones(10)\n", "points[30:40, 0] = pivot_to_center - -5 * np.ones(10)\n", "points[30:40, 1] = np.linspace(-5, 5, num=10, endpoint=False)\n", "\n", "points;" ] }, { "cell_type": "markdown", "id": "1643ceec-2576-429b-8a8c-51bdca990e85", "metadata": {}, "source": "Let's calculate the corresponding non-droop points ``ndroop_points`` and back again ``droop_points`` to see the correction returns to ``points``." }, { "cell_type": "code", "execution_count": null, "id": "71dcdefb-0289-4dc8-bc5a-e92f004cb0f0", "metadata": {}, "outputs": [], "source": [ "nondroop_points = dc(points, to_points=\"non-droop\")\n", "droop_points = dc(nondroop_points, to_points=\"droop\")\n", "\n", "np.allclose(droop_points, points)" ] }, { "cell_type": "markdown", "id": "222d9894-0de2-4192-853d-cdc612752588", "metadata": {}, "source": "In reality ``points`` and ``droop_points`` are not exactly equal since the non-droop direction and to be determine through an interactive computation. Only the non-droop to droop correction has a fitted polynomial." }, { "cell_type": "code", "execution_count": null, "id": "4262ceaf-db9a-4631-991e-c64fbea49481", "metadata": {}, "outputs": [], "source": [ "(droop_points - points)" ] }, { "cell_type": "markdown", "id": "da0c9687-d773-477e-a574-b12bdbd4f683", "metadata": {}, "source": [ "## Plot" ] }, { "cell_type": "code", "execution_count": null, "id": "44f570bc-850f-4b0f-a304-3a6f1807fd8c", "metadata": {}, "outputs": [], "source": [ "figwidth, figheight = plt.rcParams[\"figure.figsize\"]\n", "figwidth = 1.1 * figwidth\n", "figheight = 1.0 * figheight\n", "fig, axs = plt.subplots(1, 1, figsize=[figwidth, figheight])\n", "\n", "axs.set_xlabel(\"Ball Valve X\")\n", "axs.set_ylabel(\"Ball Valve Y\")\n", "\n", "axs.plot(points[..., 0], points[..., 1], 'o', label=\"droop points\")\n", "axs.plot(nondroop_points[..., 0], nondroop_points[..., 1], 'o', label=\"non-droop points\")\n", "axs.legend();" ] }, { "cell_type": "code", "execution_count": null, "id": "82aa413b-6546-4cbc-9115-125ffcc107ee", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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": 5 }