{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "import fewfermions.analysis.units as si"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.load(\"sweeps_1064_eta9.npz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 43396 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\"]/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": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 54232 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\"]/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": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 45304 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\"]/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": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.load(\"sweeps_532_eta9.npz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 44536 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\"]/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": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 51744 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\"]/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": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 47252 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\"]/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": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.load(\"sweeps_532_eta9_2.npz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 53560 characters]",
      "text/plain": [
       "<Figure size 1500x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(15,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\"]/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": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 59080 characters]",
      "text/plain": [
       "<Figure size 1500x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(15,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\"]/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": "markdown",
   "metadata": {},
   "source": [
    "## Now 532nm with different polarisabilities:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.load(\"sweeps_532_alpha408.npz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 53988 characters]",
      "text/plain": [
       "<Figure size 1500x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(15,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=408, eta=9)\")\n",
    "ax1.set_xlabel(\"gradient [G/cm]\")\n",
    "ax1.set_ylabel(\"relative precision\")\n",
    "\n",
    "new_tick_locations = data[\"power\"]/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": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.load(\"sweeps_532_alpha50.npz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 52996 characters]",
      "text/plain": [
       "<Figure size 1500x500 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(15,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=50, eta=9)\")\n",
    "ax1.set_xlabel(\"gradient [G/cm]\")\n",
    "ax1.set_ylabel(\"relative precision\")\n",
    "\n",
    "new_tick_locations = data[\"power\"]/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.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
