{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Import supporting package"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import xarray as xr\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import copy\n",
    "\n",
    "import xrft\n",
    "import finufft\n",
    "\n",
    "from uncertainties import ufloat\n",
    "from uncertainties import unumpy as unp\n",
    "from uncertainties import umath\n",
    "\n",
    "from datetime import datetime\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "plt.rcParams['font.size'] = 18\n",
    "\n",
    "from DataContainer.ReadData import read_hdf5_file, read_hdf5_global, read_hdf5_run_time\n",
    "from Analyser.ImagingAnalyser import ImageAnalyser\n",
    "from Analyser.FitAnalyser import FitAnalyser\n",
    "from Analyser.FFTAnalyser import fft, ifft, fft_nutou\n",
    "from ToolFunction.ToolFunction import *\n",
    "\n",
    "from ToolFunction.HomeMadeXarrayFunction import errorbar, dataarray_plot_errorbar\n",
    "xr.plot.dataarray_plot.errorbar = errorbar\n",
    "xr.plot.accessor.DataArrayPlotAccessor.errorbar = dataarray_plot_errorbar\n",
    "\n",
    "imageAnalyser = ImageAnalyser()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Start a client for parallel computing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "    <div style=\"width: 24px; height: 24px; background-color: #e1e1e1; border: 3px solid #9D9D9D; border-radius: 5px; position: absolute;\"> </div>\n",
       "    <div style=\"margin-left: 48px;\">\n",
       "        <h3 style=\"margin-bottom: 0px;\">Client</h3>\n",
       "        <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Client-ce3d6de8-f653-11ed-8a44-80e82ce2fa8e</p>\n",
       "        <table style=\"width: 100%; text-align: left;\">\n",
       "\n",
       "        <tr>\n",
       "        \n",
       "            <td style=\"text-align: left;\"><strong>Connection method:</strong> Cluster object</td>\n",
       "            <td style=\"text-align: left;\"><strong>Cluster type:</strong> distributed.LocalCluster</td>\n",
       "        \n",
       "        </tr>\n",
       "\n",
       "        \n",
       "            <tr>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:8787/status\" target=\"_blank\">http://127.0.0.1:8787/status</a>\n",
       "                </td>\n",
       "                <td style=\"text-align: left;\"></td>\n",
       "            </tr>\n",
       "        \n",
       "\n",
       "        </table>\n",
       "\n",
       "        \n",
       "\n",
       "        \n",
       "            <details>\n",
       "            <summary style=\"margin-bottom: 20px;\"><h3 style=\"display: inline;\">Cluster Info</h3></summary>\n",
       "            <div class=\"jp-RenderedHTMLCommon jp-RenderedHTML jp-mod-trusted jp-OutputArea-output\">\n",
       "    <div style=\"width: 24px; height: 24px; background-color: #e1e1e1; border: 3px solid #9D9D9D; border-radius: 5px; position: absolute;\">\n",
       "    </div>\n",
       "    <div style=\"margin-left: 48px;\">\n",
       "        <h3 style=\"margin-bottom: 0px; margin-top: 0px;\">LocalCluster</h3>\n",
       "        <p style=\"color: #9D9D9D; margin-bottom: 0px;\">b4aeb775</p>\n",
       "        <table style=\"width: 100%; text-align: left;\">\n",
       "            <tr>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Dashboard:</strong> <a href=\"http://127.0.0.1:8787/status\" target=\"_blank\">http://127.0.0.1:8787/status</a>\n",
       "                </td>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Workers:</strong> 6\n",
       "                </td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Total threads:</strong> 24\n",
       "                </td>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Total memory:</strong> 55.88 GiB\n",
       "                </td>\n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "    <td style=\"text-align: left;\"><strong>Status:</strong> running</td>\n",
       "    <td style=\"text-align: left;\"><strong>Using processes:</strong> True</td>\n",
       "</tr>\n",
       "\n",
       "            \n",
       "        </table>\n",
       "\n",
       "        <details>\n",
       "            <summary style=\"margin-bottom: 20px;\">\n",
       "                <h3 style=\"display: inline;\">Scheduler Info</h3>\n",
       "            </summary>\n",
       "\n",
       "            <div style=\"\">\n",
       "    <div>\n",
       "        <div style=\"width: 24px; height: 24px; background-color: #FFF7E5; border: 3px solid #FF6132; border-radius: 5px; position: absolute;\"> </div>\n",
       "        <div style=\"margin-left: 48px;\">\n",
       "            <h3 style=\"margin-bottom: 0px;\">Scheduler</h3>\n",
       "            <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Scheduler-7292c9f7-a659-455f-b744-b366f71faa4e</p>\n",
       "            <table style=\"width: 100%; text-align: left;\">\n",
       "                <tr>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Comm:</strong> tcp://127.0.0.1:59304\n",
       "                    </td>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Workers:</strong> 6\n",
       "                    </td>\n",
       "                </tr>\n",
       "                <tr>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Dashboard:</strong> <a href=\"http://127.0.0.1:8787/status\" target=\"_blank\">http://127.0.0.1:8787/status</a>\n",
       "                    </td>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Total threads:</strong> 24\n",
       "                    </td>\n",
       "                </tr>\n",
       "                <tr>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Started:</strong> Just now\n",
       "                    </td>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Total memory:</strong> 55.88 GiB\n",
       "                    </td>\n",
       "                </tr>\n",
       "            </table>\n",
       "        </div>\n",
       "    </div>\n",
       "\n",
       "    <details style=\"margin-left: 48px;\">\n",
       "        <summary style=\"margin-bottom: 20px;\">\n",
       "            <h3 style=\"display: inline;\">Workers</h3>\n",
       "        </summary>\n",
       "\n",
       "        \n",
       "        <div style=\"margin-bottom: 20px;\">\n",
       "            <div style=\"width: 24px; height: 24px; background-color: #DBF5FF; border: 3px solid #4CC9FF; border-radius: 5px; position: absolute;\"> </div>\n",
       "            <div style=\"margin-left: 48px;\">\n",
       "            <details>\n",
       "                <summary>\n",
       "                    <h4 style=\"margin-bottom: 0px; display: inline;\">Worker: 0</h4>\n",
       "                </summary>\n",
       "                <table style=\"width: 100%; text-align: left;\">\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Comm: </strong> tcp://127.0.0.1:59336\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 4\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:59339/status\" target=\"_blank\">http://127.0.0.1:59339/status</a>\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Memory: </strong> 9.31 GiB\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Nanny: </strong> tcp://127.0.0.1:59307\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\"></td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td colspan=\"2\" style=\"text-align: left;\">\n",
       "                            <strong>Local directory: </strong> C:\\Users\\data\\AppData\\Local\\Temp\\dask-worker-space\\worker-73y3n_r9\n",
       "                        </td>\n",
       "                    </tr>\n",
       "\n",
       "                    \n",
       "\n",
       "                    \n",
       "\n",
       "                </table>\n",
       "            </details>\n",
       "            </div>\n",
       "        </div>\n",
       "        \n",
       "        <div style=\"margin-bottom: 20px;\">\n",
       "            <div style=\"width: 24px; height: 24px; background-color: #DBF5FF; border: 3px solid #4CC9FF; border-radius: 5px; position: absolute;\"> </div>\n",
       "            <div style=\"margin-left: 48px;\">\n",
       "            <details>\n",
       "                <summary>\n",
       "                    <h4 style=\"margin-bottom: 0px; display: inline;\">Worker: 1</h4>\n",
       "                </summary>\n",
       "                <table style=\"width: 100%; text-align: left;\">\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Comm: </strong> tcp://127.0.0.1:59345\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 4\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:59347/status\" target=\"_blank\">http://127.0.0.1:59347/status</a>\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Memory: </strong> 9.31 GiB\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Nanny: </strong> tcp://127.0.0.1:59308\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\"></td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td colspan=\"2\" style=\"text-align: left;\">\n",
       "                            <strong>Local directory: </strong> C:\\Users\\data\\AppData\\Local\\Temp\\dask-worker-space\\worker-z72eyh5g\n",
       "                        </td>\n",
       "                    </tr>\n",
       "\n",
       "                    \n",
       "\n",
       "                    \n",
       "\n",
       "                </table>\n",
       "            </details>\n",
       "            </div>\n",
       "        </div>\n",
       "        \n",
       "        <div style=\"margin-bottom: 20px;\">\n",
       "            <div style=\"width: 24px; height: 24px; background-color: #DBF5FF; border: 3px solid #4CC9FF; border-radius: 5px; position: absolute;\"> </div>\n",
       "            <div style=\"margin-left: 48px;\">\n",
       "            <details>\n",
       "                <summary>\n",
       "                    <h4 style=\"margin-bottom: 0px; display: inline;\">Worker: 2</h4>\n",
       "                </summary>\n",
       "                <table style=\"width: 100%; text-align: left;\">\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Comm: </strong> tcp://127.0.0.1:59332\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 4\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:59333/status\" target=\"_blank\">http://127.0.0.1:59333/status</a>\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Memory: </strong> 9.31 GiB\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Nanny: </strong> tcp://127.0.0.1:59309\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\"></td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td colspan=\"2\" style=\"text-align: left;\">\n",
       "                            <strong>Local directory: </strong> C:\\Users\\data\\AppData\\Local\\Temp\\dask-worker-space\\worker-q12q3qsa\n",
       "                        </td>\n",
       "                    </tr>\n",
       "\n",
       "                    \n",
       "\n",
       "                    \n",
       "\n",
       "                </table>\n",
       "            </details>\n",
       "            </div>\n",
       "        </div>\n",
       "        \n",
       "        <div style=\"margin-bottom: 20px;\">\n",
       "            <div style=\"width: 24px; height: 24px; background-color: #DBF5FF; border: 3px solid #4CC9FF; border-radius: 5px; position: absolute;\"> </div>\n",
       "            <div style=\"margin-left: 48px;\">\n",
       "            <details>\n",
       "                <summary>\n",
       "                    <h4 style=\"margin-bottom: 0px; display: inline;\">Worker: 3</h4>\n",
       "                </summary>\n",
       "                <table style=\"width: 100%; text-align: left;\">\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Comm: </strong> tcp://127.0.0.1:59344\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 4\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:59346/status\" target=\"_blank\">http://127.0.0.1:59346/status</a>\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Memory: </strong> 9.31 GiB\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Nanny: </strong> tcp://127.0.0.1:59310\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\"></td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td colspan=\"2\" style=\"text-align: left;\">\n",
       "                            <strong>Local directory: </strong> C:\\Users\\data\\AppData\\Local\\Temp\\dask-worker-space\\worker-75c6pwd0\n",
       "                        </td>\n",
       "                    </tr>\n",
       "\n",
       "                    \n",
       "\n",
       "                    \n",
       "\n",
       "                </table>\n",
       "            </details>\n",
       "            </div>\n",
       "        </div>\n",
       "        \n",
       "        <div style=\"margin-bottom: 20px;\">\n",
       "            <div style=\"width: 24px; height: 24px; background-color: #DBF5FF; border: 3px solid #4CC9FF; border-radius: 5px; position: absolute;\"> </div>\n",
       "            <div style=\"margin-left: 48px;\">\n",
       "            <details>\n",
       "                <summary>\n",
       "                    <h4 style=\"margin-bottom: 0px; display: inline;\">Worker: 4</h4>\n",
       "                </summary>\n",
       "                <table style=\"width: 100%; text-align: left;\">\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Comm: </strong> tcp://127.0.0.1:59335\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 4\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:59337/status\" target=\"_blank\">http://127.0.0.1:59337/status</a>\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Memory: </strong> 9.31 GiB\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Nanny: </strong> tcp://127.0.0.1:59311\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\"></td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td colspan=\"2\" style=\"text-align: left;\">\n",
       "                            <strong>Local directory: </strong> C:\\Users\\data\\AppData\\Local\\Temp\\dask-worker-space\\worker-vs73ymq0\n",
       "                        </td>\n",
       "                    </tr>\n",
       "\n",
       "                    \n",
       "\n",
       "                    \n",
       "\n",
       "                </table>\n",
       "            </details>\n",
       "            </div>\n",
       "        </div>\n",
       "        \n",
       "        <div style=\"margin-bottom: 20px;\">\n",
       "            <div style=\"width: 24px; height: 24px; background-color: #DBF5FF; border: 3px solid #4CC9FF; border-radius: 5px; position: absolute;\"> </div>\n",
       "            <div style=\"margin-left: 48px;\">\n",
       "            <details>\n",
       "                <summary>\n",
       "                    <h4 style=\"margin-bottom: 0px; display: inline;\">Worker: 5</h4>\n",
       "                </summary>\n",
       "                <table style=\"width: 100%; text-align: left;\">\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Comm: </strong> tcp://127.0.0.1:59341\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 4\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:59342/status\" target=\"_blank\">http://127.0.0.1:59342/status</a>\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Memory: </strong> 9.31 GiB\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Nanny: </strong> tcp://127.0.0.1:59312\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\"></td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td colspan=\"2\" style=\"text-align: left;\">\n",
       "                            <strong>Local directory: </strong> C:\\Users\\data\\AppData\\Local\\Temp\\dask-worker-space\\worker-6pd88xs6\n",
       "                        </td>\n",
       "                    </tr>\n",
       "\n",
       "                    \n",
       "\n",
       "                    \n",
       "\n",
       "                </table>\n",
       "            </details>\n",
       "            </div>\n",
       "        </div>\n",
       "        \n",
       "\n",
       "    </details>\n",
       "</div>\n",
       "\n",
       "        </details>\n",
       "    </div>\n",
       "</div>\n",
       "            </details>\n",
       "        \n",
       "\n",
       "    </div>\n",
       "</div>"
      ],
      "text/plain": [
       "<Client: 'tcp://127.0.0.1:59304' processes=6 threads=24, memory=55.88 GiB>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from dask.distributed import Client\n",
    "client = Client(n_workers=6, threads_per_worker=4, processes=True, memory_limit='10GB')\n",
    "client"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set global path for experiment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "groupList = [\n",
    "    \"images/MOT_3D_Camera/in_situ_absorption\",\n",
    "    \"images/ODT_1_Axis_Camera/in_situ_absorption\",\n",
    "    \"images/ODT_2_Axis_Camera/in_situ_absorption\",\n",
    "]\n",
    "\n",
    "dskey = {\n",
    "    \"images/MOT_3D_Camera/in_situ_absorption\": \"camera_0\",\n",
    "    \"images/ODT_1_Axis_Camera/in_situ_absorption\": \"camera_1\",\n",
    "    \"images/ODT_2_Axis_Camera/in_situ_absorption\": \"camera_2\",\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "img_dir = '//DyLabNAS/Data/'\n",
    "SequenceName = \"Evaporative_Cooling\" + \"/\"\n",
    "folderPath = img_dir + SequenceName + \"2023/05/09\" # get_date()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Check the stability of our BEC"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The detected scaning axes and values are: \n",
      "\n",
      "{'runs': array([  0.,   1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.,\n",
      "        11.,  12.,  13.,  14.,  15.,  16.,  17.,  18.,  19.,  20.,  21.,\n",
      "        22.,  23.,  24.,  25.,  26.,  27.,  28.,  29.,  30.,  31.,  32.,\n",
      "        33.,  34.,  35.,  36.,  37.,  38.,  39.,  40.,  41.,  42.,  43.,\n",
      "        44.,  45.,  46.,  47.,  48.,  49.,  50.,  51.,  52.,  53.,  54.,\n",
      "        55.,  56.,  57.,  58.,  59.,  60.,  61.,  62.,  63.,  64.,  65.,\n",
      "        66.,  67.,  68.,  69.,  70.,  71.,  72.,  73.,  74.,  75.,  76.,\n",
      "        77.,  78.,  79.,  80.,  81.,  82.,  83.,  84.,  85.,  86.,  87.,\n",
      "        88.,  89.,  90.,  91.,  92.,  93.,  94.,  95.,  96.,  97.,  98.,\n",
      "        99., 100., 101., 102., 103., 104., 105., 106., 107., 108., 109.,\n",
      "       110., 111., 112., 113., 114., 115., 116., 117., 118., 119., 120.,\n",
      "       121., 122., 123., 124., 125., 126., 127., 128., 129., 130., 131.,\n",
      "       132., 133., 134., 135., 136., 137., 138., 139., 140., 141., 142.,\n",
      "       143., 144., 145., 146., 147., 148., 149., 150., 151., 152., 153.,\n",
      "       154., 155., 156., 157., 158., 159., 160., 161., 162., 163., 164.,\n",
      "       165., 166., 167., 168., 169., 170., 171., 172., 173., 174., 175.,\n",
      "       176., 177., 178., 179., 180., 181., 182., 183., 184., 185., 186.,\n",
      "       187., 188., 189., 190., 191., 192., 193., 194., 195., 196., 197.,\n",
      "       198., 199., 200., 201., 202., 203., 204., 205., 206., 207., 208.,\n",
      "       209., 210., 211., 212., 213., 214., 215., 216., 217., 218., 219.,\n",
      "       220., 221., 222., 223., 224., 225., 226., 227., 228., 229., 230.,\n",
      "       231., 232., 233., 234., 235., 236., 237., 238., 239., 240., 241.,\n",
      "       242., 243., 244., 245., 246., 247., 248., 249., 250., 251., 252.,\n",
      "       253., 254., 255., 256., 257., 258., 259., 260., 261., 262., 263.,\n",
      "       264., 265., 266., 267., 268., 269., 270., 271., 272., 273., 274.,\n",
      "       275., 276., 277., 278., 279., 280., 281., 282., 283., 284., 285.,\n",
      "       286., 287., 288., 289., 290., 291., 292., 293., 294., 295., 296.,\n",
      "       297., 298., 299., 300., 301., 302., 303., 304., 305., 306., 307.,\n",
      "       308., 309., 310., 311., 312., 313., 314., 315., 316., 317., 318.,\n",
      "       319., 320., 321., 322., 323., 324., 325., 326., 327., 328., 329.,\n",
      "       330., 331., 332., 333., 334., 335., 336., 337., 338., 339., 340.,\n",
      "       341., 342., 343., 344., 345., 346., 347., 348., 349., 350., 351.,\n",
      "       352., 353., 354., 355., 356., 357., 358., 359., 360., 361., 362.,\n",
      "       363., 364., 365., 366., 367., 368., 369., 370., 371., 372., 373.,\n",
      "       374., 375., 376., 377., 378., 379., 380., 381., 382., 383., 384.,\n",
      "       385., 386., 387., 388., 389., 390., 391., 392., 393., 394., 395.,\n",
      "       396., 397., 398., 399., 400., 401., 402., 403., 404., 405., 406.,\n",
      "       407., 408., 409., 410., 411., 412., 413., 414., 415., 416., 417.,\n",
      "       418., 419., 420., 421., 422., 423., 424., 425., 426., 427., 428.,\n",
      "       429., 430., 431., 432., 433., 434., 435., 436., 437., 438., 439.,\n",
      "       440., 441., 442., 443., 444., 445., 446., 447., 448., 449., 450.,\n",
      "       451., 452., 453., 454., 455., 456., 457., 458., 459., 460., 461.,\n",
      "       462., 463., 464., 465., 466., 467., 468., 469., 470., 471., 472.,\n",
      "       473., 474., 475., 476., 477., 478., 479., 480., 481., 482., 483.,\n",
      "       484., 485., 486., 487., 488., 489., 490., 491., 492., 493., 494.,\n",
      "       495., 496., 497., 498., 499., 500., 501., 502., 503., 504., 505.,\n",
      "       506., 507., 508., 509., 510., 511., 512., 513., 514., 515., 516.,\n",
      "       517., 518., 519., 520., 521., 522., 523., 524., 525., 526., 527.,\n",
      "       528., 529., 530., 531., 532., 533., 534., 535., 536., 537., 538.,\n",
      "       539., 540., 541., 542., 543., 544., 545., 546., 547., 548., 549.])}\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 49912 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "shotNum = \"0007\"\n",
    "filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
    "\n",
    "dataSetOfGlobalDict = {\n",
    "    dskey[groupList[i]]: read_hdf5_global(filePath, groupList[i])\n",
    "    for i in [0]\n",
    "}\n",
    "\n",
    "dataSetDict = {\n",
    "    dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i], datesetOfGlobal=dataSetOfGlobalDict[dskey[groupList[i]]])\n",
    "    for i in [0]\n",
    "}\n",
    "\n",
    "dataSet = dataSetDict[\"camera_0\"]\n",
    "\n",
    "print_scanAxis(dataSet)\n",
    "\n",
    "scanAxis = get_scanAxis(dataSet)\n",
    "\n",
    "dataSet = auto_rechunk(dataSet)\n",
    "dataSet = swap_xy(dataSet)\n",
    "\n",
    "dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
    "\n",
    "imageAnalyser.center = (959, 876)\n",
    "imageAnalyser.span = (100, 100)\n",
    "imageAnalyser.fraction = (0.1, 0.1)\n",
    "\n",
    "dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
    "dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
    "\n",
    "Ncount = imageAnalyser.get_Ncount(dataSet_cropOD).load()\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "Ncount.plot.errorbar(ax=ax, fmt='ob')\n",
    "\n",
    "plt.ylabel('NCount')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataSet_cropOD = auto_rechunk(dataSet_cropOD)\n",
    "\n",
    "fitAnalyser = FitAnalyser(\"Two Gaussian-2D\", fitDim=2)\n",
    "params = fitAnalyser.guess(dataSet_cropOD, dask=\"parallelized\")\n",
    "fitResult = fitAnalyser.fit(dataSet_cropOD, params, dask=\"parallelized\").load()\n",
    "\n",
    "fitValue = fitAnalyser.get_fit_value(fitResult)\n",
    "fitStd = fitAnalyser.get_fit_std(fitResult)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "BEC_Ncount_val = fitValue['A_amplitude']\n",
    "BEC_Ncount_std = fitStd['A_amplitude']\n",
    "\n",
    "thermal_Ncount_val = fitValue['B_amplitude']\n",
    "thermal_Ncount_std = fitStd['B_amplitude']\n",
    "\n",
    "BEC_width_x_val = fitValue['A_sigmax']\n",
    "BEC_width_x_std = fitStd['A_sigmax']\n",
    "BEC_width_y_val = fitValue['A_sigmay']\n",
    "BEC_width_y_std = fitStd['A_sigmay']\n",
    "\n",
    "thermal_width_x_val = fitValue['B_sigmax']\n",
    "thermal_width_x_std = fitStd['B_sigmax']\n",
    "thermal_width_y_val = fitValue['B_sigmay']\n",
    "thermal_width_y_std = fitStd['B_sigmay']\n",
    "\n",
    "BEC_center_x_val = fitValue['A_centerx']\n",
    "BEC_center_x_std = fitStd['A_centerx']\n",
    "BEC_center_y_val = fitValue['A_centery']\n",
    "BEC_center_y_std = fitStd['A_centery']\n",
    "\n",
    "thermal_center_x_val = fitValue['B_centerx']\n",
    "thermal_center_x_std = fitStd['B_centerx']\n",
    "thermal_center_y_val = fitValue['B_centery']\n",
    "thermal_center_y_std = fitStd['B_centery']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 55204 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<xarray.DataArray ()>\n",
      "array(853.42940839)\n"
     ]
    }
   ],
   "source": [
    "total_Ncount_val = BEC_Ncount_val + thermal_Ncount_val\n",
    "total_Ncount_std = BEC_Ncount_std + thermal_Ncount_std\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "total_Ncount_val.plot.errorbar(ax=ax, yerr=total_Ncount_std, fmt='ob')\n",
    "# plt.ylim([0, 1100])\n",
    "plt.ylabel('Ncount from fit')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()\n",
    "\n",
    "print(total_Ncount_val.mean())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 42532 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "BEC_Ncount_val.plot.errorbar(ax=ax, yerr=BEC_Ncount_std, fmt='ob')\n",
    "plt.ylim([0, 750])\n",
    "plt.ylabel('Ncount of BEC part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 46436 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_Ncount_val.plot.errorbar(ax=ax, yerr=thermal_Ncount_std, fmt='or')\n",
    "plt.ylim([0, 500])\n",
    "plt.ylabel('Ncount of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 53716 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "BEC_width_x_val.plot.errorbar(ax=ax, yerr=BEC_width_x_std, fmt='ob')\n",
    "\n",
    "plt.ylabel('X-axis Width of BEC part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 59044 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "BEC_width_y_val.plot.errorbar(ax=ax, yerr=BEC_width_y_std, fmt='ob')\n",
    "\n",
    "plt.ylabel('Y-axis Width of BEC part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 64840 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_width_x_val.plot.errorbar(ax=ax, yerr=thermal_width_x_std, fmt='or')\n",
    "\n",
    "plt.ylabel('X-axis width of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 59368 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_width_y_val.plot.errorbar(ax=ax, yerr=thermal_width_y_std, fmt='or')\n",
    "\n",
    "plt.ylabel('Y-axis width of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 55820 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "BEC_center_x_val.plot.errorbar(ax=ax, yerr=BEC_center_x_std, fmt='ob')\n",
    "\n",
    "plt.ylabel('X-axis center of BEC part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 56848 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "BEC_center_y_val.plot.errorbar(ax=ax, yerr=BEC_center_y_std, fmt='ob')\n",
    "\n",
    "plt.ylabel('Y-axis center of BEC part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 60184 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_center_x_val.plot.errorbar(ax=ax, yerr=thermal_center_x_std, fmt='or')\n",
    "\n",
    "plt.ylabel('X-axis center of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 63700 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_center_y_val.plot.errorbar(ax=ax, yerr=thermal_center_y_std, fmt='or')\n",
    "\n",
    "plt.ylabel('Y-axis center of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 50732 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fitFullResult = fitAnalyser.get_fit_full_result(fitResult)\n",
    "condensateFraction = fitFullResult['A_amplitude'] / (fitFullResult['A_amplitude'] + fitFullResult['B_amplitude'])\n",
    "condensateFraction_value, condensateFraction_std = seperate_uncertainty(condensateFraction)\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "condensateFraction_value.plot.errorbar(ax=ax, yerr=condensateFraction_std, fmt='ob')\n",
    "\n",
    "plt.ylabel('Condensate Fraction')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The total Ncount is:  849.84 ±  73.69\n",
      "The total Ncount from fit is:  853.43 ±  66.18\n",
      "The Ncount of the BEC part is:  528.79 ±  65.37\n",
      "The Ncount of the thermal part is:  324.64 ±  35.62\n",
      "The x-axis width of the BEC part is:  4.06 ±  0.28\n",
      "The y-axis width of the BEC part is:  11.03 ±  0.36\n",
      "The x-axis width of the thermal part is:  15.30 ±  0.91\n",
      "The y-axis width of the thermal part is:  12.99 ±  0.61\n",
      "The x-axis center of the BEC part is:  47.44 ±  1.82\n",
      "The y-axis center of the BEC part is:  51.13 ±  1.83\n",
      "The x-axis center of the thermal part is:  49.62 ±  1.54\n",
      "The y-axis center of the thermal part is:  51.17 ±  1.37\n",
      "The condensate fraction is:  0.6180 ±  0.0464\n"
     ]
    }
   ],
   "source": [
    "val = Ncount.mean().item()\n",
    "std = Ncount.std().item()\n",
    "print(f'The total Ncount is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = total_Ncount_val.mean().item()\n",
    "std = total_Ncount_val.std().item()\n",
    "print(f'The total Ncount from fit is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = BEC_Ncount_val.mean().item()\n",
    "std = BEC_Ncount_val.std().item()\n",
    "print(f'The Ncount of the BEC part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_Ncount_val.mean().item()\n",
    "std = thermal_Ncount_val.std().item()\n",
    "print(f'The Ncount of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = BEC_width_x_val.mean().item()\n",
    "std = BEC_width_x_val.std().item()\n",
    "print(f'The x-axis width of the BEC part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = BEC_width_y_val.mean().item()\n",
    "std = BEC_width_y_val.std().item()\n",
    "print(f'The y-axis width of the BEC part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_width_x_val.mean().item()\n",
    "std = thermal_width_x_val.std().item()\n",
    "print(f'The x-axis width of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_width_y_val.mean().item()\n",
    "std = thermal_width_y_val.std().item()\n",
    "print(f'The y-axis width of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = BEC_center_x_val.mean().item()\n",
    "std = BEC_center_x_val.std().item()\n",
    "print(f'The x-axis center of the BEC part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = BEC_center_y_val.mean().item()\n",
    "std = BEC_center_y_val.std().item()\n",
    "print(f'The y-axis center of the BEC part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_center_x_val.mean().item()\n",
    "std = thermal_center_x_val.std().item()\n",
    "print(f'The x-axis center of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_center_y_val.mean().item()\n",
    "std = thermal_center_y_val.std().item()\n",
    "print(f'The y-axis center of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = condensateFraction_value.mean().item()\n",
    "std = condensateFraction_value.std().item()\n",
    "print(f'The condensate fraction is: {val: .4f} \\u00B1 {std: .4f}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
       " *\n",
       " */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
       "  --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
       "  --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
       "  --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
       "  --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
       "  --xr-background-color: var(--jp-layout-color0, white);\n",
       "  --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
       "  --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
       "}\n",
       "\n",
       "html[theme=dark],\n",
       "body[data-theme=dark],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: rgba(255, 255, 255, 1);\n",
       "  --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
       "  --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
       "  --xr-border-color: #1F1F1F;\n",
       "  --xr-disabled-color: #515151;\n",
       "  --xr-background-color: #111111;\n",
       "  --xr-background-color-row-even: #111111;\n",
       "  --xr-background-color-row-odd: #313131;\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-array-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: '►';\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: '▼';\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "  padding-bottom: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: '(';\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: ')';\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: ',';\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-index-preview {\n",
       "  grid-column: 2 / 5;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  display: none;\n",
       "  background-color: var(--xr-background-color) !important;\n",
       "  padding-bottom: 5px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data,\n",
       ".xr-index-data-in:checked ~ .xr-index-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-index-name div,\n",
       ".xr-index-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2,\n",
       ".xr-no-icon {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
       "Dimensions:  (runs: 550)\n",
       "Coordinates:\n",
       "  * runs     (runs) float64 0.0 1.0 2.0 3.0 4.0 ... 546.0 547.0 548.0 549.0\n",
       "Data variables:\n",
       "    runTime  (runs) datetime64[ns] 2023-05-09T14:30:03 ... 2023-05-09T15:56:53\n",
       "Attributes: (12/101)\n",
       "    TOF_free:                          0.02\n",
       "    abs_img_freq:                      110.858\n",
       "    absorption_imaging_flag:           True\n",
       "    backup_data:                       True\n",
       "    blink_off_time:                    nan\n",
       "    blink_on_time:                     nan\n",
       "    ...                                ...\n",
       "    y_offset_img:                      0\n",
       "    z_offset:                          0.189\n",
       "    z_offset_img:                      0.189\n",
       "    runs:                              [  0.   1.   2.   3.   4.   5.   6.   ...\n",
       "    scanAxis:                          [&#x27;runs&#x27;]\n",
       "    scanAxisLength:                    [550.]</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-88084dc8-d188-4cb7-9f08-7bbc1ecd5214' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-88084dc8-d188-4cb7-9f08-7bbc1ecd5214' class='xr-section-summary'  title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>runs</span>: 550</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-244c7b76-f615-490a-b022-10578f28ae3f' class='xr-section-summary-in' type='checkbox'  checked><label for='section-244c7b76-f615-490a-b022-10578f28ae3f' class='xr-section-summary' >Coordinates: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>runs</span></div><div class='xr-var-dims'>(runs)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.0 1.0 2.0 ... 547.0 548.0 549.0</div><input id='attrs-e024ad9f-479d-49ad-b632-e22673b877a2' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-e024ad9f-479d-49ad-b632-e22673b877a2' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-af447ba5-c806-4fd5-a4af-329fa037168e' class='xr-var-data-in' type='checkbox'><label for='data-af447ba5-c806-4fd5-a4af-329fa037168e' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([  0.,   1.,   2., ..., 547., 548., 549.])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-d8431900-c013-4df4-8c03-ff6ae292a2ae' class='xr-section-summary-in' type='checkbox'  checked><label for='section-d8431900-c013-4df4-8c03-ff6ae292a2ae' class='xr-section-summary' >Data variables: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>runTime</span></div><div class='xr-var-dims'>(runs)</div><div class='xr-var-dtype'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>2023-05-09T14:30:03 ... 2023-05-...</div><input id='attrs-107aa3fc-177d-4d23-8a4b-b024a6afe3ad' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-107aa3fc-177d-4d23-8a4b-b024a6afe3ad' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4e7b9479-5510-47e8-903a-8638060c107d' class='xr-var-data-in' type='checkbox'><label for='data-4e7b9479-5510-47e8-903a-8638060c107d' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([&#x27;2023-05-09T14:30:03.000000000&#x27;, &#x27;2023-05-09T14:30:11.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:30:19.000000000&#x27;, &#x27;2023-05-09T14:30:27.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:30:35.000000000&#x27;, &#x27;2023-05-09T14:30:43.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:30:52.000000000&#x27;, &#x27;2023-05-09T14:31:00.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:31:08.000000000&#x27;, &#x27;2023-05-09T14:31:16.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:31:24.000000000&#x27;, &#x27;2023-05-09T14:31:33.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:31:41.000000000&#x27;, &#x27;2023-05-09T14:31:49.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:31:57.000000000&#x27;, &#x27;2023-05-09T14:32:05.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:32:13.000000000&#x27;, &#x27;2023-05-09T14:32:22.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:32:30.000000000&#x27;, &#x27;2023-05-09T14:32:38.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:32:46.000000000&#x27;, &#x27;2023-05-09T14:32:54.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:33:03.000000000&#x27;, &#x27;2023-05-09T14:33:11.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:33:19.000000000&#x27;, &#x27;2023-05-09T14:33:27.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:33:35.000000000&#x27;, &#x27;2023-05-09T14:33:44.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:33:52.000000000&#x27;, &#x27;2023-05-09T14:34:00.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:34:08.000000000&#x27;, &#x27;2023-05-09T14:34:16.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:34:24.000000000&#x27;, &#x27;2023-05-09T14:34:32.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:34:41.000000000&#x27;, &#x27;2023-05-09T14:34:49.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:34:57.000000000&#x27;, &#x27;2023-05-09T14:35:05.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:35:13.000000000&#x27;, &#x27;2023-05-09T14:35:21.000000000&#x27;,\n",
       "...\n",
       "       &#x27;2023-05-09T15:51:57.000000000&#x27;, &#x27;2023-05-09T15:52:05.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:52:13.000000000&#x27;, &#x27;2023-05-09T15:52:21.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:52:29.000000000&#x27;, &#x27;2023-05-09T15:52:37.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:52:45.000000000&#x27;, &#x27;2023-05-09T15:52:53.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:53:01.000000000&#x27;, &#x27;2023-05-09T15:53:09.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:53:17.000000000&#x27;, &#x27;2023-05-09T15:53:25.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:53:33.000000000&#x27;, &#x27;2023-05-09T15:53:41.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:53:49.000000000&#x27;, &#x27;2023-05-09T15:53:57.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:54:05.000000000&#x27;, &#x27;2023-05-09T15:54:13.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:54:21.000000000&#x27;, &#x27;2023-05-09T15:54:29.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:54:37.000000000&#x27;, &#x27;2023-05-09T15:54:45.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:54:53.000000000&#x27;, &#x27;2023-05-09T15:55:01.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:55:09.000000000&#x27;, &#x27;2023-05-09T15:55:17.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:55:25.000000000&#x27;, &#x27;2023-05-09T15:55:33.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:55:41.000000000&#x27;, &#x27;2023-05-09T15:55:49.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:55:57.000000000&#x27;, &#x27;2023-05-09T15:56:05.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:56:13.000000000&#x27;, &#x27;2023-05-09T15:56:21.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:56:29.000000000&#x27;, &#x27;2023-05-09T15:56:37.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:56:45.000000000&#x27;, &#x27;2023-05-09T15:56:53.000000000&#x27;],\n",
       "      dtype=&#x27;datetime64[ns]&#x27;)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-ef465c85-8b4c-441b-9e1e-fded7ea4f456' class='xr-section-summary-in' type='checkbox'  ><label for='section-ef465c85-8b4c-441b-9e1e-fded7ea4f456' class='xr-section-summary' >Indexes: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>runs</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-f7d107bc-6e17-40b5-a03b-62a880f79946' class='xr-index-data-in' type='checkbox'/><label for='index-f7d107bc-6e17-40b5-a03b-62a880f79946' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Float64Index([  0.0,   1.0,   2.0,   3.0,   4.0,   5.0,   6.0,   7.0,   8.0,\n",
       "                9.0,\n",
       "              ...\n",
       "              540.0, 541.0, 542.0, 543.0, 544.0, 545.0, 546.0, 547.0, 548.0,\n",
       "              549.0],\n",
       "             dtype=&#x27;float64&#x27;, name=&#x27;runs&#x27;, length=550))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-9316f125-2b66-4f49-92eb-c6315d7b0e53' class='xr-section-summary-in' type='checkbox'  ><label for='section-9316f125-2b66-4f49-92eb-c6315d7b0e53' class='xr-section-summary' >Attributes: <span>(101)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>TOF_free :</span></dt><dd>0.02</dd><dt><span>abs_img_freq :</span></dt><dd>110.858</dd><dt><span>absorption_imaging_flag :</span></dt><dd>True</dd><dt><span>backup_data :</span></dt><dd>True</dd><dt><span>blink_off_time :</span></dt><dd>nan</dd><dt><span>blink_on_time :</span></dt><dd>nan</dd><dt><span>c_duration :</span></dt><dd>0.2</dd><dt><span>cmot_final_current :</span></dt><dd>0.65</dd><dt><span>cmot_hold :</span></dt><dd>0.06</dd><dt><span>cmot_initial_current :</span></dt><dd>0.18</dd><dt><span>compX_current :</span></dt><dd>0.005</dd><dt><span>compX_current_sg :</span></dt><dd>0</dd><dt><span>compX_final_current :</span></dt><dd>0.005</dd><dt><span>compX_initial_current :</span></dt><dd>0.005</dd><dt><span>compY_current :</span></dt><dd>0</dd><dt><span>compY_current_sg :</span></dt><dd>0</dd><dt><span>compY_final_current :</span></dt><dd>0.0</dd><dt><span>compY_initial_current :</span></dt><dd>0</dd><dt><span>compZ_current :</span></dt><dd>0</dd><dt><span>compZ_current_sg :</span></dt><dd>0.189</dd><dt><span>compZ_final_current :</span></dt><dd>0.2729</dd><dt><span>compZ_initial_current :</span></dt><dd>0</dd><dt><span>default_camera :</span></dt><dd>0</dd><dt><span>evap_1_arm_1_final_pow :</span></dt><dd>0.35</dd><dt><span>evap_1_arm_1_mod_depth_final :</span></dt><dd>0</dd><dt><span>evap_1_arm_1_mod_depth_initial :</span></dt><dd>1.0</dd><dt><span>evap_1_arm_1_mod_ramp_duration :</span></dt><dd>1.15</dd><dt><span>evap_1_arm_1_pow_ramp_duration :</span></dt><dd>1.65</dd><dt><span>evap_1_arm_1_start_pow :</span></dt><dd>7</dd><dt><span>evap_1_arm_2_final_pow :</span></dt><dd>5</dd><dt><span>evap_1_arm_2_ramp_duration :</span></dt><dd>0.5</dd><dt><span>evap_1_arm_2_start_pow :</span></dt><dd>0</dd><dt><span>evap_1_mod_ramp_trunc_value :</span></dt><dd>1</dd><dt><span>evap_1_pow_ramp_trunc_value :</span></dt><dd>1.0</dd><dt><span>evap_1_rate_constant_1 :</span></dt><dd>0.525</dd><dt><span>evap_1_rate_constant_2 :</span></dt><dd>0.51</dd><dt><span>evap_2_arm_1_final_pow :</span></dt><dd>0.037</dd><dt><span>evap_2_arm_1_start_pow :</span></dt><dd>0.35</dd><dt><span>evap_2_arm_2_final_pow :</span></dt><dd>0.09</dd><dt><span>evap_2_arm_2_start_pow :</span></dt><dd>5</dd><dt><span>evap_2_ramp_duration :</span></dt><dd>1.0</dd><dt><span>evap_2_ramp_trunc_value :</span></dt><dd>1.0</dd><dt><span>evap_2_rate_constant_1 :</span></dt><dd>0.37</dd><dt><span>evap_2_rate_constant_2 :</span></dt><dd>0.71</dd><dt><span>evap_3_arm_1_final_pow :</span></dt><dd>0.1038</dd><dt><span>evap_3_arm_1_mod_depth_final :</span></dt><dd>0.43</dd><dt><span>evap_3_arm_1_mod_depth_initial :</span></dt><dd>0</dd><dt><span>evap_3_arm_1_start_pow :</span></dt><dd>0.037</dd><dt><span>evap_3_ramp_duration :</span></dt><dd>0.1</dd><dt><span>evap_3_ramp_trunc_value :</span></dt><dd>1.0</dd><dt><span>evap_3_rate_constant_1 :</span></dt><dd>-0.879</dd><dt><span>evap_3_rate_constant_2 :</span></dt><dd>-0.297</dd><dt><span>final_amp :</span></dt><dd>0.0001</dd><dt><span>final_freq :</span></dt><dd>104.0</dd><dt><span>gradCoil_current :</span></dt><dd>0.18</dd><dt><span>gradCoil_current_sg :</span></dt><dd>0</dd><dt><span>imaging_method :</span></dt><dd>in_situ_absorption</dd><dt><span>imaging_pulse_duration :</span></dt><dd>2.5e-05</dd><dt><span>imaging_wavelength :</span></dt><dd>4.21291e-07</dd><dt><span>initial_amp :</span></dt><dd>0.62</dd><dt><span>initial_freq :</span></dt><dd>102.13</dd><dt><span>mod_depth_initial :</span></dt><dd>1.0</dd><dt><span>mot_3d_amp :</span></dt><dd>0.62</dd><dt><span>mot_3d_camera_exposure_time :</span></dt><dd>0.002</dd><dt><span>mot_3d_camera_trigger_duration :</span></dt><dd>0.00025</dd><dt><span>mot_3d_freq :</span></dt><dd>102.13</dd><dt><span>mot_load_duration :</span></dt><dd>2</dd><dt><span>odt_axis_camera_trigger_duration :</span></dt><dd>0.002</dd><dt><span>odt_hold_time_1 :</span></dt><dd>0.01</dd><dt><span>odt_hold_time_2 :</span></dt><dd>0.1</dd><dt><span>odt_hold_time_3 :</span></dt><dd>0.1</dd><dt><span>odt_hold_time_4 :</span></dt><dd>1</dd><dt><span>pow_arm_1 :</span></dt><dd>7</dd><dt><span>pow_arm_2 :</span></dt><dd>0</dd><dt><span>pulse_delay :</span></dt><dd>8e-05</dd><dt><span>push_amp :</span></dt><dd>0.16</dd><dt><span>push_freq :</span></dt><dd>102.75</dd><dt><span>ramp_duration :</span></dt><dd>1</dd><dt><span>recomp_ramp_duration :</span></dt><dd>0.5</dd><dt><span>recomp_ramp_pow_fin_arm_1 :</span></dt><dd>0.1038</dd><dt><span>recomp_ramp_pow_fin_arm_2 :</span></dt><dd>0.09</dd><dt><span>recomp_ramp_pow_ini_arm_1 :</span></dt><dd>0.1038</dd><dt><span>recomp_ramp_pow_ini_arm_2 :</span></dt><dd>0.09</dd><dt><span>save_results :</span></dt><dd>False</dd><dt><span>sin_mod_amplitude :</span></dt><dd>0.0025900000000000003</dd><dt><span>sin_mod_dc_offset :</span></dt><dd>0.037</dd><dt><span>sin_mod_duration :</span></dt><dd>nan</dd><dt><span>sin_mod_freq :</span></dt><dd>nan</dd><dt><span>sin_mod_phase :</span></dt><dd>0.0</dd><dt><span>stern_gerlach_duration :</span></dt><dd>0.001</dd><dt><span>wait_after_2dmot_off :</span></dt><dd>0</dd><dt><span>wait_time_between_images :</span></dt><dd>0.22</dd><dt><span>x_offset :</span></dt><dd>0</dd><dt><span>x_offset_img :</span></dt><dd>0</dd><dt><span>y_offset :</span></dt><dd>0</dd><dt><span>y_offset_img :</span></dt><dd>0</dd><dt><span>z_offset :</span></dt><dd>0.189</dd><dt><span>z_offset_img :</span></dt><dd>0.189</dd><dt><span>runs :</span></dt><dd>[  0.   1.   2.   3.   4.   5.   6.   7.   8.   9.  10.  11.  12.  13.\n",
       "  14.  15.  16.  17.  18.  19.  20.  21.  22.  23.  24.  25.  26.  27.\n",
       "  28.  29.  30.  31.  32.  33.  34.  35.  36.  37.  38.  39.  40.  41.\n",
       "  42.  43.  44.  45.  46.  47.  48.  49.  50.  51.  52.  53.  54.  55.\n",
       "  56.  57.  58.  59.  60.  61.  62.  63.  64.  65.  66.  67.  68.  69.\n",
       "  70.  71.  72.  73.  74.  75.  76.  77.  78.  79.  80.  81.  82.  83.\n",
       "  84.  85.  86.  87.  88.  89.  90.  91.  92.  93.  94.  95.  96.  97.\n",
       "  98.  99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111.\n",
       " 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125.\n",
       " 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139.\n",
       " 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153.\n",
       " 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167.\n",
       " 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181.\n",
       " 182. 183. 184. 185. 186. 187. 188. 189. 190. 191. 192. 193. 194. 195.\n",
       " 196. 197. 198. 199. 200. 201. 202. 203. 204. 205. 206. 207. 208. 209.\n",
       " 210. 211. 212. 213. 214. 215. 216. 217. 218. 219. 220. 221. 222. 223.\n",
       " 224. 225. 226. 227. 228. 229. 230. 231. 232. 233. 234. 235. 236. 237.\n",
       " 238. 239. 240. 241. 242. 243. 244. 245. 246. 247. 248. 249. 250. 251.\n",
       " 252. 253. 254. 255. 256. 257. 258. 259. 260. 261. 262. 263. 264. 265.\n",
       " 266. 267. 268. 269. 270. 271. 272. 273. 274. 275. 276. 277. 278. 279.\n",
       " 280. 281. 282. 283. 284. 285. 286. 287. 288. 289. 290. 291. 292. 293.\n",
       " 294. 295. 296. 297. 298. 299. 300. 301. 302. 303. 304. 305. 306. 307.\n",
       " 308. 309. 310. 311. 312. 313. 314. 315. 316. 317. 318. 319. 320. 321.\n",
       " 322. 323. 324. 325. 326. 327. 328. 329. 330. 331. 332. 333. 334. 335.\n",
       " 336. 337. 338. 339. 340. 341. 342. 343. 344. 345. 346. 347. 348. 349.\n",
       " 350. 351. 352. 353. 354. 355. 356. 357. 358. 359. 360. 361. 362. 363.\n",
       " 364. 365. 366. 367. 368. 369. 370. 371. 372. 373. 374. 375. 376. 377.\n",
       " 378. 379. 380. 381. 382. 383. 384. 385. 386. 387. 388. 389. 390. 391.\n",
       " 392. 393. 394. 395. 396. 397. 398. 399. 400. 401. 402. 403. 404. 405.\n",
       " 406. 407. 408. 409. 410. 411. 412. 413. 414. 415. 416. 417. 418. 419.\n",
       " 420. 421. 422. 423. 424. 425. 426. 427. 428. 429. 430. 431. 432. 433.\n",
       " 434. 435. 436. 437. 438. 439. 440. 441. 442. 443. 444. 445. 446. 447.\n",
       " 448. 449. 450. 451. 452. 453. 454. 455. 456. 457. 458. 459. 460. 461.\n",
       " 462. 463. 464. 465. 466. 467. 468. 469. 470. 471. 472. 473. 474. 475.\n",
       " 476. 477. 478. 479. 480. 481. 482. 483. 484. 485. 486. 487. 488. 489.\n",
       " 490. 491. 492. 493. 494. 495. 496. 497. 498. 499. 500. 501. 502. 503.\n",
       " 504. 505. 506. 507. 508. 509. 510. 511. 512. 513. 514. 515. 516. 517.\n",
       " 518. 519. 520. 521. 522. 523. 524. 525. 526. 527. 528. 529. 530. 531.\n",
       " 532. 533. 534. 535. 536. 537. 538. 539. 540. 541. 542. 543. 544. 545.\n",
       " 546. 547. 548. 549.]</dd><dt><span>scanAxis :</span></dt><dd>[&#x27;runs&#x27;]</dd><dt><span>scanAxisLength :</span></dt><dd>[550.]</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:  (runs: 550)\n",
       "Coordinates:\n",
       "  * runs     (runs) float64 0.0 1.0 2.0 3.0 4.0 ... 546.0 547.0 548.0 549.0\n",
       "Data variables:\n",
       "    runTime  (runs) datetime64[ns] 2023-05-09T14:30:03 ... 2023-05-09T15:56:53\n",
       "Attributes: (12/101)\n",
       "    TOF_free:                          0.02\n",
       "    abs_img_freq:                      110.858\n",
       "    absorption_imaging_flag:           True\n",
       "    backup_data:                       True\n",
       "    blink_off_time:                    nan\n",
       "    blink_on_time:                     nan\n",
       "    ...                                ...\n",
       "    y_offset_img:                      0\n",
       "    z_offset:                          0.189\n",
       "    z_offset_img:                      0.189\n",
       "    runs:                              [  0.   1.   2.   3.   4.   5.   6.   ...\n",
       "    scanAxis:                          ['runs']\n",
       "    scanAxisLength:                    [550.]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i=0\n",
    "runTime = read_hdf5_run_time(filePath, datesetOfGlobal=dataSetOfGlobalDict[dskey[groupList[i]]])\n",
    "runTime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "time = runTime.runTime.to_numpy()\n",
    "time0 = int(time[0])\n",
    "time = np.array(\n",
    "    [\n",
    "        float(value) - time0\n",
    "        for value in time\n",
    "    ]\n",
    ")\n",
    "time = time / time.max() * 2 * np.pi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
       " *\n",
       " */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
       "  --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
       "  --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
       "  --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
       "  --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
       "  --xr-background-color: var(--jp-layout-color0, white);\n",
       "  --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
       "  --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
       "}\n",
       "\n",
       "html[theme=dark],\n",
       "body[data-theme=dark],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: rgba(255, 255, 255, 1);\n",
       "  --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
       "  --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
       "  --xr-border-color: #1F1F1F;\n",
       "  --xr-disabled-color: #515151;\n",
       "  --xr-background-color: #111111;\n",
       "  --xr-background-color-row-even: #111111;\n",
       "  --xr-background-color-row-odd: #313131;\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-array-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: '►';\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: '▼';\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "  padding-bottom: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: '(';\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: ')';\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: ',';\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-index-preview {\n",
       "  grid-column: 2 / 5;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  display: none;\n",
       "  background-color: var(--xr-background-color) !important;\n",
       "  padding-bottom: 5px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data,\n",
       ".xr-index-data-in:checked ~ .xr-index-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-index-name div,\n",
       ".xr-index-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2,\n",
       ".xr-no-icon {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;OD&#x27; (time: 550)&gt;\n",
       "array([ 750.47641876,  738.34281204,  784.41476569,  796.02169322,\n",
       "        952.51855344,  882.92079597,  863.59651678,  866.57709198,\n",
       "        941.99125428,  783.16551019,  946.27689189,  918.33176133,\n",
       "        941.81141492,  947.74774665,  892.61913887,  977.17520626,\n",
       "        945.34126351,  956.52682689,  804.78165476,  939.49484698,\n",
       "        953.56682753,  879.61475127,  846.05592616,  830.90774024,\n",
       "        910.80224254,  839.43361196,  863.23083974,  873.50170576,\n",
       "        850.29285459,  949.59349556,  707.93266373,  946.74069024,\n",
       "        941.71185143,  946.57095286,  914.32343568,  947.09283187,\n",
       "        954.03294364,  784.23261906,  786.97273688,  832.62952621,\n",
       "        903.46885276,  794.84132388,  987.33131008,  920.97693631,\n",
       "        982.49210229,  790.82171889,  796.04783468,  672.41580595,\n",
       "        726.07270248,  709.64654892,  820.34697312,  839.24755133,\n",
       "        830.20821813,  905.60581009,  832.01909227,  614.3819873 ,\n",
       "        723.89815083,  930.88065587,  825.30243762,  842.16853182,\n",
       "        960.03822443,  970.87588969,  867.93951095,  796.77918204,\n",
       "        715.07236109,  867.86554561,  949.15778283,  938.56330193,\n",
       "        857.52360377,  880.71776388,  856.94886599,  923.54732893,\n",
       "        840.56332593,  934.82056594,  938.21743126,  841.27262899,\n",
       "        935.776538  ,  810.94173848,  926.17365109,  746.68729357,\n",
       "...\n",
       "        865.51482127,  833.61692314,  821.20906768,  933.87516973,\n",
       "        810.80092789,  824.63722508,  859.85285532,  913.23783203,\n",
       "        789.32182143,  814.52479359,  843.87902457,  857.31154799,\n",
       "        896.47897516,  872.95758519,  761.01860691,  806.85333498,\n",
       "        947.18607913,  882.95786654,  660.90304299,  779.06534297,\n",
       "        824.68260644,  960.00725562,  931.83023265,  925.32091745,\n",
       "        876.67147414,  808.28701944,  865.12927984,  907.22865863,\n",
       "        849.53390823,  827.70871779,  726.90703872,  878.79705242,\n",
       "        960.28888691,  750.46295033,  903.46216093,  862.60511899,\n",
       "        956.07697944,  881.35524969,  837.32695128,  791.87607618,\n",
       "        811.78036383,  902.4373154 ,  942.28581666,  874.3906838 ,\n",
       "        896.64409276,  787.28302139,  963.13514734,  877.87315412,\n",
       "        833.86614596,  826.5946265 ,  735.16788438,  922.53477054,\n",
       "        880.6268579 ,  867.12639832,  852.01398293,  828.11720597,\n",
       "        891.6310036 ,  807.47838578,  895.25022758,  822.18630467,\n",
       "        943.8055441 ,  845.66585589,  729.57792525,  884.88667118,\n",
       "        796.64506694,  855.18595889,  803.11938466,  832.46778894,\n",
       "        858.2150589 ,  937.40605043,  853.13728532,  910.90015676,\n",
       "        780.99561864,  883.83375992,  804.26394636,  978.32360651,\n",
       "        901.75651529,  884.02352999])\n",
       "Coordinates:\n",
       "  * time     (time) datetime64[ns] 2023-05-09T14:30:03 ... 2023-05-09T15:56:53</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'OD'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>time</span>: 550</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-f0a04964-e324-4797-8c9b-8976d3db2498' class='xr-array-in' type='checkbox' checked><label for='section-f0a04964-e324-4797-8c9b-8976d3db2498' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>750.5 738.3 784.4 796.0 952.5 882.9 ... 883.8 804.3 978.3 901.8 884.0</span></div><div class='xr-array-data'><pre>array([ 750.47641876,  738.34281204,  784.41476569,  796.02169322,\n",
       "        952.51855344,  882.92079597,  863.59651678,  866.57709198,\n",
       "        941.99125428,  783.16551019,  946.27689189,  918.33176133,\n",
       "        941.81141492,  947.74774665,  892.61913887,  977.17520626,\n",
       "        945.34126351,  956.52682689,  804.78165476,  939.49484698,\n",
       "        953.56682753,  879.61475127,  846.05592616,  830.90774024,\n",
       "        910.80224254,  839.43361196,  863.23083974,  873.50170576,\n",
       "        850.29285459,  949.59349556,  707.93266373,  946.74069024,\n",
       "        941.71185143,  946.57095286,  914.32343568,  947.09283187,\n",
       "        954.03294364,  784.23261906,  786.97273688,  832.62952621,\n",
       "        903.46885276,  794.84132388,  987.33131008,  920.97693631,\n",
       "        982.49210229,  790.82171889,  796.04783468,  672.41580595,\n",
       "        726.07270248,  709.64654892,  820.34697312,  839.24755133,\n",
       "        830.20821813,  905.60581009,  832.01909227,  614.3819873 ,\n",
       "        723.89815083,  930.88065587,  825.30243762,  842.16853182,\n",
       "        960.03822443,  970.87588969,  867.93951095,  796.77918204,\n",
       "        715.07236109,  867.86554561,  949.15778283,  938.56330193,\n",
       "        857.52360377,  880.71776388,  856.94886599,  923.54732893,\n",
       "        840.56332593,  934.82056594,  938.21743126,  841.27262899,\n",
       "        935.776538  ,  810.94173848,  926.17365109,  746.68729357,\n",
       "...\n",
       "        865.51482127,  833.61692314,  821.20906768,  933.87516973,\n",
       "        810.80092789,  824.63722508,  859.85285532,  913.23783203,\n",
       "        789.32182143,  814.52479359,  843.87902457,  857.31154799,\n",
       "        896.47897516,  872.95758519,  761.01860691,  806.85333498,\n",
       "        947.18607913,  882.95786654,  660.90304299,  779.06534297,\n",
       "        824.68260644,  960.00725562,  931.83023265,  925.32091745,\n",
       "        876.67147414,  808.28701944,  865.12927984,  907.22865863,\n",
       "        849.53390823,  827.70871779,  726.90703872,  878.79705242,\n",
       "        960.28888691,  750.46295033,  903.46216093,  862.60511899,\n",
       "        956.07697944,  881.35524969,  837.32695128,  791.87607618,\n",
       "        811.78036383,  902.4373154 ,  942.28581666,  874.3906838 ,\n",
       "        896.64409276,  787.28302139,  963.13514734,  877.87315412,\n",
       "        833.86614596,  826.5946265 ,  735.16788438,  922.53477054,\n",
       "        880.6268579 ,  867.12639832,  852.01398293,  828.11720597,\n",
       "        891.6310036 ,  807.47838578,  895.25022758,  822.18630467,\n",
       "        943.8055441 ,  845.66585589,  729.57792525,  884.88667118,\n",
       "        796.64506694,  855.18595889,  803.11938466,  832.46778894,\n",
       "        858.2150589 ,  937.40605043,  853.13728532,  910.90015676,\n",
       "        780.99561864,  883.83375992,  804.26394636,  978.32360651,\n",
       "        901.75651529,  884.02352999])</pre></div></div></li><li class='xr-section-item'><input id='section-48b7aec8-eb02-45cc-a32b-cfda791bcf2f' class='xr-section-summary-in' type='checkbox'  checked><label for='section-48b7aec8-eb02-45cc-a32b-cfda791bcf2f' class='xr-section-summary' >Coordinates: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>time</span></div><div class='xr-var-dims'>(time)</div><div class='xr-var-dtype'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>2023-05-09T14:30:03 ... 2023-05-...</div><input id='attrs-8c7d8736-257d-4634-a606-ae183ed97285' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-8c7d8736-257d-4634-a606-ae183ed97285' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-172876be-c3c8-47bd-81c3-5517ed8455e5' class='xr-var-data-in' type='checkbox'><label for='data-172876be-c3c8-47bd-81c3-5517ed8455e5' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([&#x27;2023-05-09T14:30:03.000000000&#x27;, &#x27;2023-05-09T14:30:11.000000000&#x27;,\n",
       "       &#x27;2023-05-09T14:30:19.000000000&#x27;, ..., &#x27;2023-05-09T15:56:37.000000000&#x27;,\n",
       "       &#x27;2023-05-09T15:56:45.000000000&#x27;, &#x27;2023-05-09T15:56:53.000000000&#x27;],\n",
       "      dtype=&#x27;datetime64[ns]&#x27;)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-d7fccb17-8668-433e-9732-ee85659ac075' class='xr-section-summary-in' type='checkbox'  ><label for='section-d7fccb17-8668-433e-9732-ee85659ac075' class='xr-section-summary' >Indexes: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>time</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-51443323-7ed6-43b0-8d07-b7f5c6291202' class='xr-index-data-in' type='checkbox'/><label for='index-51443323-7ed6-43b0-8d07-b7f5c6291202' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(DatetimeIndex([&#x27;2023-05-09 14:30:03&#x27;, &#x27;2023-05-09 14:30:11&#x27;,\n",
       "               &#x27;2023-05-09 14:30:19&#x27;, &#x27;2023-05-09 14:30:27&#x27;,\n",
       "               &#x27;2023-05-09 14:30:35&#x27;, &#x27;2023-05-09 14:30:43&#x27;,\n",
       "               &#x27;2023-05-09 14:30:52&#x27;, &#x27;2023-05-09 14:31:00&#x27;,\n",
       "               &#x27;2023-05-09 14:31:08&#x27;, &#x27;2023-05-09 14:31:16&#x27;,\n",
       "               ...\n",
       "               &#x27;2023-05-09 15:55:41&#x27;, &#x27;2023-05-09 15:55:49&#x27;,\n",
       "               &#x27;2023-05-09 15:55:57&#x27;, &#x27;2023-05-09 15:56:05&#x27;,\n",
       "               &#x27;2023-05-09 15:56:13&#x27;, &#x27;2023-05-09 15:56:21&#x27;,\n",
       "               &#x27;2023-05-09 15:56:29&#x27;, &#x27;2023-05-09 15:56:37&#x27;,\n",
       "               &#x27;2023-05-09 15:56:45&#x27;, &#x27;2023-05-09 15:56:53&#x27;],\n",
       "              dtype=&#x27;datetime64[ns]&#x27;, name=&#x27;time&#x27;, length=550, freq=None))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-619055c1-9dbb-4e1d-9f14-0b7293d15f72' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-619055c1-9dbb-4e1d-9f14-0b7293d15f72' class='xr-section-summary'  title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'OD' (time: 550)>\n",
       "array([ 750.47641876,  738.34281204,  784.41476569,  796.02169322,\n",
       "        952.51855344,  882.92079597,  863.59651678,  866.57709198,\n",
       "        941.99125428,  783.16551019,  946.27689189,  918.33176133,\n",
       "        941.81141492,  947.74774665,  892.61913887,  977.17520626,\n",
       "        945.34126351,  956.52682689,  804.78165476,  939.49484698,\n",
       "        953.56682753,  879.61475127,  846.05592616,  830.90774024,\n",
       "        910.80224254,  839.43361196,  863.23083974,  873.50170576,\n",
       "        850.29285459,  949.59349556,  707.93266373,  946.74069024,\n",
       "        941.71185143,  946.57095286,  914.32343568,  947.09283187,\n",
       "        954.03294364,  784.23261906,  786.97273688,  832.62952621,\n",
       "        903.46885276,  794.84132388,  987.33131008,  920.97693631,\n",
       "        982.49210229,  790.82171889,  796.04783468,  672.41580595,\n",
       "        726.07270248,  709.64654892,  820.34697312,  839.24755133,\n",
       "        830.20821813,  905.60581009,  832.01909227,  614.3819873 ,\n",
       "        723.89815083,  930.88065587,  825.30243762,  842.16853182,\n",
       "        960.03822443,  970.87588969,  867.93951095,  796.77918204,\n",
       "        715.07236109,  867.86554561,  949.15778283,  938.56330193,\n",
       "        857.52360377,  880.71776388,  856.94886599,  923.54732893,\n",
       "        840.56332593,  934.82056594,  938.21743126,  841.27262899,\n",
       "        935.776538  ,  810.94173848,  926.17365109,  746.68729357,\n",
       "...\n",
       "        865.51482127,  833.61692314,  821.20906768,  933.87516973,\n",
       "        810.80092789,  824.63722508,  859.85285532,  913.23783203,\n",
       "        789.32182143,  814.52479359,  843.87902457,  857.31154799,\n",
       "        896.47897516,  872.95758519,  761.01860691,  806.85333498,\n",
       "        947.18607913,  882.95786654,  660.90304299,  779.06534297,\n",
       "        824.68260644,  960.00725562,  931.83023265,  925.32091745,\n",
       "        876.67147414,  808.28701944,  865.12927984,  907.22865863,\n",
       "        849.53390823,  827.70871779,  726.90703872,  878.79705242,\n",
       "        960.28888691,  750.46295033,  903.46216093,  862.60511899,\n",
       "        956.07697944,  881.35524969,  837.32695128,  791.87607618,\n",
       "        811.78036383,  902.4373154 ,  942.28581666,  874.3906838 ,\n",
       "        896.64409276,  787.28302139,  963.13514734,  877.87315412,\n",
       "        833.86614596,  826.5946265 ,  735.16788438,  922.53477054,\n",
       "        880.6268579 ,  867.12639832,  852.01398293,  828.11720597,\n",
       "        891.6310036 ,  807.47838578,  895.25022758,  822.18630467,\n",
       "        943.8055441 ,  845.66585589,  729.57792525,  884.88667118,\n",
       "        796.64506694,  855.18595889,  803.11938466,  832.46778894,\n",
       "        858.2150589 ,  937.40605043,  853.13728532,  910.90015676,\n",
       "        780.99561864,  883.83375992,  804.26394636,  978.32360651,\n",
       "        901.75651529,  884.02352999])\n",
       "Coordinates:\n",
       "  * time     (time) datetime64[ns] 2023-05-09T14:30:03 ... 2023-05-09T15:56:53"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Ncount_time = xr.DataArray(\n",
    "    data=Ncount,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "Ncount_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1d0be120160>]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 76184 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "Ncount_time.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.0, 70000.0)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 72172 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "Ncount_time_interp = Ncount_time.interp(time=pd.date_range(\"2023-05-09T14:30:03.000000000\", \"2023-05-09T15:56:53.000000000\", periods=500))\n",
    "da_fft = xrft.fft(Ncount_time_interp)\n",
    "da_fft_amp = np.abs(da_fft)\n",
    "# da_fft_amp.isel(freq_time=range(251,370)).plot()\n",
    "da_fft_amp.plot()\n",
    "# plt.xlim([-0.05, 0.05])\n",
    "plt.ylim([0, 7e4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.0, 70000.0)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 63284 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# da_test2.isel(time=range(300)).plot()\n",
    "da_fft = xrft.fft(\n",
    "    Ncount_time.isel(time=range(300)).interp(\n",
    "        time=pd.date_range(\n",
    "            Ncount_time.time[0].item(), Ncount_time.time[299].item(), periods=300\n",
    "            # \"2023-05-09T14:30:03.000000000\", \"2023-05-09T15:10:06.000000000\", periods=300\n",
    "        )\n",
    "    )\n",
    ")\n",
    "# np.abs(da_fft).isel(freq_time=range(151,300)).plot()\n",
    "np.abs(da_fft).plot()\n",
    "# plt.xlim([0, 0.003])\n",
    "plt.ylim([0, 7e4])\n",
    "# plt.yscale(\"log\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 45632 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 55596 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "analyserDataArray = Ncount\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 1001\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "value = np.abs(f)\n",
    "value[int((N-1)/2)] = np.nan\n",
    "value.where(value.time_freq>0).plot()\n",
    "plt.xlim([0, 0.01])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.xlabel('frequency (Hz)')\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analyserDataArray = BEC_Ncount_val\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 1001\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "value = np.abs(f)\n",
    "value[int((N-1)/2)] = np.nan\n",
    "value.where(value.time_freq>0).plot()\n",
    "plt.xlim([0, 0.01])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analyserDataArray = BEC_width_x_val\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 1001\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "value = np.abs(f)\n",
    "value[int((N-1)/2)] = np.nan\n",
    "value.where(value.time_freq>0).plot()\n",
    "plt.xlim([0, 0.01])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analyserDataArray = thermal_width_y_val\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 1001\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "np.abs(f).plot()\n",
    "# plt.xlim([0, 0.01])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analyserDataArray = BEC_center_y_val\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 1001\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "np.abs(f).plot()\n",
    "# plt.xlim([0, 0.01])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analyserDataArray = thermal_center_y_val\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 1001\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "np.abs(f).plot()\n",
    "# plt.xlim([0, 0.01])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analyserDataArray = condensateFraction_value\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 1001\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "np.abs(f).plot()\n",
    "# plt.xlim([0, 0.01])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Close to the BEC transition point, in evaporative cooling 2 with truncation value = 0.77"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "shotNum = \"0015\"\n",
    "filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
    "\n",
    "dataSetDict = {\n",
    "    dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i])\n",
    "    for i in [0]\n",
    "}\n",
    "\n",
    "dataSet = dataSetDict[\"camera_0\"]\n",
    "\n",
    "print_scanAxis(dataSet)\n",
    "\n",
    "scanAxis = get_scanAxis(dataSet)\n",
    "\n",
    "dataSet = auto_rechunk(dataSet)\n",
    "\n",
    "dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
    "\n",
    "imageAnalyser.center = (879, 956)\n",
    "imageAnalyser.span = (200, 200)\n",
    "imageAnalyser.fraction = (0.1, 0.1)\n",
    "\n",
    "dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
    "dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
    "\n",
    "Ncount = imageAnalyser.get_Ncount(dataSet_cropOD).load()\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "Ncount.plot.errorbar(ax=ax, fmt='ob')\n",
    "\n",
    "plt.ylabel('NCount')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "Ncount.plot.errorbar(ax=ax, fmt='ob')\n",
    "plt.ylim([0, 3000])\n",
    "plt.ylabel('NCount')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataSet_cropOD = auto_rechunk(dataSet_cropOD)\n",
    "\n",
    "fitAnalyser = FitAnalyser(\"Gaussian-2D\", fitDim=2)\n",
    "params = fitAnalyser.guess(dataSet_cropOD, dask=\"parallelized\")\n",
    "fitResult = fitAnalyser.fit(dataSet_cropOD, params, dask=\"parallelized\").load()\n",
    "\n",
    "fitValue = fitAnalyser.get_fit_value(fitResult)\n",
    "fitStd = fitAnalyser.get_fit_std(fitResult)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "thermal_Ncount_val = fitValue['amplitude']\n",
    "thermal_Ncount_std = fitStd['amplitude']\n",
    "\n",
    "thermal_width_x_val = fitValue['sigmax']\n",
    "thermal_width_x_std = fitStd['sigmax']\n",
    "thermal_width_y_val = fitValue['sigmay']\n",
    "thermal_width_y_std = fitStd['sigmay']\n",
    "\n",
    "thermal_center_x_val = fitValue['centerx']\n",
    "thermal_center_x_std = fitStd['centerx']\n",
    "thermal_center_y_val = fitValue['centery']\n",
    "thermal_center_y_std = fitStd['centery']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "total_Ncount_val = thermal_Ncount_val\n",
    "total_Ncount_std = thermal_Ncount_std\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "total_Ncount_val.plot.errorbar(ax=ax, yerr=total_Ncount_std, fmt='ob')\n",
    "plt.ylim([0, 3000])\n",
    "plt.ylabel('Ncount from fit')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_width_x_val.plot.errorbar(ax=ax, yerr=thermal_width_x_std, fmt='or')\n",
    "\n",
    "plt.ylabel('X-axis width of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_width_y_val.plot.errorbar(ax=ax, yerr=thermal_width_y_std, fmt='or')\n",
    "\n",
    "plt.ylabel('Y-axis width of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_center_x_val.plot.errorbar(ax=ax, yerr=thermal_center_x_std, fmt='or')\n",
    "\n",
    "plt.ylabel('X-axis center of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_center_y_val.plot.errorbar(ax=ax, yerr=thermal_center_y_std, fmt='or')\n",
    "\n",
    "plt.ylabel('Y-axis center of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "val = Ncount.mean().item()\n",
    "std = Ncount.std().item()\n",
    "print(f'The total Ncount is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = total_Ncount_val.mean().item()\n",
    "std = total_Ncount_val.std().item()\n",
    "print(f'The total Ncount from fit is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_width_x_val.mean().item()\n",
    "std = thermal_width_x_val.std().item()\n",
    "print(f'The x-axis width of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_width_y_val.mean().item()\n",
    "std = thermal_width_y_val.std().item()\n",
    "print(f'The y-axis width of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_center_x_val.mean().item()\n",
    "std = thermal_center_x_val.std().item()\n",
    "print(f'The x-axis center of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_center_y_val.mean().item()\n",
    "std = thermal_center_y_val.std().item()\n",
    "print(f'The y-axis center of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "i=0\n",
    "runTime = read_hdf5_run_time(filePath, datesetOfGlobal=dataSetOfGlobalDict[dskey[groupList[i]]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "time = runTime.runTime.to_numpy()\n",
    "time0 = int(time[0])\n",
    "time = np.array(\n",
    "    [\n",
    "        float(value) - time0\n",
    "        for value in time\n",
    "    ]\n",
    ")\n",
    "time = time / time.max() * 2 * np.pi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analyserDataArray = Ncount\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 701\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "value = np.abs(f)\n",
    "value[int((N-1)/2)] = np.nan\n",
    "value.where(value.time_freq>0).plot()\n",
    "# plt.xlim([0, 0.02])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.xlabel('frequency (Hz)')\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## At the end of ODT loading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "shotNum = \"0020\"\n",
    "filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
    "\n",
    "dataSetDict = {\n",
    "    dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i])\n",
    "    for i in [0]\n",
    "}\n",
    "\n",
    "dataSet = dataSetDict[\"camera_0\"]\n",
    "\n",
    "print_scanAxis(dataSet)\n",
    "\n",
    "scanAxis = get_scanAxis(dataSet)\n",
    "\n",
    "dataSet = auto_rechunk(dataSet)\n",
    "\n",
    "dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
    "\n",
    "imageAnalyser.center = (550, 800)\n",
    "imageAnalyser.span = (900, 1600)\n",
    "imageAnalyser.fraction = (0.1, 0.1)\n",
    "\n",
    "dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
    "dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
    "\n",
    "Ncount = imageAnalyser.get_Ncount(dataSet_cropOD).load()\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "Ncount.plot.errorbar(ax=ax, fmt='ob')\n",
    "\n",
    "plt.ylabel('NCount')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataSet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "Ncount.plot.errorbar(ax=ax, fmt='ob')\n",
    "plt.ylim([0, 150000])\n",
    "plt.ylabel('NCount')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataSet_cropOD = dataSet_cropOD.chunk((1, 900, 1600))\n",
    "dataSet_cropOD"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# dataSet_cropOD = auto_rechunk(dataSet_cropOD)\n",
    "\n",
    "fitAnalyser = FitAnalyser(\"Gaussian-2D\", fitDim=2)\n",
    "params = fitAnalyser.guess(dataSet_cropOD, dask=\"parallelized\")\n",
    "fitResult = fitAnalyser.fit(dataSet_cropOD, params, dask=\"parallelized\").load()\n",
    "\n",
    "fitValue = fitAnalyser.get_fit_value(fitResult)\n",
    "fitStd = fitAnalyser.get_fit_std(fitResult)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "thermal_Ncount_val = fitValue['amplitude']\n",
    "thermal_Ncount_std = fitStd['amplitude']\n",
    "\n",
    "thermal_width_x_val = fitValue['sigmax']\n",
    "thermal_width_x_std = fitStd['sigmax']\n",
    "thermal_width_y_val = fitValue['sigmay']\n",
    "thermal_width_y_std = fitStd['sigmay']\n",
    "\n",
    "thermal_center_x_val = fitValue['centerx']\n",
    "thermal_center_x_std = fitStd['centerx']\n",
    "thermal_center_y_val = fitValue['centery']\n",
    "thermal_center_y_std = fitStd['centery']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "total_Ncount_val = thermal_Ncount_val\n",
    "total_Ncount_std = thermal_Ncount_std\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "total_Ncount_val.plot.errorbar(ax=ax, yerr=total_Ncount_std, fmt='ob')\n",
    "plt.ylim([0, 160000])\n",
    "plt.ylabel('Ncount from fit')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_width_x_val.plot.errorbar(ax=ax, yerr=thermal_width_x_std, fmt='or')\n",
    "\n",
    "plt.ylabel('Y-axis width of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_width_y_val.plot.errorbar(ax=ax, yerr=thermal_width_y_std, fmt='or')\n",
    "\n",
    "plt.ylabel('X-axis width of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_center_x_val.plot.errorbar(ax=ax, yerr=thermal_center_x_std, fmt='or')\n",
    "\n",
    "plt.ylabel('Y-axis center of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "thermal_center_y_val.plot.errorbar(ax=ax, yerr=thermal_center_y_std, fmt='or')\n",
    "\n",
    "plt.ylabel('X-axis center of thermal part')\n",
    "plt.tight_layout()\n",
    "plt.grid(visible=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "val = Ncount.mean().item()\n",
    "std = Ncount.std().item()\n",
    "print(f'The total Ncount is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = total_Ncount_val.mean().item()\n",
    "std = total_Ncount_val.std().item()\n",
    "print(f'The total Ncount from fit is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_width_x_val.mean().item()\n",
    "std = thermal_width_x_val.std().item()\n",
    "print(f'The y-axis width of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_width_y_val.mean().item()\n",
    "std = thermal_width_y_val.std().item()\n",
    "print(f'The x-axis width of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_center_x_val.mean().item()\n",
    "std = thermal_center_x_val.std().item()\n",
    "print(f'The y-axis center of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')\n",
    "\n",
    "val = thermal_center_y_val.mean().item()\n",
    "std = thermal_center_y_val.std().item()\n",
    "print(f'The x-axis center of the thermal part is: {val: .2f} \\u00B1 {std: .2f}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "i=0\n",
    "runTime = read_hdf5_run_time(filePath, datesetOfGlobal=dataSetOfGlobalDict[dskey[groupList[i]]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "time = runTime.runTime.to_numpy()\n",
    "time0 = int(time[0])\n",
    "time = np.array(\n",
    "    [\n",
    "        float(value) - time0\n",
    "        for value in time\n",
    "    ]\n",
    ")\n",
    "time = time / time.max() * 2 * np.pi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analyserDataArray = Ncount\n",
    "\n",
    "analyserDataArray_time = xr.DataArray(\n",
    "    data=analyserDataArray,\n",
    "    dims=[\"time\"],\n",
    "    coords={\n",
    "        \"time\": runTime.runTime.to_numpy(),\n",
    "    }\n",
    ")\n",
    "\n",
    "# desired number of Fourier modes (uniform outputs)\n",
    "N = 701\n",
    "\n",
    "# calculate the transform\n",
    "analyserDataArray_time_array = analyserDataArray_time.to_numpy()\n",
    "analyserDataArray_time_array = np.array(analyserDataArray_time_array, dtype=complex)\n",
    "f = xr.DataArray(\n",
    "    data=finufft.nufft1d1(time, analyserDataArray_time_array, N),\n",
    "    dims=['time_freq'],\n",
    "    coords={\n",
    "        \"time_freq\":np.linspace(-0.125/2,0.125/2,N)\n",
    "    }\n",
    ")\n",
    "\n",
    "value = np.abs(f)\n",
    "value[int((N-1)/2)] = np.nan\n",
    "value.where(value.time_freq>0).plot()\n",
    "# plt.xlim([0, 0.02])\n",
    "# plt.ylim([0, 2000])\n",
    "plt.xlabel('frequency (Hz)')\n",
    "plt.show()\n",
    "\n",
    "mask = xr.DataArray(\n",
    "    data = np.full(runTime.runTime.shape,fill_value=False, dtype=bool),\n",
    "    dims = [\"time\"],\n",
    "    coords = {\n",
    "        \"time\":runTime.runTime.to_numpy()\n",
    "    }\n",
    ")\n",
    "\n",
    "for i in range(len(mask)):\n",
    "    if (int(mask.time[i]) - 1683642540000000000) % 5.4e11 > 3.6e11:\n",
    "        mask[i] = True\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "xr.where(mask, np.nan, analyserDataArray_time).plot.errorbar(fmt='ob')\n",
    "analyserDataArray_time.where(mask).plot.errorbar(fmt='or')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "l = list(np.arange(0.001, 0.025, 0.0005))\n",
    "# l = np.logspace(np.log10(100e-3), np.log10(20), num=20)\n",
    "\n",
    "l = [round(item, 7) for item in l]\n",
    "#random.shuffle(l)\n",
    "\n",
    "print(l)\n",
    "print(len(l))\n",
    "np.mean(l)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ODT 1 Calibration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "v_high = 2.7\n",
    "\"\"\"High Power\"\"\"\n",
    "P_arm1_high = 5.776 * v_high - 0.683\n",
    "\n",
    "v_mid = 0.2076\n",
    "\"\"\"Intermediate Power\"\"\"\n",
    "P_arm1_mid = 5.815 * v_mid - 0.03651\n",
    "\n",
    "v_low = 0.0587\n",
    "\"\"\"Low Power\"\"\"\n",
    "P_arm1_low = 5271 * v_low - 27.5\n",
    "\n",
    "print(round(P_arm1_high, 3))\n",
    "print(round(P_arm1_mid, 3))\n",
    "print(round(P_arm1_low, 3))"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ODT 2 Power Calibration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "v = 0.7607\n",
    "P_arm2 = 2.302 * v - 0.06452\n",
    "print(round(P_arm2, 3))"
   ]
  }
 ],
 "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"
  },
  "vscode": {
   "interpreter": {
    "hash": "c05913ad4f24fdc6b2418069394dc5835b1981849b107c9ba6df693aafd66650"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
