{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "#add relative path to backend\n",
    "import sys\n",
    "sys.path.append('../../clean_diag/backend')\n",
    "\n",
    "import trap_units as si"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1064nm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.load(\"data/sweeps_1064.npz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 47996 characters]",
      "text/plain": [
       "<Figure size 1000x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(10,5))\n",
    "ax1 = fig.add_subplot(111)\n",
    "ax2 = ax1.twiny()\n",
    "\n",
    "ax1.set_yscale(\"log\")\n",
    "ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"gradient_rel\"],\"o\",label=\"gradient\")\n",
    "ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"power_rel\"],\"o\",label=\"power\")\n",
    "\n",
    "ax1.set_title(r\"relative precision ($\\frac{\\text{stepsize}}{\\text{value}}$) needed to control atomnumber (1064nm, a=184, eta=9)\")\n",
    "ax1.set_xlabel(\"gradient [G/cm]\")\n",
    "ax1.set_ylabel(\"relative precision\")\n",
    "\n",
    "new_tick_locations = data[\"power\"][::2]/si.uW\n",
    "\n",
    "ax2.set_xlim(ax1.get_xlim())\n",
    "ax2.set_xticks(new_tick_locations)\n",
    "#ax2.set_xticklabels(new_tick_locations)\n",
    "ax2.set_xlabel(r\"power [uW]\")\n",
    "\n",
    "ax1.legend()\n",
    "ax1.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 51700 characters]",
      "text/plain": [
       "<Figure size 1000x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(10,5))\n",
    "ax1 = fig.add_subplot(111)\n",
    "ax2 = ax1.twiny()\n",
    "\n",
    "ax1.set_yscale(\"linear\")\n",
    "ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"gradient_step\"]/si.G*si.cm,\"o\",label=\"gradient\")\n",
    "#ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"power_step\"]/si.uW,\"o\",label=\"power\")\n",
    "\n",
    "ax1.set_title(\"absolute precision needed to control atomnumber (1064nm, a=184, eta=9)\")\n",
    "ax1.set_xlabel(\"gradient [G/cm]\")\n",
    "ax1.set_ylabel(\"absolute precision [G/cm]\")\n",
    "\n",
    "new_tick_locations = data[\"power\"][::2]/si.uW\n",
    "\n",
    "ax2.set_xlim(ax1.get_xlim())\n",
    "ax2.set_xticks(new_tick_locations)\n",
    "#ax2.set_xticklabels(new_tick_locations)\n",
    "ax2.set_xlabel(r\"power [uW]\")\n",
    "\n",
    "ax1.legend()\n",
    "ax1.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 47964 characters]",
      "text/plain": [
       "<Figure size 1000x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(10,5))\n",
    "ax1 = fig.add_subplot(111)\n",
    "ax2 = ax1.twiny()\n",
    "\n",
    "ax1.set_yscale(\"linear\")\n",
    "#ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"gradient_step\"]/si.G*si.cm,\"o\",label=\"gradient\")\n",
    "ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"power_step\"]/si.uW,\"o\",label=\"power\")\n",
    "\n",
    "ax1.set_title(\"absolute precision needed to control atomnumber (1064nm, a=184, eta=9)\")\n",
    "ax1.set_xlabel(\"gradient [G/cm]\")\n",
    "ax1.set_ylabel(\"absolute precision [uW]\")\n",
    "\n",
    "new_tick_locations = data[\"power\"][::2]/si.uW\n",
    "\n",
    "ax2.set_xlim(ax1.get_xlim())\n",
    "ax2.set_xticks(new_tick_locations)\n",
    "#ax2.set_xticklabels(new_tick_locations)\n",
    "ax2.set_xlabel(r\"power [uW]\")\n",
    "\n",
    "ax1.legend()\n",
    "ax1.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.load(\"data/sweeps_532.npz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 43960 characters]",
      "text/plain": [
       "<Figure size 1000x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(10,5))\n",
    "ax1 = fig.add_subplot(111)\n",
    "ax2 = ax1.twiny()\n",
    "\n",
    "ax1.set_yscale(\"log\")\n",
    "ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"gradient_rel\"],\"o\",label=\"gradient\")\n",
    "ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"power_rel\"],\"o\",label=\"power\")\n",
    "\n",
    "ax1.set_title(r\"relative precision ($\\frac{\\text{stepsize}}{\\text{value}}$) needed to control atomnumber (532nm, a=180, eta=9)\")\n",
    "ax1.set_xlabel(\"gradient [G/cm]\")\n",
    "ax1.set_ylabel(\"relative precision\")\n",
    "\n",
    "new_tick_locations = data[\"power\"][::2]/si.uW\n",
    "\n",
    "ax2.set_xlim(ax1.get_xlim())\n",
    "ax2.set_xticks(new_tick_locations)\n",
    "#ax2.set_xticklabels(new_tick_locations)\n",
    "ax2.set_xlabel(r\"power [uW]\")\n",
    "\n",
    "ax1.legend()\n",
    "ax1.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 49624 characters]",
      "text/plain": [
       "<Figure size 1000x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(10,5))\n",
    "ax1 = fig.add_subplot(111)\n",
    "ax2 = ax1.twiny()\n",
    "\n",
    "ax1.set_yscale(\"linear\")\n",
    "ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"gradient_step\"]/si.G*si.cm,\"o\",label=\"gradient\")\n",
    "#ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"power_step\"]/si.uW,\"o\",label=\"power\")\n",
    "\n",
    "ax1.set_title(\"absolute precision needed to control atomnumber (532nm, a=180, eta=9)\")\n",
    "ax1.set_xlabel(\"gradient [G/cm]\")\n",
    "ax1.set_ylabel(\"absolute precision [G/cm]\")\n",
    "\n",
    "new_tick_locations = data[\"power\"][::2]/si.uW\n",
    "\n",
    "ax2.set_xlim(ax1.get_xlim())\n",
    "ax2.set_xticks(new_tick_locations)\n",
    "#ax2.set_xticklabels(new_tick_locations)\n",
    "ax2.set_xlabel(r\"power [uW]\")\n",
    "\n",
    "ax1.legend()\n",
    "ax1.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 51328 characters]",
      "text/plain": [
       "<Figure size 1000x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(10,5))\n",
    "ax1 = fig.add_subplot(111)\n",
    "ax2 = ax1.twiny()\n",
    "\n",
    "ax1.set_yscale(\"linear\")\n",
    "#ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"gradient_step\"]/si.G*si.cm,\"o\",label=\"gradient\")\n",
    "ax1.plot(data[\"gradient\"]/si.G*si.cm,data[\"power_step\"]/si.uW,\"o\",label=\"power\")\n",
    "\n",
    "ax1.set_title(\"absolute precision needed to control atomnumber (532nm, a=180, eta=9)\")\n",
    "ax1.set_xlabel(\"gradient [G/cm]\")\n",
    "ax1.set_ylabel(\"absolute precision [uW]\")\n",
    "\n",
    "new_tick_locations = data[\"power\"][::2]/si.uW\n",
    "\n",
    "ax2.set_xlim(ax1.get_xlim())\n",
    "ax2.set_xticks(new_tick_locations)\n",
    "#ax2.set_xticklabels(new_tick_locations)\n",
    "ax2.set_xlabel(r\"power [uW]\")\n",
    "\n",
    "ax1.legend()\n",
    "ax1.grid()\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "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.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
