{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23852 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import mpmath as mp\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "def polylog(power, numerator):\n",
    "    \n",
    "    order = 100\n",
    "    \n",
    "    dataShape = numerator.shape\n",
    "    numerator = np.tile(numerator, (order, 1))\n",
    "    numerator = np.power(numerator.T, np.arange(1, order+1)).T\n",
    "\n",
    "    denominator = np.arange(1, order+1)\n",
    "    denominator = np.tile(denominator, (dataShape[0], 1))\n",
    "    denominator = denominator.T\n",
    "\n",
    "    data = numerator/ np.power(denominator, power)\n",
    "\n",
    "    return np.sum(data, axis=0)\n",
    "\n",
    "x = np.linspace(0, 1, 51)\n",
    "y1 = polylog(2, x)\n",
    "y2 = [float(mp.polylog(2, i).real) for i in x]\n",
    "\n",
    "plt.figure()\n",
    "\n",
    "plt.plot(x, y1, 'r')\n",
    "plt.plot(x, y2, 'b')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": [
    "from lmfit.lineshapes import (not_zero, breit_wigner, damped_oscillator, dho, doniach,\n",
    "                              expgaussian, exponential, gaussian, gaussian2d,\n",
    "                              linear, lognormal, lorentzian, moffat, parabolic,\n",
    "                              pearson7, powerlaw, pvoigt, rectangle, sine,\n",
    "                              skewed_gaussian, skewed_voigt, split_lorentzian, step,\n",
    "                              students_t, thermal_distribution, tiny, voigt)\n",
    "\n",
    "def polylog(power, numerator):\n",
    "    \n",
    "    order = 100\n",
    "    \n",
    "    dataShape = numerator.shape\n",
    "    numerator = np.tile(numerator, (order, 1))\n",
    "    numerator = np.power(numerator.T, np.arange(1, order+1)).T\n",
    "\n",
    "    denominator = np.arange(1, order+1)\n",
    "    denominator = np.tile(denominator, (dataShape[0], 1))\n",
    "    denominator = denominator.T\n",
    "\n",
    "    data = numerator/ np.power(denominator, power)\n",
    "\n",
    "    return np.sum(data, axis=0)\n",
    "\n",
    "def polylog2_2d(x, y=0.0, centerx=0.0, centery=0.0, amplitude=1.0, sigmax=1.0, sigmay=1.0): \n",
    "    ## Approximation of the polylog function with 2D gaussian as argument. -> discribes the thermal part of the cloud\n",
    "    return amplitude / 2 / 5.403642092095097 / max(tiny, sigmax * sigmay) * polylog(2, np.exp( -((x-centerx)**2/(2 * (sigmax)**2))-((y-centery)**2/( 2 * (sigmay)**2)) ))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5.403642092095097\n"
     ]
    }
   ],
   "source": [
    "from scipy import special\n",
    "\n",
    "sum = 0\n",
    "for i in range(1,20000):\n",
    "    sum += 1/i**4 * special.gamma(1/2/i)**2\n",
    "    \n",
    "print(sum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.0"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[1] - x[0] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8405962721688879"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.linspace(-100, 100, 101)\n",
    "y = np.linspace(-100, 100, 101)\n",
    "\n",
    "X, Y = np.meshgrid(x, y)\n",
    "X = X.flatten()\n",
    "Y = Y.flatten()\n",
    "Z = polylog2_2d(x=X, y=Y).reshape(101, 101)\n",
    "\n",
    "np.sum(Z)"
   ]
  },
  {
   "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 glob\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, read_csv_file\n",
    "from Analyser.ImagingAnalyser import ImageAnalyser\n",
    "from Analyser.FitAnalyser import FitAnalyser\n",
    "from Analyser.FitAnalyser import ThomasFermi2dModel, DensityProfileBEC2dModel, Polylog22dModel\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": [
    "# Import supporting package"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import xarray as xr\n",
    "import numpy as np\n",
    "\n",
    "from uncertainties import ufloat\n",
    "from uncertainties import unumpy as unp\n",
    "from uncertainties import umath\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from DataContainer.ReadData import read_hdf5_file\n",
    "from Analyser.ImagingAnalyser import ImageAnalyser\n",
    "from Analyser.FitAnalyser import FitAnalyser\n",
    "from Analyser.FitAnalyser import ThomasFermi2dModel, DensityProfileBEC2dModel, Polylog22dModel\n",
    "from Analyser.FitAnalyser import NewFitModel\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": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\data\\AppData\\Roaming\\Python\\Python39\\site-packages\\distributed\\node.py:182: UserWarning: Port 8787 is already in use.\n",
      "Perhaps you already have a cluster running?\n",
      "Hosting the HTTP server on port 52475 instead\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "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-5ac7f000-261b-11ee-9f6c-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:52475/status\" target=\"_blank\">http://127.0.0.1:52475/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;\">c80cced4</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:52475/status\" target=\"_blank\">http://127.0.0.1:52475/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> 60\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-0363aa80-9ca7-4bd2-8096-e563f44991c3</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:52478\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:52475/status\" target=\"_blank\">http://127.0.0.1:52475/status</a>\n",
       "                    </td>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Total threads:</strong> 60\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:52506\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 10\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52509/status\" target=\"_blank\">http://127.0.0.1:52509/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:52481\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-bwtzfry2\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:52512\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 10\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52513/status\" target=\"_blank\">http://127.0.0.1:52513/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:52482\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-mp7n6m76\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:52515\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 10\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52516/status\" target=\"_blank\">http://127.0.0.1:52516/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:52483\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-co90qahq\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:52518\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 10\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52519/status\" target=\"_blank\">http://127.0.0.1:52519/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:52484\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-4p3qclmm\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:52521\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 10\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52522/status\" target=\"_blank\">http://127.0.0.1:52522/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:52485\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-jl88pafx\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:52507\n",
       "                        </td>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Total threads: </strong> 10\n",
       "                        </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <td style=\"text-align: left;\">\n",
       "                            <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52508/status\" target=\"_blank\">http://127.0.0.1:52508/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:52486\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-lczd_jce\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:52478' processes=6 threads=60, memory=55.88 GiB>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from dask.distributed import Client\n",
    "client = Client(n_workers=6, threads_per_worker=10, processes=True, memory_limit='10GB')\n",
    "client"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set global path for experiment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# filepath = \"//DyLabNAS/Data/Evaporative_Cooling/2023/05/03/0043/*.h5\"\n",
    "# filepath = \"//DyLabNAS/Data/Evaporative_Cooling/2023/04/18/0003/2023-04-18_0003_Evaporative_Cooling_000.h5\"\n",
    "\n",
    "# filepath = \"//DyLabNAS/Data/Repetition_scan/2023/04/21/0002/*.h5\"\n",
    "\n",
    "# filepath = r\"./testData/0002/*.h5\"\n",
    "\n",
    "# filepath = r\"./testData/0002/2023-04-21_0002_Evaporative_Cooling_0.h5\"\n",
    "\n",
    "# filepath = r'd:/Jianshun Gao/Simulations/analyseScripts/testData/0002/2023-04-21_0002_Evaporative_Cooling_0.h5'\n",
    "\n",
    "# filepath = \"//DyLabNAS/Data/Evaporative_Cooling/2023/04/18/0003/*.h5\"\n",
    "\n",
    "filepath = \"//DyLabNAS/Data/Evaporative_Cooling/2023/05/04/0000/*.h5\"\n",
    "\n",
    "# filepath = './result_from_experiment/2023-04-24/0013/2023-04-24_0013_Evaporative_Cooling_13.h5'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "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_1\",\n",
    "    \"images/ODT_1_Axis_Camera/in_situ_absorption\": \"camera_2\",\n",
    "    \"images/ODT_2_Axis_Camera/in_situ_absorption\": \"camera_3\",\n",
    "}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "img_dir = '//DyLabNAS/Data/'\n",
    "SequenceName = \"Evaporative_Cooling\" + \"/\"\n",
    "folderPath = img_dir + SequenceName + '2023/05/23'# get_date()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# An example for one experimental run"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "f:\\Jianshun\\analyseScript\\DataContainer\\ReadData.py:234: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n",
      "  if not key in datesetOfGlobal.scanAxis\n"
     ]
    },
    {
     "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:     (y: 1200, x: 1920)\n",
       "Dimensions without coordinates: y, x\n",
       "Data variables:\n",
       "    atoms       (y, x) uint16 dask.array&lt;chunksize=(1200, 1920), meta=np.ndarray&gt;\n",
       "    background  (y, x) uint16 dask.array&lt;chunksize=(1200, 1920), meta=np.ndarray&gt;\n",
       "    dark        (y, x) uint16 dask.array&lt;chunksize=(1200, 1920), meta=np.ndarray&gt;\n",
       "    shotNum     &lt;U2 &#x27;11&#x27;\n",
       "    OD          (y, x) float64 dask.array&lt;chunksize=(1200, 1920), meta=np.ndarray&gt;\n",
       "Attributes: (12/96)\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:                          0\n",
       "    y_offset_img:                      0\n",
       "    z_offset:                          0.189\n",
       "    z_offset_img:                      0.189\n",
       "    scanAxis:                          []\n",
       "    scanAxisLength:                    []</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-ec5b96ec-3fbd-41ed-93ff-44307cde3390' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-ec5b96ec-3fbd-41ed-93ff-44307cde3390' class='xr-section-summary'  title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span>y</span>: 1200</li><li><span>x</span>: 1920</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-baf349f6-ffc6-4810-a176-13e9f16ba25b' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-baf349f6-ffc6-4810-a176-13e9f16ba25b' class='xr-section-summary'  title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-61a52fcb-e121-4c08-b890-1be565dbae2f' class='xr-section-summary-in' type='checkbox'  checked><label for='section-61a52fcb-e121-4c08-b890-1be565dbae2f' class='xr-section-summary' >Data variables: <span>(5)</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>atoms</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>uint16</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1200, 1920), meta=np.ndarray&gt;</div><input id='attrs-25c95ac6-37ef-4466-8fba-b9d0998dec05' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-25c95ac6-37ef-4466-8fba-b9d0998dec05' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-13ef18e5-221b-48af-93de-6c0a04ad61e5' class='xr-var-data-in' type='checkbox'><label for='data-13ef18e5-221b-48af-93de-6c0a04ad61e5' 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'><dt><span>IMAGE_SUBCLASS :</span></dt><dd>IMAGE_GRAYSCALE</dd><dt><span>IMAGE_VERSION :</span></dt><dd>1.2</dd><dt><span>IMAGE_WHITE_IS_ZERO :</span></dt><dd>0</dd></dl></div><div class='xr-var-data'><table>\n",
       "    <tr>\n",
       "        <td>\n",
       "            <table style=\"border-collapse: collapse;\">\n",
       "                <thead>\n",
       "                    <tr>\n",
       "                        <td> </td>\n",
       "                        <th> Array </th>\n",
       "                        <th> Chunk </th>\n",
       "                    </tr>\n",
       "                </thead>\n",
       "                <tbody>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Bytes </th>\n",
       "                        <td> 4.39 MiB </td>\n",
       "                        <td> 4.39 MiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (1200, 1920) </td>\n",
       "                        <td> (1200, 1920) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 1 chunks in 2 graph layers </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Data type </th>\n",
       "                        <td colspan=\"2\"> uint16 numpy.ndarray </td>\n",
       "                    </tr>\n",
       "                </tbody>\n",
       "            </table>\n",
       "        </td>\n",
       "        <td>\n",
       "        <svg width=\"170\" height=\"125\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"75\" x2=\"120\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 120.0,0.0 120.0,75.0 0.0,75.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"60.000000\" y=\"95.000000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1920</text>\n",
       "  <text x=\"140.000000\" y=\"37.500000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,37.500000)\">1200</text>\n",
       "</svg>\n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>background</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>uint16</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1200, 1920), meta=np.ndarray&gt;</div><input id='attrs-d2313912-491a-48a5-8d85-3992f8816257' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-d2313912-491a-48a5-8d85-3992f8816257' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-14c4d7f0-6ed5-43f8-ac87-7dade8ec08b2' class='xr-var-data-in' type='checkbox'><label for='data-14c4d7f0-6ed5-43f8-ac87-7dade8ec08b2' 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'><dt><span>IMAGE_SUBCLASS :</span></dt><dd>IMAGE_GRAYSCALE</dd><dt><span>IMAGE_VERSION :</span></dt><dd>1.2</dd><dt><span>IMAGE_WHITE_IS_ZERO :</span></dt><dd>0</dd></dl></div><div class='xr-var-data'><table>\n",
       "    <tr>\n",
       "        <td>\n",
       "            <table style=\"border-collapse: collapse;\">\n",
       "                <thead>\n",
       "                    <tr>\n",
       "                        <td> </td>\n",
       "                        <th> Array </th>\n",
       "                        <th> Chunk </th>\n",
       "                    </tr>\n",
       "                </thead>\n",
       "                <tbody>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Bytes </th>\n",
       "                        <td> 4.39 MiB </td>\n",
       "                        <td> 4.39 MiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (1200, 1920) </td>\n",
       "                        <td> (1200, 1920) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 1 chunks in 2 graph layers </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Data type </th>\n",
       "                        <td colspan=\"2\"> uint16 numpy.ndarray </td>\n",
       "                    </tr>\n",
       "                </tbody>\n",
       "            </table>\n",
       "        </td>\n",
       "        <td>\n",
       "        <svg width=\"170\" height=\"125\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"75\" x2=\"120\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 120.0,0.0 120.0,75.0 0.0,75.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"60.000000\" y=\"95.000000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1920</text>\n",
       "  <text x=\"140.000000\" y=\"37.500000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,37.500000)\">1200</text>\n",
       "</svg>\n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>dark</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>uint16</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1200, 1920), meta=np.ndarray&gt;</div><input id='attrs-ffd44c81-646b-4564-b1fe-05a154f3a96b' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-ffd44c81-646b-4564-b1fe-05a154f3a96b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-eade5bec-ce4b-4846-8277-603280226d6f' class='xr-var-data-in' type='checkbox'><label for='data-eade5bec-ce4b-4846-8277-603280226d6f' 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'><dt><span>IMAGE_SUBCLASS :</span></dt><dd>IMAGE_GRAYSCALE</dd><dt><span>IMAGE_VERSION :</span></dt><dd>1.2</dd><dt><span>IMAGE_WHITE_IS_ZERO :</span></dt><dd>0</dd></dl></div><div class='xr-var-data'><table>\n",
       "    <tr>\n",
       "        <td>\n",
       "            <table style=\"border-collapse: collapse;\">\n",
       "                <thead>\n",
       "                    <tr>\n",
       "                        <td> </td>\n",
       "                        <th> Array </th>\n",
       "                        <th> Chunk </th>\n",
       "                    </tr>\n",
       "                </thead>\n",
       "                <tbody>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Bytes </th>\n",
       "                        <td> 4.39 MiB </td>\n",
       "                        <td> 4.39 MiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (1200, 1920) </td>\n",
       "                        <td> (1200, 1920) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 1 chunks in 2 graph layers </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Data type </th>\n",
       "                        <td colspan=\"2\"> uint16 numpy.ndarray </td>\n",
       "                    </tr>\n",
       "                </tbody>\n",
       "            </table>\n",
       "        </td>\n",
       "        <td>\n",
       "        <svg width=\"170\" height=\"125\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"75\" x2=\"120\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 120.0,0.0 120.0,75.0 0.0,75.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"60.000000\" y=\"95.000000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1920</text>\n",
       "  <text x=\"140.000000\" y=\"37.500000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,37.500000)\">1200</text>\n",
       "</svg>\n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>shotNum</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>&lt;U2</div><div class='xr-var-preview xr-preview'>&#x27;11&#x27;</div><input id='attrs-c809af6a-bccf-45f5-bbe1-aa233c8fcfab' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-c809af6a-bccf-45f5-bbe1-aa233c8fcfab' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-9f84c873-2e2c-466f-8ba9-0b2fdde93380' class='xr-var-data-in' type='checkbox'><label for='data-9f84c873-2e2c-466f-8ba9-0b2fdde93380' 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;11&#x27;, dtype=&#x27;&lt;U2&#x27;)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>OD</span></div><div class='xr-var-dims'>(y, x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1200, 1920), meta=np.ndarray&gt;</div><input id='attrs-7f76e601-6ec1-48c3-b28a-de60fb1da3a6' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-7f76e601-6ec1-48c3-b28a-de60fb1da3a6' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-80ae0948-0fc2-4a48-8232-d9376f5ac77b' class='xr-var-data-in' type='checkbox'><label for='data-80ae0948-0fc2-4a48-8232-d9376f5ac77b' 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'><dt><span>IMAGE_SUBCLASS :</span></dt><dd>IMAGE_GRAYSCALE</dd><dt><span>IMAGE_VERSION :</span></dt><dd>1.2</dd><dt><span>IMAGE_WHITE_IS_ZERO :</span></dt><dd>0</dd></dl></div><div class='xr-var-data'><table>\n",
       "    <tr>\n",
       "        <td>\n",
       "            <table style=\"border-collapse: collapse;\">\n",
       "                <thead>\n",
       "                    <tr>\n",
       "                        <td> </td>\n",
       "                        <th> Array </th>\n",
       "                        <th> Chunk </th>\n",
       "                    </tr>\n",
       "                </thead>\n",
       "                <tbody>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Bytes </th>\n",
       "                        <td> 17.58 MiB </td>\n",
       "                        <td> 17.58 MiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (1200, 1920) </td>\n",
       "                        <td> (1200, 1920) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 1 chunks in 16 graph layers </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Data type </th>\n",
       "                        <td colspan=\"2\"> float64 numpy.ndarray </td>\n",
       "                    </tr>\n",
       "                </tbody>\n",
       "            </table>\n",
       "        </td>\n",
       "        <td>\n",
       "        <svg width=\"170\" height=\"125\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"75\" x2=\"120\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 120.0,0.0 120.0,75.0 0.0,75.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"60.000000\" y=\"95.000000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1920</text>\n",
       "  <text x=\"140.000000\" y=\"37.500000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,140.000000,37.500000)\">1200</text>\n",
       "</svg>\n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li></ul></div></li><li class='xr-section-item'><input id='section-af699151-4f5c-49c7-bb0d-93998f824fa5' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-af699151-4f5c-49c7-bb0d-93998f824fa5' class='xr-section-summary'  title='Expand/collapse section'>Indexes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-6a5d30f7-7f90-46f2-b6a2-e6898a477881' class='xr-section-summary-in' type='checkbox'  ><label for='section-6a5d30f7-7f90-46f2-b6a2-e6898a477881' class='xr-section-summary' >Attributes: <span>(96)</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.2812</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</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</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>8e-05</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>4</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.25</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>runs :</span></dt><dd>1</dd><dt><span>save_results :</span></dt><dd>False</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>scanAxis :</span></dt><dd>[]</dd><dt><span>scanAxisLength :</span></dt><dd>[]</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:     (y: 1200, x: 1920)\n",
       "Dimensions without coordinates: y, x\n",
       "Data variables:\n",
       "    atoms       (y, x) uint16 dask.array<chunksize=(1200, 1920), meta=np.ndarray>\n",
       "    background  (y, x) uint16 dask.array<chunksize=(1200, 1920), meta=np.ndarray>\n",
       "    dark        (y, x) uint16 dask.array<chunksize=(1200, 1920), meta=np.ndarray>\n",
       "    shotNum     <U2 '11'\n",
       "    OD          (y, x) float64 dask.array<chunksize=(1200, 1920), meta=np.ndarray>\n",
       "Attributes: (12/96)\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:                          0\n",
       "    y_offset_img:                      0\n",
       "    z_offset:                          0.189\n",
       "    z_offset_img:                      0.189\n",
       "    scanAxis:                          []\n",
       "    scanAxisLength:                    []"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "shotNum = \"0069\"\n",
    "filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
    "# filePath = \"//DyLabNAS/Data/Evaporative_Cooling/2023/05/12/0065/*.h5\"\n",
    "filePath = './result_from_experiment/2023-04-24/0013/2023-04-24_0013_Evaporative_Cooling_11.h5'\n",
    "\n",
    "dataSetDict = {\n",
    "    dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i])\n",
    "    for i in [0] # range(len(groupList))\n",
    "}\n",
    "\n",
    "dataSet = dataSetDict[\"camera_1\"]\n",
    "dataSet = swap_xy(dataSet)\n",
    "\n",
    "scanAxis = get_scanAxis(dataSet)\n",
    "\n",
    "dataSet = auto_rechunk(dataSet)\n",
    "\n",
    "dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
    "\n",
    "dataSet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "selected = np.zeros((2, 2))\n",
    "a =  xr.DataArray(\n",
    "                data=selected,\n",
    "                dims=[\"x\", \"y\"],\n",
    "                coords=dict(\n",
    "                    x=np.arange(np.shape(selected)[0]),\n",
    "                    y=np.arange(np.shape(selected)[1]),\n",
    "                )\n",
    "            )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "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:           (fileNum: 1, phony_dim_0: 59, phony_dim_1: 0)\n",
       "Dimensions without coordinates: fileNum, phony_dim_0, phony_dim_1\n",
       "Data variables:\n",
       "    connection table  (fileNum, phony_dim_0) [(&#x27;name&#x27;, &#x27;S256&#x27;), (&#x27;class&#x27;, &#x27;S256&#x27;), (&#x27;parent&#x27;, &#x27;S256&#x27;), (&#x27;parent port&#x27;, &#x27;S256&#x27;), (&#x27;unit conversion class&#x27;, &#x27;S256&#x27;), (&#x27;unit conversion params&#x27;, &#x27;O&#x27;), (&#x27;BLACS_connection&#x27;, &#x27;S9&#x27;), (&#x27;properties&#x27;, &#x27;O&#x27;)] dask.array&lt;chunksize=(1, 59), meta=np.ndarray&gt;\n",
       "    script            (fileNum) &lt;U7544 &#x27;from labscript import *\\nfrom labscri...\n",
       "    time_markers      (fileNum, phony_dim_1) [(&#x27;label&#x27;, &#x27;S256&#x27;), (&#x27;time&#x27;, &#x27;&lt;f8&#x27;), (&#x27;color&#x27;, &#x27;&lt;i4&#x27;, (1, 3))] dask.array&lt;chunksize=(1, 0), meta=np.ndarray&gt;\n",
       "    waits             (fileNum, phony_dim_1) [(&#x27;label&#x27;, &#x27;S256&#x27;), (&#x27;time&#x27;, &#x27;&lt;f8&#x27;), (&#x27;timeout&#x27;, &#x27;&lt;f8&#x27;)] dask.array&lt;chunksize=(1, 0), meta=np.ndarray&gt;\n",
       "Attributes:\n",
       "    n_runs:           12\n",
       "    run number:       11\n",
       "    run time:         20230424T183333\n",
       "    script_basename:  Evaporative_Cooling\n",
       "    sequence_date:    2023-04-24\n",
       "    sequence_id:      20230424T183145_Evaporative_Cooling\n",
       "    sequence_index:   13</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-df0fb99b-2e32-443a-8abc-37d1cfce576a' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-df0fb99b-2e32-443a-8abc-37d1cfce576a' class='xr-section-summary'  title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span>fileNum</span>: 1</li><li><span>phony_dim_0</span>: 59</li><li><span>phony_dim_1</span>: 0</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-d7da5bd2-8200-4a86-bebc-3bdd2d5c29d0' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-d7da5bd2-8200-4a86-bebc-3bdd2d5c29d0' class='xr-section-summary'  title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-90f2bb5c-fcfd-431e-8352-bce55b32b20d' class='xr-section-summary-in' type='checkbox'  checked><label for='section-90f2bb5c-fcfd-431e-8352-bce55b32b20d' class='xr-section-summary' >Data variables: <span>(4)</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>connection table</span></div><div class='xr-var-dims'>(fileNum, phony_dim_0)</div><div class='xr-var-dtype'>[(&#x27;name&#x27;, &#x27;S256&#x27;), (&#x27;class&#x27;, &#x27;S256&#x27;), (&#x27;parent&#x27;, &#x27;S256&#x27;), (&#x27;parent port&#x27;, &#x27;S256&#x27;), (&#x27;unit conversion class&#x27;, &#x27;S256&#x27;), (&#x27;unit conversion params&#x27;, &#x27;O&#x27;), (&#x27;BLACS_connection&#x27;, &#x27;S9&#x27;), (&#x27;properties&#x27;, &#x27;O&#x27;)]</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1, 59), meta=np.ndarray&gt;</div><input id='attrs-3ab7a604-2517-460d-a0e1-481bd0381665' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-3ab7a604-2517-460d-a0e1-481bd0381665' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-5c5dbfe0-052d-42b1-9858-b77b261205b8' class='xr-var-data-in' type='checkbox'><label for='data-5c5dbfe0-052d-42b1-9858-b77b261205b8' 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'><dt><span>master_pseudoclock :</span></dt><dd>prawn</dd></dl></div><div class='xr-var-data'><table>\n",
       "    <tr>\n",
       "        <td>\n",
       "            <table style=\"border-collapse: collapse;\">\n",
       "                <thead>\n",
       "                    <tr>\n",
       "                        <td> </td>\n",
       "                        <th> Array </th>\n",
       "                        <th> Chunk </th>\n",
       "                    </tr>\n",
       "                </thead>\n",
       "                <tbody>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Bytes </th>\n",
       "                        <td> 75.19 kiB </td>\n",
       "                        <td> 75.19 kiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (1, 59) </td>\n",
       "                        <td> (1, 59) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 1 chunks in 3 graph layers </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Data type </th>\n",
       "                        <td colspan=\"2\"> [('name', 'S256'), ('class', 'S256'), ('parent', 'S256'), ('parent port', 'S256'), ('unit conversion class', 'S256'), ('unit conversion params', 'O'), ('BLACS_connection', 'S9'), ('properties', 'O')] numpy.ndarray </td>\n",
       "                    </tr>\n",
       "                </tbody>\n",
       "            </table>\n",
       "        </td>\n",
       "        <td>\n",
       "        <svg width=\"170\" height=\"78\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"28\" x2=\"120\" y2=\"28\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"28\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"28\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 120.0,0.0 120.0,28.11425155255148 0.0,28.11425155255148\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"60.000000\" y=\"48.114252\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >59</text>\n",
       "  <text x=\"140.000000\" y=\"14.057126\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,14.057126)\">1</text>\n",
       "</svg>\n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>script</span></div><div class='xr-var-dims'>(fileNum)</div><div class='xr-var-dtype'>&lt;U7544</div><div class='xr-var-preview xr-preview'>&#x27;from labscript import *\\nfrom l...</div><input id='attrs-a5f506c9-a282-44ca-b34b-38a5510ec73d' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-a5f506c9-a282-44ca-b34b-38a5510ec73d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ea2e991d-94bd-40ca-a7e9-8724e449bc2b' class='xr-var-data-in' type='checkbox'><label for='data-ea2e991d-94bd-40ca-a7e9-8724e449bc2b' 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'><dt><span>name :</span></dt><dd>Evaporative_Cooling.py</dd><dt><span>path :</span></dt><dd>C:\\Users\\control\\labscript-suite\\userlib\\labscriptlib\\DyBEC\\Sequences</dd></dl></div><div class='xr-var-data'><pre>array([&#x27;from labscript import *\\nfrom labscript_utils import import_or_reload\\nimport_or_reload(\\&#x27;labscriptlib.DyBEC.connection_table\\&#x27;)\\n\\nfrom labscriptlib.DyBEC.Subsequences.MOT import *\\nfrom labscriptlib.DyBEC.Subsequences.ODT import *\\nfrom labscriptlib.DyBEC.Subsequences.SequenceControl import *\\nfrom labscriptlib.DyBEC.Subsequences.Manipulations import *\\n\\n&quot;&quot;&quot;\\ndifferent parameters:\\nTOF: Duration of time-of-flight\\nimaging_pulse_duration: Duration of imaging pulse (controlled by the RF switch)\\nmot_3d_camera_trigger_duration: trigger duration for the camera\\nwait_time_between_images: lapsed time between taking two successive images (e.g. \\&#x27;with atoms\\&#x27; and \\&#x27;without atoms\\&#x27;)\\npulse_delay: delay for the imaging pulse (with respect to the exposure trigger)\\n&quot;&quot;&quot;\\n\\nstart()\\n\\nt0 = 1e-3\\n\\nt  = reinitialise(t0)\\n\\n&quot;&quot;&quot;Switch on the 2D MOT, 3D MOT and push beam&quot;&quot;&quot;\\nMOT_2D_Shutter.go_high(t)\\nMOT_3D_Shutter.go_high(t)\\nPush_Beam_Red_Shutter.go_high(t) ## red push shutter on \\n\\nMOT_Grad_Coil_Switch.go_high(t)\\nMOT_CompX_Coil_Switch.go_high(t)\\nMOT_CompY_Coil_Switch.go_high(t)\\nMOT_CompZ_Coil_Switch.go_high(t)\\n\\nt += 5e-3\\n\\n&quot;&quot;&quot;Load 3D MOT from 2D MOT with push&quot;&quot;&quot;\\nMOT_3D_RF_Switch.go_high(t) \\nPush_Beam_Red_Switch.go_high(t) ## red push switch on\\n\\nt += load_mot3d(t)\\n\\n&quot;&quot;&quot;Switch off the 2D MOT and the push beam&quot;&quot;&quot;\\nPush_Beam_Red_Switch.go_low(t) ## red push switch off\\nPush_Beam_Red_Shutter.go_low(t) ## red push shutter off\\nMOT_2D_Shutter.go_low(t)\\n\\n&quot;&quot;&quot;Set power ODT1, ODT2, and modulation of ODT1&quot;&quot;&quot;\\nset_ODT_power(t)\\nset_modulation(t)\\n\\n&quot;&quot;&quot;MOT Compression&quot;&quot;&quot;\\nt += compress_mot3d(t)\\n\\n&quot;&quot;&quot;Switch on ODT1&quot;&quot;&quot;\\nCDT1_Switch.go_high(t)\\n\\nt += cmot_hold\\n\\nMOT_3D_RF_Switch.go_low(t)\\nMOT_3D_Shutter.go_low(t)\\nMOT_Grad_Coil_Switch.go_low(t)\\n\\n&quot;&quot;&quot;Set the offset magnetic field in x, y and z directions&quot;&quot;&quot;\\nt += odt_hold_time_1\\nset_offset_mag_field(t, x_offset, y_offset, z_offset)\\nt += odt_hold_time_2\\n\\n&quot;&quot;&quot;EVAPORATION 1&quot;&quot;&quot;\\n&quot;&quot;&quot;Ramp down modulation and power of ODT1, switch on and ramp up power of ODT2&quot;&quot;&quot;\\nCDT2_Switch.go_high(t)\\nramp_on_arm_2(t + 1, evap_1_arm_2_ramp_duration, evap_1_arm_2_start_pow, evap_1_arm_2_final_pow)\\nt += ramp_modulation_and_power(t, evap_1_arm_1_mod_ramp_duration, evap_1_arm_1_pow_ramp_duration, evap_1_arm_1_mod_depth_initial,\\n                               evap_1_arm_1_mod_depth_final, evap_1_arm_1_start_pow, evap_1_arm_1_final_pow, evap_1_rate_constant_1, \\n                               evap_1_rate_constant_2, evap_1_mod_ramp_trunc_value, evap_1_pow_ramp_trunc_value)\\n\\n&quot;&quot;&quot;EVAPORATION 2&quot;&quot;&quot;\\n&quot;&quot;&quot;Evaporation in the crossed ODT: ramp down the power of ODT1 &amp; ODT2 simultaneously&quot;&quot;&quot;\\n# t += odt_hold_time_3\\nt += ramp_cODT(t, evap_2_ramp_duration, evap_2_arm_1_start_pow, evap_2_arm_1_final_pow, evap_2_arm_2_start_pow, evap_2_arm_2_final_pow,\\n               evap_2_rate_constant_1, evap_2_rate_constant_2, evap_2_ramp_trunc_value)\\n\\n&quot;&quot;&quot;EVAPORATION 3&quot;&quot;&quot;\\n&quot;&quot;&quot;Ramp back on modulation and power of ODT1&quot;&quot;&quot;\\n# t += ramp_modulation_and_power(t, evap_3_ramp_duration, evap_3_ramp_duration, evap_3_arm_1_mod_depth_initial, evap_3_arm_1_mod_depth_final,\\n#                                evap_3_arm_1_start_pow, evap_3_arm_1_final_pow, evap_3_rate_constant_1, evap_3_rate_constant_2,\\n#                                evap_3_ramp_trunc_value, evap_3_ramp_trunc_value)\\n\\n&quot;&quot;&quot; Recompress in cODT to measure lifetime &quot;&quot;&quot;\\n# t1 = t\\n# ramp_on_arm_1(t1, recomp_ramp_duration, recomp_ramp_pow_ini_arm_1, recomp_ramp_pow_fin_arm_1)\\n# t += ramp_on_arm_2(t1, recomp_ramp_duration, recomp_ramp_pow_ini_arm_2, recomp_ramp_pow_fin_arm_2)\\n\\nt += odt_hold_time_4\\n\\n&quot;&quot;&quot; ODT blinking for measuring the trapping frequencies &quot;&quot;&quot;\\n# CDT1_Switch.go_low(t)\\n# CDT2_Switch.go_low(t)\\n# t += blink_off_time\\n# CDT1_Switch.go_high(t)\\n# CDT2_Switch.go_high(t)\\n# t += blink_on_time\\n\\n&quot;&quot;&quot; Time of Flight &quot;&quot;&quot;\\nif TOF_free &lt; 12e-3:\\n    set_offset_mag_field(t, x_offset_img, y_offset_img, z_offset_img)\\n    Imaging_Shutter.go_high(t)\\n    t += 20e-3\\n    CDT1_Switch.go_low(t)\\n    CDT2_Switch.go_low(t)\\n    t += 20e-6 # Additional wait to ensure all other beams are off when imaging beam is on so as to not have light shifts\\n    t += TOF_free\\nelse:\\n    CDT1_Switch.go_low(t)\\n    CDT2_Switch.go_low(t)\\n    t += 5e-3\\n    set_offset_mag_field(t, x_offset_img, y_offset_img, z_offset_img)\\n    Imaging_Shutter.go_high(t)\\n    t += TOF_free - 5e-3\\n\\n\\&#x27;\\&#x27;\\&#x27;first image: with atoms\\&#x27;\\&#x27;\\&#x27;\\nMOT_3D_Camera.expose(t, imaging_method, \\&#x27;atoms\\&#x27;, trigger_duration = mot_3d_camera_trigger_duration)\\n# ODT_1_Axis_Camera.expose(t, imaging_method, \\&#x27;atoms\\&#x27;, trigger_duration = odt_axis_camera_trigger_duration)\\n# ODT_2_Axis_Camera.expose(t, imaging_method, \\&#x27;atoms\\&#x27;, trigger_duration = odt_axis_camera_trigger_duration)\\n\\nt += pulse_delay\\nImaging_RF_Switch.go_high(t)\\nImaging_RF_Switch.go_low(t + imaging_pulse_duration)   ## first imaging pulse with duration set by \\&#x27;imaging_pulse_duration\\&#x27;\\n\\nt += wait_time_between_images   ## wait time between images\\n\\n\\&#x27;\\&#x27;\\&#x27;second image: without atoms\\&#x27;\\&#x27;\\&#x27;\\nMOT_3D_Camera.expose(t, imaging_method, \\&#x27;background\\&#x27;, trigger_duration = mot_3d_camera_trigger_duration)\\n# ODT_1_Axis_Camera.expose(t, imaging_method, \\&#x27;background\\&#x27;, trigger_duration = odt_axis_camera_trigger_duration)\\n# ODT_2_Axis_Camera.expose(t, imaging_method, \\&#x27;background\\&#x27;, trigger_duration = odt_axis_camera_trigger_duration)\\n\\nt += pulse_delay\\nImaging_RF_Switch.go_high(t)\\nImaging_RF_Switch.go_low(t + imaging_pulse_duration)   ## second imaging pulse with duration set by \\&#x27;imaging_pulse_duration\\&#x27;\\n\\nt += wait_time_between_images    ## wait time between images\\n\\n\\&#x27;\\&#x27;\\&#x27;third image: dark\\&#x27;\\&#x27;\\&#x27;\\nMOT_3D_Camera.expose(t, imaging_method, \\&#x27;dark\\&#x27;, trigger_duration = mot_3d_camera_trigger_duration)\\n# ODT_1_Axis_Camera.expose(t, imaging_method, \\&#x27;dark\\&#x27;, trigger_duration = odt_axis_camera_trigger_duration)\\n# ODT_2_Axis_Camera.expose(t, imaging_method, \\&#x27;dark\\&#x27;, trigger_duration = odt_axis_camera_trigger_duration)\\n\\nMOT_CompX_Coil_Switch.go_low(t)\\nMOT_CompY_Coil_Switch.go_low(t)\\nMOT_CompZ_Coil_Switch.go_low(t)\\nt += 100e-3\\n\\nImaging_Shutter.go_low(t+1e-3)\\nt = reinitialise(t)\\nt += 100e-3\\n\\nstop(t)\\n\\n########## Deprecated ############\\n\\n&quot;&quot;&quot;EVAPORATION 1&quot;&quot;&quot;\\n&quot;&quot;&quot;Ramp down modulation and power of ODT1 exponentially, switch on and ramp up power of ODT2&quot;&quot;&quot;\\n# t += lin_ramp_modulation_and_power(t, evap_1_ramp_duration_1, mod_depth_1_ini, mod_depth_1_fin, evap_1_start_pow_1, evap_1_final_pow_1)\\n# t += lin_ramp_modulation_and_power(t, evap_1_ramp_duration_2, mod_depth_2_ini, mod_depth_2_fin, evap_1_start_pow_2, evap_1_final_pow_2)\\n# t += lin_ramp_modulation_and_power(t, evap_1_ramp_duration_3, mod_depth_3_ini, mod_depth_3_fin, evap_1_start_pow_3, evap_1_final_pow_3)\\n# CDT2_Switch.go_high(t)\\n# t0 = t \\n# ramp_on_arm_2(t0, evap_1_ramp_duration_4, pow_ini_arm_2, pow_fin_arm_2)\\n# t += lin_ramp_modulation_and_power(t0, evap_1_ramp_duration_4, mod_depth_4_ini, mod_depth_4_fin, evap_1_start_pow_4, evap_1_final_pow_4)\\n\\n&quot;&quot;&quot;EVAPORATION 2&quot;&quot;&quot;\\n&quot;&quot;&quot;evaporation in the ODT1: ramp down the power of ODT1 only&quot;&quot;&quot;\\n# t += lin_ramp_arm_1(t, evap_2_ramp_duration_1, evap_2_start_pow_1, evap_2_final_pow_1)\\n\\n&quot;&quot;&quot;EVAPORATION 3&quot;&quot;&quot;\\n&quot;&quot;&quot;evaporation in the CDT: ramp down the power of ODT1 &amp; ODT2 simultaneously&quot;&quot;&quot;\\n# t += odt_hold_time_3\\n# t += ramp_cODT(t, evap_3_ramp_duration, evap_3_arm_1_start_pow, evap_3_arm_1_final_pow, evap_3_arm_2_start_pow, evap_3_arm_2_final_pow, evap_3_rate_constant_1, evap_3_rate_constant_2, evap_3_truncation_value)\\n\\n&quot;&quot;&quot;EVAPORATION 4&quot;&quot;&quot;\\n&quot;&quot;&quot;ramp back on modulation and power of ODT1&quot;&quot;&quot;\\n# t += lin_ramp_modulation_and_power(t, evap_ramp_4_duration, mod_depth_on_initial, mod_depth_on_final, evap_4_arm_1_start_pow, evap_4_arm_1_final_pow)\\n\\n########## Deprecated ############&#x27;],\n",
       "      dtype=&#x27;&lt;U7544&#x27;)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>time_markers</span></div><div class='xr-var-dims'>(fileNum, phony_dim_1)</div><div class='xr-var-dtype'>[(&#x27;label&#x27;, &#x27;S256&#x27;), (&#x27;time&#x27;, &#x27;&lt;f8&#x27;), (&#x27;color&#x27;, &#x27;&lt;i4&#x27;, (1, 3))]</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1, 0), meta=np.ndarray&gt;</div><input id='attrs-96366a15-b8a7-4819-a1af-91c14a407a87' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-96366a15-b8a7-4819-a1af-91c14a407a87' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-d986513c-da4d-44ce-8e39-d31ef1e1f487' class='xr-var-data-in' type='checkbox'><label for='data-d986513c-da4d-44ce-8e39-d31ef1e1f487' 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'><table>\n",
       "    <tr>\n",
       "        <td>\n",
       "            <table style=\"border-collapse: collapse;\">\n",
       "                <thead>\n",
       "                    <tr>\n",
       "                        <td> </td>\n",
       "                        <th> Array </th>\n",
       "                        <th> Chunk </th>\n",
       "                    </tr>\n",
       "                </thead>\n",
       "                <tbody>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Bytes </th>\n",
       "                        <td> 0 B </td>\n",
       "                        <td> 0 B </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (1, 0) </td>\n",
       "                        <td> (1, 0) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 1 chunks in 3 graph layers </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Data type </th>\n",
       "                        <td colspan=\"2\"> [('label', 'S256'), ('time', '<f8'), ('color', '<i4', (1, 3))] numpy.ndarray </td>\n",
       "                    </tr>\n",
       "                </tbody>\n",
       "            </table>\n",
       "        </td>\n",
       "        <td>\n",
       "        \n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>waits</span></div><div class='xr-var-dims'>(fileNum, phony_dim_1)</div><div class='xr-var-dtype'>[(&#x27;label&#x27;, &#x27;S256&#x27;), (&#x27;time&#x27;, &#x27;&lt;f8&#x27;), (&#x27;timeout&#x27;, &#x27;&lt;f8&#x27;)]</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1, 0), meta=np.ndarray&gt;</div><input id='attrs-229d9531-b917-48a2-8c2c-d33d13f0c3aa' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-229d9531-b917-48a2-8c2c-d33d13f0c3aa' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-7a30f2d1-a3a8-4f41-9e11-d9480b1e4980' class='xr-var-data-in' type='checkbox'><label for='data-7a30f2d1-a3a8-4f41-9e11-d9480b1e4980' 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'><dt><span>wait_monitor_acquisition_connection :</span></dt><dd>internal</dd><dt><span>wait_monitor_acquisition_device :</span></dt><dd>prawn_internal_wait_monitor_outputs</dd><dt><span>wait_monitor_timeout_connection :</span></dt><dd>internal</dd><dt><span>wait_monitor_timeout_device :</span></dt><dd>prawn_internal_wait_monitor_outputs</dd><dt><span>wait_monitor_timeout_trigger_type :</span></dt><dd>rising</dd></dl></div><div class='xr-var-data'><table>\n",
       "    <tr>\n",
       "        <td>\n",
       "            <table style=\"border-collapse: collapse;\">\n",
       "                <thead>\n",
       "                    <tr>\n",
       "                        <td> </td>\n",
       "                        <th> Array </th>\n",
       "                        <th> Chunk </th>\n",
       "                    </tr>\n",
       "                </thead>\n",
       "                <tbody>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Bytes </th>\n",
       "                        <td> 0 B </td>\n",
       "                        <td> 0 B </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (1, 0) </td>\n",
       "                        <td> (1, 0) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 1 chunks in 3 graph layers </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Data type </th>\n",
       "                        <td colspan=\"2\"> [('label', 'S256'), ('time', '<f8'), ('timeout', '<f8')] numpy.ndarray </td>\n",
       "                    </tr>\n",
       "                </tbody>\n",
       "            </table>\n",
       "        </td>\n",
       "        <td>\n",
       "        \n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li></ul></div></li><li class='xr-section-item'><input id='section-8a09c761-42d2-4d22-9690-2553848a07ba' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-8a09c761-42d2-4d22-9690-2553848a07ba' class='xr-section-summary'  title='Expand/collapse section'>Indexes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-44b83dfc-4a6d-432c-b8e7-61cdcc75a383' class='xr-section-summary-in' type='checkbox'  checked><label for='section-44b83dfc-4a6d-432c-b8e7-61cdcc75a383' class='xr-section-summary' >Attributes: <span>(7)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>n_runs :</span></dt><dd>12</dd><dt><span>run number :</span></dt><dd>11</dd><dt><span>run time :</span></dt><dd>20230424T183333</dd><dt><span>script_basename :</span></dt><dd>Evaporative_Cooling</dd><dt><span>sequence_date :</span></dt><dd>2023-04-24</dd><dt><span>sequence_id :</span></dt><dd>20230424T183145_Evaporative_Cooling</dd><dt><span>sequence_index :</span></dt><dd>13</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:           (fileNum: 1, phony_dim_0: 59, phony_dim_1: 0)\n",
       "Dimensions without coordinates: fileNum, phony_dim_0, phony_dim_1\n",
       "Data variables:\n",
       "    connection table  (fileNum, phony_dim_0) [('name', 'S256'), ('class', 'S256'), ('parent', 'S256'), ('parent port', 'S256'), ('unit conversion class', 'S256'), ('unit conversion params', 'O'), ('BLACS_connection', 'S9'), ('properties', 'O')] dask.array<chunksize=(1, 59), meta=np.ndarray>\n",
       "    script            (fileNum) <U7544 'from labscript import *\\nfrom labscri...\n",
       "    time_markers      (fileNum, phony_dim_1) [('label', 'S256'), ('time', '<f8'), ('color', '<i4', (1, 3))] dask.array<chunksize=(1, 0), meta=np.ndarray>\n",
       "    waits             (fileNum, phony_dim_1) [('label', 'S256'), ('time', '<f8'), ('timeout', '<f8')] dask.array<chunksize=(1, 0), meta=np.ndarray>\n",
       "Attributes:\n",
       "    n_runs:           12\n",
       "    run number:       11\n",
       "    run time:         20230424T183333\n",
       "    script_basename:  Evaporative_Cooling\n",
       "    sequence_date:    2023-04-24\n",
       "    sequence_id:      20230424T183145_Evaporative_Cooling\n",
       "    sequence_index:   13"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xr.open_mfdataset(filePath, \n",
    "            concat_dim=\"fileNum\", \n",
    "            combine=\"nested\", \n",
    "            engine=\"h5netcdf\", \n",
    "            phony_dims=\"access\", \n",
    "            parallel=True, )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['F:',\n",
       " 'Jianshun',\n",
       " 'analyseScript',\n",
       " 'testData',\n",
       " '0002',\n",
       " '2023-04-21_0002_Evaporative_Cooling_0.h5']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = 'F:\\\\Jianshun/analyseScript/testData/0002/2023-04-21_0002_Evaporative_Cooling_0.h5'\n",
    "a.replace('\\\\', '/').split('/')[-1].split('_')"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calculate an plot OD images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 197640 characters]",
      "text/plain": [
       "<Figure size 640x480 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# imageAnalyser.center = (960, 1040)\n",
    "# imageAnalyser.span = (100, 100)\n",
    "# imageAnalyser.fraction = (0.1, 0.1)\n",
    "\n",
    "imageAnalyser.center = (960, 875)\n",
    "imageAnalyser.span = (300, 300)\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",
    "dataSet_cropOD.plot.pcolormesh(cmap='jet', vmin=0, col=scanAxis[0], row=scanAxis[1])\n",
    "plt.show()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Do a 2D two-peak gaussian fit to the OD images"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Do the fit"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "f:\\Jianshun\\analyseScript\\Analyser\\FitAnalyser.py:86: RuntimeWarning: invalid value encountered in power\n",
      "  res = (1- ((x-centerx)/(sigmax))**2 - ((y-centery)/(sigmay))**2)**(3 / 2)\n"
     ]
    }
   ],
   "source": [
    "from Analyser.FitAnalyser import ThomasFermi2dModel, DensityProfileBEC2dModel, polylog2_2d\n",
    "\n",
    "fitModel = DensityProfileBEC2dModel()\n",
    "# fitModel = ThomasFermi2dModel()\n",
    "\n",
    "fitAnalyser = FitAnalyser(fitModel, fitDim=2)\n",
    "\n",
    "# fitAnalyser = FitAnalyser(\"Gaussian-2D\", fitDim=2)\n",
    "\n",
    "# dataSet_cropOD = dataSet_cropOD.chunk((1,1,100,100))\n",
    "\n",
    "params = fitAnalyser.guess(dataSet_cropOD, guess_kwargs=dict(pureBECThreshold=0.3), dask=\"parallelized\")\n",
    "fitResult = fitAnalyser.fit(dataSet_cropOD, params).load()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><tr><th> name </th><th> value </th><th> initial value </th><th> min </th><th> max </th><th> vary </th><th> expression </th></tr><tr><td> BEC_amplitude </td><td>  366.888620 </td><td> None </td><td>  0.00000000 </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> thermal_amplitude </td><td>  0.00000000 </td><td> None </td><td>  0.00000000 </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> BEC_centerx </td><td>  152.087577 </td><td> None </td><td>        -inf </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> BEC_centery </td><td>  156.309927 </td><td> None </td><td>        -inf </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> thermal_centerx </td><td>  169.884333 </td><td> None </td><td>        -inf </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> thermal_centery </td><td>  157.547034 </td><td> None </td><td>        -inf </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> BEC_sigmax </td><td>  1.63603577 </td><td> None </td><td>  0.00000000 </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> BEC_sigmay </td><td>  3.42894901 </td><td> None </td><td>  0.00000000 </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> thermal_sigmax </td><td>  158.415970 </td><td> None </td><td>  0.00000000 </td><td>         inf </td><td> True </td><td>  </td></tr><tr><td> thermal_sigmay </td><td>  190.099163 </td><td> None </td><td>        -inf </td><td>         inf </td><td> False </td><td> thermalAspectRatio * thermal_sigmax </td></tr><tr><td> thermalAspectRatio </td><td>  1.20000000 </td><td> None </td><td>  0.80000000 </td><td>  1.20000000 </td><td> True </td><td>  </td></tr><tr><td> condensate_fraction </td><td>  1.00000000 </td><td> None </td><td>        -inf </td><td>         inf </td><td> False </td><td> BEC_amplitude / (BEC_amplitude + thermal_amplitude) </td></tr></table>"
      ],
      "text/plain": [
       "Parameters([('BEC_amplitude', <Parameter 'BEC_amplitude', value=366.8886196688306, bounds=[0:inf]>), ('thermal_amplitude', <Parameter 'thermal_amplitude', value=0, bounds=[0:inf]>), ('BEC_centerx', <Parameter 'BEC_centerx', value=152.08757708603804, bounds=[-inf:inf]>), ('BEC_centery', <Parameter 'BEC_centery', value=156.30992724959418, bounds=[-inf:inf]>), ('thermal_centerx', <Parameter 'thermal_centerx', value=169.88433327212883, bounds=[-inf:inf]>), ('thermal_centery', <Parameter 'thermal_centery', value=157.5470340720574, bounds=[-inf:inf]>), ('BEC_sigmax', <Parameter 'BEC_sigmax', value=1.636035766171183, bounds=[0:inf]>), ('BEC_sigmay', <Parameter 'BEC_sigmay', value=3.4289490138791647, bounds=[0:inf]>), ('thermal_sigmax', <Parameter 'thermal_sigmax', value=158.41596952074627, bounds=[0:inf]>), ('thermal_sigmay', <Parameter 'thermal_sigmay', value=190.09916342489552, bounds=[-inf:inf], expr='thermalAspectRatio * thermal_sigmax'>), ('thermalAspectRatio', <Parameter 'thermalAspectRatio', value=1.2, bounds=[0.8:1.2]>), ('condensate_fraction', <Parameter 'condensate_fraction', value=1.0, bounds=[-inf:inf], expr='BEC_amplitude / (BEC_amplitude + thermal_amplitude)'>)])"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "params.compute().item()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.QuadMesh at 0x1e0e84006d0>"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 27308 characters]",
      "text/plain": [
       "<Figure size 640x480 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fitCurve = fitAnalyser.eval(fitResult, x=np.arange(300), y=np.arange(300), dask=\"parallelized\").load()\n",
    "\n",
    "fitCurve.plot.pcolormesh(cmap='jet', vmin=0, col=scanAxis[0], row=scanAxis[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [],
   "source": [
    "fitModel2 = Polylog22dModel(prefix='thermal_')\n",
    "fitAnalyser2 = FitAnalyser(fitModel2, fitDim=2)\n",
    "fitCurve2 = fitAnalyser2.eval(fitResult, x=np.arange(100), y=np.arange(100), dask=\"parallelized\").load()\n",
    "\n",
    "fitModel3 = ThomasFermi2dModel(prefix='BEC_')\n",
    "fitAnalyser3 = FitAnalyser(fitModel3, fitDim=2)\n",
    "fitCurve3 = fitAnalyser3.eval(fitResult, x=np.arange(100), y=np.arange(100), dask=\"parallelized\").load()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 55528 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 54548 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "dataSet_cropOD.sum(dim='x').plot(ax=ax, col=scanAxis[0], row=scanAxis[1])\n",
    "fitCurve.sum(dim='x').plot(ax=ax, col=scanAxis[0], row=scanAxis[1])\n",
    "fitCurve2.sum(dim='x').plot(ax=ax, col=scanAxis[0], row=scanAxis[1])\n",
    "fitCurve3.sum(dim='x').plot(ax=ax, col=scanAxis[0], row=scanAxis[1])\n",
    "\n",
    "plt.show()\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "\n",
    "dataSet_cropOD.sum(dim='y').plot(ax=ax, col=scanAxis[0], row=scanAxis[1])\n",
    "fitCurve.sum(dim='y').plot(ax=ax, col=scanAxis[0], row=scanAxis[1])\n",
    "fitCurve2.sum(dim='y').plot(ax=ax, col=scanAxis[0], row=scanAxis[1])\n",
    "fitCurve3.sum(dim='y').plot(ax=ax, col=scanAxis[0], row=scanAxis[1])\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\data\\AppData\\Roaming\\Python\\Python39\\site-packages\\numpy\\lib\\function_base.py:2246: RuntimeWarning: invalid value encountered in _get_fit_full_result_single (vectorized)\n",
      "  outputs = ufunc(*inputs)\n"
     ]
    }
   ],
   "source": [
    "value = fitAnalyser.get_fit_full_result(fitResult)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "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:              ()\n",
       "Data variables:\n",
       "    BEC_amplitude        object 0.0+/-nan\n",
       "    thermal_amplitude    object 2104.548431645919+/-nan\n",
       "    BEC_centerx          object 146.94301032591366+/-nan\n",
       "    BEC_centery          object 147.47224593536436+/-nan\n",
       "    thermal_centerx      object 146.27287010988167+/-nan\n",
       "    thermal_centery      object 148.78153517037947+/-nan\n",
       "    BEC_sigmax           object 17.155488681677085+/-nan\n",
       "    BEC_sigmay           object 18.315601451967396+/-nan\n",
       "    thermal_sigmax       object 42.999686622150065+/-nan\n",
       "    thermal_sigmay       object 51.599623946580074+/-nan\n",
       "    thermalAspectRatio   object 1.2+/-nan\n",
       "    condensate_fraction  object 0.0+/-nan\n",
       "Attributes:\n",
       "    IMAGE_SUBCLASS:       IMAGE_GRAYSCALE\n",
       "    IMAGE_VERSION:        1.2\n",
       "    IMAGE_WHITE_IS_ZERO:  0\n",
       "    x_start:              810\n",
       "    x_end:                1110\n",
       "    y_end:                1025\n",
       "    y_start:              725\n",
       "    x_center:             960\n",
       "    y_center:             875\n",
       "    x_span:               300\n",
       "    y_span:               300</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-53523a01-2c07-4165-91ae-60ce98257240' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-53523a01-2c07-4165-91ae-60ce98257240' class='xr-section-summary'  title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-448573c2-6f7b-479e-ae18-5c693d5ebbdb' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-448573c2-6f7b-479e-ae18-5c693d5ebbdb' class='xr-section-summary'  title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-f81fa7c4-b59b-456c-929b-d5fdf0999ba7' class='xr-section-summary-in' type='checkbox'  checked><label for='section-f81fa7c4-b59b-456c-929b-d5fdf0999ba7' class='xr-section-summary' >Data variables: <span>(12)</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>BEC_amplitude</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>0.0+/-nan</div><input id='attrs-ae17e55d-accd-49e8-9a73-373506561892' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-ae17e55d-accd-49e8-9a73-373506561892' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4d309f58-8d37-475d-9462-884f4ad37e77' class='xr-var-data-in' type='checkbox'><label for='data-4d309f58-8d37-475d-9462-884f4ad37e77' 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.0+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>thermal_amplitude</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>2104.548431645919+/-nan</div><input id='attrs-ce8230fc-40ed-4545-8712-ec500a361b66' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-ce8230fc-40ed-4545-8712-ec500a361b66' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c4d45705-76ae-4681-a822-8d9af1dbbece' class='xr-var-data-in' type='checkbox'><label for='data-c4d45705-76ae-4681-a822-8d9af1dbbece' 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(2104.548431645919+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>BEC_centerx</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>146.94301032591366+/-nan</div><input id='attrs-d3679e45-9660-4dc8-9900-6ff9b96700a5' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-d3679e45-9660-4dc8-9900-6ff9b96700a5' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-2d54cdcf-9b44-4720-b151-cdd4cfffd6be' class='xr-var-data-in' type='checkbox'><label for='data-2d54cdcf-9b44-4720-b151-cdd4cfffd6be' 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(146.94301032591366+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>BEC_centery</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>147.47224593536436+/-nan</div><input id='attrs-bdd1b243-37f9-4c5b-b281-cad8518f539e' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-bdd1b243-37f9-4c5b-b281-cad8518f539e' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-d9fe3035-bc63-408d-93e5-50cffe8d1a60' class='xr-var-data-in' type='checkbox'><label for='data-d9fe3035-bc63-408d-93e5-50cffe8d1a60' 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(147.47224593536436+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>thermal_centerx</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>146.27287010988167+/-nan</div><input id='attrs-7fb7dc26-82ad-49eb-83ae-bafb0b3f876a' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-7fb7dc26-82ad-49eb-83ae-bafb0b3f876a' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-08bdb556-ba2d-473d-8b0f-8955e6e3124e' class='xr-var-data-in' type='checkbox'><label for='data-08bdb556-ba2d-473d-8b0f-8955e6e3124e' 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(146.27287010988167+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>thermal_centery</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>148.78153517037947+/-nan</div><input id='attrs-3da43036-1dea-4a3f-a01f-e5389fa02de0' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-3da43036-1dea-4a3f-a01f-e5389fa02de0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4b9d40d4-ace6-44fa-8f39-f640f11e6976' class='xr-var-data-in' type='checkbox'><label for='data-4b9d40d4-ace6-44fa-8f39-f640f11e6976' 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(148.78153517037947+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>BEC_sigmax</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>17.155488681677085+/-nan</div><input id='attrs-783a8786-d131-48bc-b94c-6301659c7cf1' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-783a8786-d131-48bc-b94c-6301659c7cf1' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ba8ac7d5-06cf-43de-b1f3-06cdd30e4412' class='xr-var-data-in' type='checkbox'><label for='data-ba8ac7d5-06cf-43de-b1f3-06cdd30e4412' 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(17.155488681677085+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>BEC_sigmay</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>18.315601451967396+/-nan</div><input id='attrs-1763da2e-7acf-4050-9254-12f20f086c8f' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-1763da2e-7acf-4050-9254-12f20f086c8f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f63fc78c-630c-49b7-8e38-508a140bfc7a' class='xr-var-data-in' type='checkbox'><label for='data-f63fc78c-630c-49b7-8e38-508a140bfc7a' 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(18.315601451967396+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>thermal_sigmax</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>42.999686622150065+/-nan</div><input id='attrs-853c9056-d1e5-4cd9-9651-c55696182c46' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-853c9056-d1e5-4cd9-9651-c55696182c46' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c7da350c-983c-4a4a-8c2b-3e3088dc3c45' class='xr-var-data-in' type='checkbox'><label for='data-c7da350c-983c-4a4a-8c2b-3e3088dc3c45' 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(42.999686622150065+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>thermal_sigmay</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>51.599623946580074+/-nan</div><input id='attrs-e39f9e6f-232b-4100-818e-8c04aa7ef1eb' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-e39f9e6f-232b-4100-818e-8c04aa7ef1eb' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-341b0d11-b102-48d6-bfce-9c50de3a8e63' class='xr-var-data-in' type='checkbox'><label for='data-341b0d11-b102-48d6-bfce-9c50de3a8e63' 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(51.599623946580074+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>thermalAspectRatio</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>1.2+/-nan</div><input id='attrs-b22b238b-7313-415e-81fa-884f46a6ae01' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-b22b238b-7313-415e-81fa-884f46a6ae01' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-692f659a-4ea0-4826-88fa-a9d75ebaffa3' class='xr-var-data-in' type='checkbox'><label for='data-692f659a-4ea0-4826-88fa-a9d75ebaffa3' 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(1.2+/-nan, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>condensate_fraction</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>0.0+/-nan</div><input id='attrs-0114f61a-f370-4847-88b5-e2a6f07684d9' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-0114f61a-f370-4847-88b5-e2a6f07684d9' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-d3f12cda-3bd6-4dbd-92ca-e121db995872' class='xr-var-data-in' type='checkbox'><label for='data-d3f12cda-3bd6-4dbd-92ca-e121db995872' 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.0+/-nan, dtype=object)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-cf8bd205-992c-4301-b898-328e8b399d33' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-cf8bd205-992c-4301-b898-328e8b399d33' class='xr-section-summary'  title='Expand/collapse section'>Indexes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-8e60218d-87c4-4a98-9aad-43c0fba800f1' class='xr-section-summary-in' type='checkbox'  ><label for='section-8e60218d-87c4-4a98-9aad-43c0fba800f1' class='xr-section-summary' >Attributes: <span>(11)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>IMAGE_SUBCLASS :</span></dt><dd>IMAGE_GRAYSCALE</dd><dt><span>IMAGE_VERSION :</span></dt><dd>1.2</dd><dt><span>IMAGE_WHITE_IS_ZERO :</span></dt><dd>0</dd><dt><span>x_start :</span></dt><dd>810</dd><dt><span>x_end :</span></dt><dd>1110</dd><dt><span>y_end :</span></dt><dd>1025</dd><dt><span>y_start :</span></dt><dd>725</dd><dt><span>x_center :</span></dt><dd>960</dd><dt><span>y_center :</span></dt><dd>875</dd><dt><span>x_span :</span></dt><dd>300</dd><dt><span>y_span :</span></dt><dd>300</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:              ()\n",
       "Data variables:\n",
       "    BEC_amplitude        object 0.0+/-nan\n",
       "    thermal_amplitude    object 2104.548431645919+/-nan\n",
       "    BEC_centerx          object 146.94301032591366+/-nan\n",
       "    BEC_centery          object 147.47224593536436+/-nan\n",
       "    thermal_centerx      object 146.27287010988167+/-nan\n",
       "    thermal_centery      object 148.78153517037947+/-nan\n",
       "    BEC_sigmax           object 17.155488681677085+/-nan\n",
       "    BEC_sigmay           object 18.315601451967396+/-nan\n",
       "    thermal_sigmax       object 42.999686622150065+/-nan\n",
       "    thermal_sigmay       object 51.599623946580074+/-nan\n",
       "    thermalAspectRatio   object 1.2+/-nan\n",
       "    condensate_fraction  object 0.0+/-nan\n",
       "Attributes:\n",
       "    IMAGE_SUBCLASS:       IMAGE_GRAYSCALE\n",
       "    IMAGE_VERSION:        1.2\n",
       "    IMAGE_WHITE_IS_ZERO:  0\n",
       "    x_start:              810\n",
       "    x_end:                1110\n",
       "    y_end:                1025\n",
       "    y_start:              725\n",
       "    x_center:             960\n",
       "    y_center:             875\n",
       "    x_span:               300\n",
       "    y_span:               300"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "unable to infer dtype on variable 'OD'; xarray cannot serialize arbitrary Python objects",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32mf:\\Jianshun\\analyseScript\\test.ipynb Cell 25\u001b[0m in \u001b[0;36m1\n\u001b[1;32m----> <a href='vscode-notebook-cell:/f%3A/Jianshun/analyseScript/test.ipynb#Y216sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m fitResult\u001b[39m.\u001b[39;49mto_netcdf(\u001b[39m\"\u001b[39;49m\u001b[39msaved_on_disk.nc\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\core\\dataarray.py:3959\u001b[0m, in \u001b[0;36mDataArray.to_netcdf\u001b[1;34m(self, path, mode, format, group, engine, encoding, unlimited_dims, compute, invalid_netcdf)\u001b[0m\n\u001b[0;32m   3955\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m   3956\u001b[0m     \u001b[39m# No problems with the name - so we're fine!\u001b[39;00m\n\u001b[0;32m   3957\u001b[0m     dataset \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mto_dataset()\n\u001b[1;32m-> 3959\u001b[0m \u001b[39mreturn\u001b[39;00m to_netcdf(  \u001b[39m# type: ignore  # mypy cannot resolve the overloads:(\u001b[39;49;00m\n\u001b[0;32m   3960\u001b[0m     dataset,\n\u001b[0;32m   3961\u001b[0m     path,\n\u001b[0;32m   3962\u001b[0m     mode\u001b[39m=\u001b[39;49mmode,\n\u001b[0;32m   3963\u001b[0m     \u001b[39mformat\u001b[39;49m\u001b[39m=\u001b[39;49m\u001b[39mformat\u001b[39;49m,\n\u001b[0;32m   3964\u001b[0m     group\u001b[39m=\u001b[39;49mgroup,\n\u001b[0;32m   3965\u001b[0m     engine\u001b[39m=\u001b[39;49mengine,\n\u001b[0;32m   3966\u001b[0m     encoding\u001b[39m=\u001b[39;49mencoding,\n\u001b[0;32m   3967\u001b[0m     unlimited_dims\u001b[39m=\u001b[39;49munlimited_dims,\n\u001b[0;32m   3968\u001b[0m     compute\u001b[39m=\u001b[39;49mcompute,\n\u001b[0;32m   3969\u001b[0m     multifile\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m,\n\u001b[0;32m   3970\u001b[0m     invalid_netcdf\u001b[39m=\u001b[39;49minvalid_netcdf,\n\u001b[0;32m   3971\u001b[0m )\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\backends\\api.py:1216\u001b[0m, in \u001b[0;36mto_netcdf\u001b[1;34m(dataset, path_or_file, mode, format, group, engine, encoding, unlimited_dims, compute, multifile, invalid_netcdf)\u001b[0m\n\u001b[0;32m   1211\u001b[0m \u001b[39m# TODO: figure out how to refactor this logic (here and in save_mfdataset)\u001b[39;00m\n\u001b[0;32m   1212\u001b[0m \u001b[39m# to avoid this mess of conditionals\u001b[39;00m\n\u001b[0;32m   1213\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m   1214\u001b[0m     \u001b[39m# TODO: allow this work (setting up the file for writing array data)\u001b[39;00m\n\u001b[0;32m   1215\u001b[0m     \u001b[39m# to be parallelized with dask\u001b[39;00m\n\u001b[1;32m-> 1216\u001b[0m     dump_to_store(\n\u001b[0;32m   1217\u001b[0m         dataset, store, writer, encoding\u001b[39m=\u001b[39;49mencoding, unlimited_dims\u001b[39m=\u001b[39;49munlimited_dims\n\u001b[0;32m   1218\u001b[0m     )\n\u001b[0;32m   1219\u001b[0m     \u001b[39mif\u001b[39;00m autoclose:\n\u001b[0;32m   1220\u001b[0m         store\u001b[39m.\u001b[39mclose()\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\backends\\api.py:1263\u001b[0m, in \u001b[0;36mdump_to_store\u001b[1;34m(dataset, store, writer, encoder, encoding, unlimited_dims)\u001b[0m\n\u001b[0;32m   1260\u001b[0m \u001b[39mif\u001b[39;00m encoder:\n\u001b[0;32m   1261\u001b[0m     variables, attrs \u001b[39m=\u001b[39m encoder(variables, attrs)\n\u001b[1;32m-> 1263\u001b[0m store\u001b[39m.\u001b[39;49mstore(variables, attrs, check_encoding, writer, unlimited_dims\u001b[39m=\u001b[39;49munlimited_dims)\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\backends\\common.py:269\u001b[0m, in \u001b[0;36mAbstractWritableDataStore.store\u001b[1;34m(self, variables, attributes, check_encoding_set, writer, unlimited_dims)\u001b[0m\n\u001b[0;32m    266\u001b[0m \u001b[39mif\u001b[39;00m writer \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m    267\u001b[0m     writer \u001b[39m=\u001b[39m ArrayWriter()\n\u001b[1;32m--> 269\u001b[0m variables, attributes \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mencode(variables, attributes)\n\u001b[0;32m    271\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mset_attributes(attributes)\n\u001b[0;32m    272\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mset_dimensions(variables, unlimited_dims\u001b[39m=\u001b[39munlimited_dims)\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\backends\\common.py:358\u001b[0m, in \u001b[0;36mWritableCFDataStore.encode\u001b[1;34m(self, variables, attributes)\u001b[0m\n\u001b[0;32m    355\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mencode\u001b[39m(\u001b[39mself\u001b[39m, variables, attributes):\n\u001b[0;32m    356\u001b[0m     \u001b[39m# All NetCDF files get CF encoded by default, without this attempting\u001b[39;00m\n\u001b[0;32m    357\u001b[0m     \u001b[39m# to write times, for example, would fail.\u001b[39;00m\n\u001b[1;32m--> 358\u001b[0m     variables, attributes \u001b[39m=\u001b[39m cf_encoder(variables, attributes)\n\u001b[0;32m    359\u001b[0m     variables \u001b[39m=\u001b[39m {k: \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mencode_variable(v) \u001b[39mfor\u001b[39;00m k, v \u001b[39min\u001b[39;00m variables\u001b[39m.\u001b[39mitems()}\n\u001b[0;32m    360\u001b[0m     attributes \u001b[39m=\u001b[39m {k: \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mencode_attribute(v) \u001b[39mfor\u001b[39;00m k, v \u001b[39min\u001b[39;00m attributes\u001b[39m.\u001b[39mitems()}\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\conventions.py:775\u001b[0m, in \u001b[0;36mcf_encoder\u001b[1;34m(variables, attributes)\u001b[0m\n\u001b[0;32m    772\u001b[0m \u001b[39m# add encoding for time bounds variables if present.\u001b[39;00m\n\u001b[0;32m    773\u001b[0m _update_bounds_encoding(variables)\n\u001b[1;32m--> 775\u001b[0m new_vars \u001b[39m=\u001b[39m {k: encode_cf_variable(v, name\u001b[39m=\u001b[39mk) \u001b[39mfor\u001b[39;00m k, v \u001b[39min\u001b[39;00m variables\u001b[39m.\u001b[39mitems()}\n\u001b[0;32m    777\u001b[0m \u001b[39m# Remove attrs from bounds variables (issue #2921)\u001b[39;00m\n\u001b[0;32m    778\u001b[0m \u001b[39mfor\u001b[39;00m var \u001b[39min\u001b[39;00m new_vars\u001b[39m.\u001b[39mvalues():\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\conventions.py:775\u001b[0m, in \u001b[0;36m<dictcomp>\u001b[1;34m(.0)\u001b[0m\n\u001b[0;32m    772\u001b[0m \u001b[39m# add encoding for time bounds variables if present.\u001b[39;00m\n\u001b[0;32m    773\u001b[0m _update_bounds_encoding(variables)\n\u001b[1;32m--> 775\u001b[0m new_vars \u001b[39m=\u001b[39m {k: encode_cf_variable(v, name\u001b[39m=\u001b[39;49mk) \u001b[39mfor\u001b[39;00m k, v \u001b[39min\u001b[39;00m variables\u001b[39m.\u001b[39mitems()}\n\u001b[0;32m    777\u001b[0m \u001b[39m# Remove attrs from bounds variables (issue #2921)\u001b[39;00m\n\u001b[0;32m    778\u001b[0m \u001b[39mfor\u001b[39;00m var \u001b[39min\u001b[39;00m new_vars\u001b[39m.\u001b[39mvalues():\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\conventions.py:189\u001b[0m, in \u001b[0;36mencode_cf_variable\u001b[1;34m(var, needs_copy, name)\u001b[0m\n\u001b[0;32m    186\u001b[0m     var \u001b[39m=\u001b[39m coder\u001b[39m.\u001b[39mencode(var, name\u001b[39m=\u001b[39mname)\n\u001b[0;32m    188\u001b[0m \u001b[39m# TODO(kmuehlbauer): check if ensure_dtype_not_object can be moved to backends:\u001b[39;00m\n\u001b[1;32m--> 189\u001b[0m var \u001b[39m=\u001b[39m ensure_dtype_not_object(var, name\u001b[39m=\u001b[39;49mname)\n\u001b[0;32m    191\u001b[0m \u001b[39mfor\u001b[39;00m attr_name \u001b[39min\u001b[39;00m CF_RELATED_DATA:\n\u001b[0;32m    192\u001b[0m     pop_to(var\u001b[39m.\u001b[39mencoding, var\u001b[39m.\u001b[39mattrs, attr_name)\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\conventions.py:145\u001b[0m, in \u001b[0;36mensure_dtype_not_object\u001b[1;34m(var, name)\u001b[0m\n\u001b[0;32m    143\u001b[0m     data[missing] \u001b[39m=\u001b[39m fill_value\n\u001b[0;32m    144\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m--> 145\u001b[0m     data \u001b[39m=\u001b[39m _copy_with_dtype(data, dtype\u001b[39m=\u001b[39m_infer_dtype(data, name))\n\u001b[0;32m    147\u001b[0m \u001b[39massert\u001b[39;00m data\u001b[39m.\u001b[39mdtype\u001b[39m.\u001b[39mkind \u001b[39m!=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mO\u001b[39m\u001b[39m\"\u001b[39m \u001b[39mor\u001b[39;00m data\u001b[39m.\u001b[39mdtype\u001b[39m.\u001b[39mmetadata\n\u001b[0;32m    148\u001b[0m var \u001b[39m=\u001b[39m Variable(dims, data, attrs, encoding, fastpath\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m)\n",
      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python39\\site-packages\\xarray\\conventions.py:77\u001b[0m, in \u001b[0;36m_infer_dtype\u001b[1;34m(array, name)\u001b[0m\n\u001b[0;32m     74\u001b[0m \u001b[39mif\u001b[39;00m dtype\u001b[39m.\u001b[39mkind \u001b[39m!=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mO\u001b[39m\u001b[39m\"\u001b[39m:\n\u001b[0;32m     75\u001b[0m     \u001b[39mreturn\u001b[39;00m dtype\n\u001b[1;32m---> 77\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\n\u001b[0;32m     78\u001b[0m     \u001b[39m\"\u001b[39m\u001b[39munable to infer dtype on variable \u001b[39m\u001b[39m{!r}\u001b[39;00m\u001b[39m; xarray \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m     79\u001b[0m     \u001b[39m\"\u001b[39m\u001b[39mcannot serialize arbitrary Python objects\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m.\u001b[39mformat(name)\n\u001b[0;32m     80\u001b[0m )\n",
      "\u001b[1;31mValueError\u001b[0m: unable to infer dtype on variable 'OD'; xarray cannot serialize arbitrary Python objects"
     ]
    }
   ],
   "source": [
    "fitResult.to_netcdf(\"saved_on_disk.nc\")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Get the Ncount"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Ncount = dataSet_crop.OD.sum(dim=(scanAxis[0], 'x', 'y'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Ncount.load()\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "Ncount.plot(ax=ax)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fitAnalyser = FitAnalyser(\"Lorentzian With Offset\")\n",
    "params = fitAnalyser.guess(Ncount, x='runs', dask=\"parallelized\", guess_kwargs=dict(negative=True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fitResult = fitAnalyser.fit(Ncount, params, x='runs', dask=\"parallelized\")\n",
    "fitCurve = fitAnalyser.eval(fitResult, x=np.arange(40), dask=\"parallelized\").load()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "ax = fig.gca()\n",
    "plt.errorbar([1], [1], yerr=[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fitCurve.plot.errorbar(yerr=fitCurve)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.ufunc(fitCurve)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Read CSV"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# filePath = 'Z:/Dy_Lab/Data/Measurements/Experiments/DyBEC/BEC Stability Check/20230509-0007/*.csv'\n",
    "\n",
    "# filePath = np.sort(glob.glob(filePath))\n",
    "\n",
    "# read_csv_file(filePath, maxFileNum=5, csvEngine='pandas', csvKwargs=dict(header=[0,1], na_filter=False, index_col=0))\n",
    "# read_csv_file(filePath, csvEngine='dask')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "filePath = 'Z:/Dy_Lab/Data/Measurements/Experiments/DyBEC/BEC Stability Check/20230509-0007/*.csv'\n",
    "\n",
    "filePath = np.sort(glob.glob(filePath))\n",
    "\n",
    "data = np.empty(filePath.shape,dtype=object)\n",
    "\n",
    "i = 0\n",
    "for fp in filePath:\n",
    "    data_single = pd.read_csv(fp)\n",
    "    data_single = xr.Dataset.from_dataframe(data_single)\n",
    "    data_single = data_single.drop_isel(index=0)\n",
    "    # data_single = data_single.expand_dims(dim='runs')\n",
    "    data[i] = data_single\n",
    "    i = i + 1\n",
    "\n",
    "data = xr.concat(data, 'runs')\n",
    "\n",
    "data = data.assign_coords(dict(index=data.Time.isel(runs=0).astype(float))).rename(dict(index='time')).astype(float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "arm2_mean = data['Channel A'].mean(dim='runs')\n",
    "arm2_std = data['Channel A'].std(dim='runs')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "arm2_mean.plot.errorbar(yerr=arm2_std, fmt='ob')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "arm2_std.plot.errorbar(fmt='ob')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data['Channel A'].sel(time=4.55, method='nearest').plot.errorbar(fmt='ob')\n",
    "\n",
    "plt.ylim([0, 0.15])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.6417497231450753+/-0.01090681927109203"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(-ufloat(99.835,0.018) + ufloat(99.969,0.014))/15*1e3\n",
    "(-ufloat(99.835,0.018) + ufloat(100.994,0.008))/1.29/1.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.6267995570321101+/-0.01750984307955913"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(ufloat(99.835,0.018) - ufloat(98.703,0.026))/1.29/1.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.6342746400885927+/-0.010314471766443609"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "((ufloat(99.835,0.018) - ufloat(98.703,0.026))/1.29/1.4 + (-ufloat(99.835,0.018) + ufloat(100.994,0.008))/1.29/1.4) /2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.642+/-0.011\n",
      "0.627+/-0.018\n",
      "0.634+/-0.010\n",
      "0.0444+/-0.0007\n"
     ]
    }
   ],
   "source": [
    "a = (-ufloat(99.835,0.018) + ufloat(100.994,0.008))/1.29/1.4\n",
    "b = (ufloat(99.835,0.018) - ufloat(98.703,0.026))/1.29/1.4\n",
    "\n",
    "print(a)\n",
    "print(b)\n",
    "print((a+b)/2)\n",
    "print((a+b)/2 * (1.29-1.24)*1.4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.637+/-0.011\n",
      "0.641+/-0.018\n",
      "0.639+/-0.010\n",
      "0.0447+/-0.0007\n"
     ]
    }
   ],
   "source": [
    "a = (-ufloat(99.969,0.018) + ufloat(101.120,0.008))/1.29/1.4\n",
    "b = (ufloat(99.969,0.018) - ufloat(98.811,0.026))/1.29/1.4\n",
    "\n",
    "print(a)\n",
    "print(b)\n",
    "print((a+b)/2)\n",
    "print((a+b)/2 * (1.29-1.24)*1.4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0447+/-0.0007\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "env",
   "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.12"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "c05913ad4f24fdc6b2418069394dc5835b1981849b107c9ba6df693aafd66650"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
