{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from PyQt5.QtCore import (Qt, pyqtSignal)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pymongo\n",
    "import xarray_mongodb\n",
    "import bson\n",
    "import datetime\n",
    "\n",
    "# datetime.datetime.utcnow()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "mongoClient = pymongo.MongoClient('mongodb://control:DyLab2021@127.0.0.1:27017/?authMechanism=DEFAULT')\n",
    "mongoDB = mongoClient.testDB\n",
    "mongoCollection = mongoDB.testCollection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# mongoClient.admin.command(\n",
    "#     'createUser', 'control', \n",
    "#     pwd='DyLab2021',\n",
    "#     roles=[{'role': 'readWriteAnyDatabase', 'db': 'admin'}]\n",
    "# )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# mongoClient.admin.command(\n",
    "#     'dropUser', 'contorl'\n",
    "# )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# mongoClient.admin.command('usersInfo')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Task executing\n",
      "Task2 executing \n",
      "\n",
      "\n",
      "Task2 done\n",
      "\n",
      "Task done\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from time import sleep\n",
    "from multiprocessing.pool import ThreadPool\n",
    " \n",
    "# task executed in a worker thread\n",
    "def task():\n",
    "    # report a message\n",
    "    print(f'Task executing\\n')\n",
    "    # block for a moment\n",
    "    sleep(1)\n",
    "    # report a message\n",
    "    print(f'Task done\\n')\n",
    "    \n",
    "def task2():\n",
    "    # report a message\n",
    "    print(f'Task2 executing \\n')\n",
    "    # block for a moment\n",
    "    sleep(1)\n",
    "    # report a message\n",
    "    print(f'Task2 done\\n')\n",
    " \n",
    "# protect the entry point\n",
    "if __name__ == '__main__':\n",
    "    # create and configure the thread pool\n",
    "    pool = ThreadPool()\n",
    "    # issue tasks to the thread pool\n",
    "    pool.apply_async(task)\n",
    "    pool.apply_async(task2)\n",
    "    # close the thread pool\n",
    "    pool.close()\n",
    "    # wait for all tasks to finish\n",
    "    pool.join()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Import supporting package"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "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": 8,
   "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()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1738.8478693742436\n"
     ]
    }
   ],
   "source": [
    "sigma = 8.4743e-14 * 0.5\n",
    "M = 0.6827\n",
    "print(1/sigma*5.86e-6**2 / M**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8.583565255602754e-06"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "5.86e-6/M"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Start a client for parallel computing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "    <div style=\"width: 24px; height: 24px; background-color: #e1e1e1; border: 3px solid #9D9D9D; border-radius: 5px; position: absolute;\"> </div>\n",
       "    <div style=\"margin-left: 48px;\">\n",
       "        <h3 style=\"margin-bottom: 0px;\">Client</h3>\n",
       "        <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Client-e928dd09-0a9f-11ee-b50c-80e82ce2fa8e</p>\n",
       "        <table style=\"width: 100%; text-align: left;\">\n",
       "\n",
       "        <tr>\n",
       "        \n",
       "            <td style=\"text-align: left;\"><strong>Connection method:</strong> Cluster object</td>\n",
       "            <td style=\"text-align: left;\"><strong>Cluster type:</strong> distributed.LocalCluster</td>\n",
       "        \n",
       "        </tr>\n",
       "\n",
       "        \n",
       "            <tr>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:8787/status\" target=\"_blank\">http://127.0.0.1:8787/status</a>\n",
       "                </td>\n",
       "                <td style=\"text-align: left;\"></td>\n",
       "            </tr>\n",
       "        \n",
       "\n",
       "        </table>\n",
       "\n",
       "        \n",
       "\n",
       "        \n",
       "            <details>\n",
       "            <summary style=\"margin-bottom: 20px;\"><h3 style=\"display: inline;\">Cluster Info</h3></summary>\n",
       "            <div class=\"jp-RenderedHTMLCommon jp-RenderedHTML jp-mod-trusted jp-OutputArea-output\">\n",
       "    <div style=\"width: 24px; height: 24px; background-color: #e1e1e1; border: 3px solid #9D9D9D; border-radius: 5px; position: absolute;\">\n",
       "    </div>\n",
       "    <div style=\"margin-left: 48px;\">\n",
       "        <h3 style=\"margin-bottom: 0px; margin-top: 0px;\">LocalCluster</h3>\n",
       "        <p style=\"color: #9D9D9D; margin-bottom: 0px;\">f62d3f1c</p>\n",
       "        <table style=\"width: 100%; text-align: left;\">\n",
       "            <tr>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Dashboard:</strong> <a href=\"http://127.0.0.1:8787/status\" target=\"_blank\">http://127.0.0.1:8787/status</a>\n",
       "                </td>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Workers:</strong> 6\n",
       "                </td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                <td style=\"text-align: left;\">\n",
       "                    <strong>Total threads:</strong> 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-2b02de43-b3ad-400f-ae4c-0914b85d2b71</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:62759\n",
       "                    </td>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Workers:</strong> 6\n",
       "                    </td>\n",
       "                </tr>\n",
       "                <tr>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Dashboard:</strong> <a href=\"http://127.0.0.1:8787/status\" target=\"_blank\">http://127.0.0.1:8787/status</a>\n",
       "                    </td>\n",
       "                    <td style=\"text-align: left;\">\n",
       "                        <strong>Total threads:</strong> 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:62781\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:62787/status\" target=\"_blank\">http://127.0.0.1:62787/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:62762\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-3gcis6xr\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:62795\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:62799/status\" target=\"_blank\">http://127.0.0.1:62799/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:62763\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-z8bj7z95\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:62789\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:62791/status\" target=\"_blank\">http://127.0.0.1:62791/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:62764\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-67f2wwr0\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:62797\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:62802/status\" target=\"_blank\">http://127.0.0.1:62802/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:62765\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-g84sd6u2\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:62796\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:62798/status\" target=\"_blank\">http://127.0.0.1:62798/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:62766\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-55nj59xw\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:62790\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:62793/status\" target=\"_blank\">http://127.0.0.1:62793/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:62767\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-s47mqrsf\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:62759' processes=6 threads=60, memory=55.88 GiB>"
      ]
     },
     "execution_count": 11,
     "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": 12,
   "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_08.h5'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "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": 14,
   "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": 15,
   "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:              (compX_final_current: 11, runs: 3, y: 1200, x: 1920)\n",
       "Coordinates:\n",
       "  * compX_final_current  (compX_final_current) float64 0.0 0.002 ... 0.018 0.02\n",
       "  * runs                 (runs) float64 0.0 1.0 2.0\n",
       "Dimensions without coordinates: y, x\n",
       "Data variables:\n",
       "    atoms                (compX_final_current, runs, y, x) uint16 dask.array&lt;chunksize=(9, 3, 1200, 1920), meta=np.ndarray&gt;\n",
       "    background           (compX_final_current, runs, y, x) uint16 dask.array&lt;chunksize=(9, 3, 1200, 1920), meta=np.ndarray&gt;\n",
       "    dark                 (compX_final_current, runs, y, x) uint16 dask.array&lt;chunksize=(9, 3, 1200, 1920), meta=np.ndarray&gt;\n",
       "    shotNum              (compX_final_current, runs) &lt;U2 dask.array&lt;chunksize=(11, 3), meta=np.ndarray&gt;\n",
       "    OD                   (compX_final_current, runs, y, x) float64 dask.array&lt;chunksize=(9, 3, 1200, 1920), meta=np.ndarray&gt;\n",
       "Attributes: (12/120)\n",
       "    TOF_free:                          0.022\n",
       "    abs_img_freq:                      110.858\n",
       "    absorption_imaging_flag:           True\n",
       "    backup_data:                       True\n",
       "    blink_off_time:                    0.001\n",
       "    blink_on_time:                     0.001\n",
       "    ...                                ...\n",
       "    z_offset:                          0.189\n",
       "    z_offset_img:                      0.189\n",
       "    compX_final_current:               [0.    0.002 0.004 0.006 0.008 0.01  0...\n",
       "    runs:                              [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 1...\n",
       "    scanAxis:                          [&#x27;compX_final_current&#x27; &#x27;runs&#x27;]\n",
       "    scanAxisLength:                    [33. 33.]</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-b9ae155a-cf09-4eb8-842a-5e3d68fb091f' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-b9ae155a-cf09-4eb8-842a-5e3d68fb091f' class='xr-section-summary'  title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>compX_final_current</span>: 11</li><li><span class='xr-has-index'>runs</span>: 3</li><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-17d8eed4-ed1b-4e5a-bcdc-3ad6bea77ff4' class='xr-section-summary-in' type='checkbox'  checked><label for='section-17d8eed4-ed1b-4e5a-bcdc-3ad6bea77ff4' class='xr-section-summary' >Coordinates: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>compX_final_current</span></div><div class='xr-var-dims'>(compX_final_current)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.0 0.002 0.004 ... 0.018 0.02</div><input id='attrs-863961cf-d72e-46e9-a866-67470bc1388c' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-863961cf-d72e-46e9-a866-67470bc1388c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-9344fd09-ba24-41d8-90ab-485ade4d6a91' class='xr-var-data-in' type='checkbox'><label for='data-9344fd09-ba24-41d8-90ab-485ade4d6a91' 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.002, 0.004, 0.006, 0.008, 0.01 , 0.012, 0.014, 0.016, 0.018,\n",
       "       0.02 ])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>runs</span></div><div class='xr-var-dims'>(runs)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.0 1.0 2.0</div><input id='attrs-907ea110-b888-4cd7-a485-3ca7076a8dc3' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-907ea110-b888-4cd7-a485-3ca7076a8dc3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-b6b9aa47-6f8c-484f-af8b-a8cafbff10be' class='xr-var-data-in' type='checkbox'><label for='data-b6b9aa47-6f8c-484f-af8b-a8cafbff10be' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([0., 1., 2.])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-6906b7c8-0730-4704-8b36-2414b062c545' class='xr-section-summary-in' type='checkbox'  checked><label for='section-6906b7c8-0730-4704-8b36-2414b062c545' 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'>(compX_final_current, runs, y, x)</div><div class='xr-var-dtype'>uint16</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(9, 3, 1200, 1920), meta=np.ndarray&gt;</div><input id='attrs-58fe1a57-5da5-4654-9b36-4d2bb4330969' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-58fe1a57-5da5-4654-9b36-4d2bb4330969' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-add8fc41-8deb-43d6-8742-8f88232b9f88' class='xr-var-data-in' type='checkbox'><label for='data-add8fc41-8deb-43d6-8742-8f88232b9f88' 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> 145.02 MiB </td>\n",
       "                        <td> 118.65 MiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (11, 3, 1200, 1920) </td>\n",
       "                        <td> (9, 3, 1200, 1920) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 2 chunks in 104 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=\"374\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"25\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"25\" x2=\"25\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"25\" />\n",
       "  <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 25.412616514582485,0.0 25.412616514582485,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"12.706308\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >11</text>\n",
       "  <text x=\"45.412617\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,45.412617,12.706308)\">1</text>\n",
       "\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"109\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"95\" y1=\"75\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"95\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"95.0,0.0 109.9485979497544,14.948597949754403 109.9485979497544,89.9485979497544 95.0,75.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"215\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"109\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"215\" y1=\"0\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"95.0,0.0 215.0,0.0 229.9485979497544,14.948597949754403 109.9485979497544,14.948597949754403\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"89\" x2=\"229\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"229\" y1=\"14\" x2=\"229\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"109.9485979497544,14.948597949754403 229.9485979497544,14.948597949754403 229.9485979497544,89.9485979497544 109.9485979497544,89.9485979497544\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"169.948598\" y=\"109.948598\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1920</text>\n",
       "  <text x=\"249.948598\" y=\"52.448598\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,249.948598,52.448598)\">1200</text>\n",
       "  <text x=\"92.474299\" y=\"102.474299\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,92.474299,102.474299)\">3</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'>(compX_final_current, runs, y, x)</div><div class='xr-var-dtype'>uint16</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(9, 3, 1200, 1920), meta=np.ndarray&gt;</div><input id='attrs-4f5a1e6d-f0bf-4445-86fa-05f123bf471c' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-4f5a1e6d-f0bf-4445-86fa-05f123bf471c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-97971573-5ecd-4996-b065-4771111ac722' class='xr-var-data-in' type='checkbox'><label for='data-97971573-5ecd-4996-b065-4771111ac722' 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> 145.02 MiB </td>\n",
       "                        <td> 118.65 MiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (11, 3, 1200, 1920) </td>\n",
       "                        <td> (9, 3, 1200, 1920) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 2 chunks in 104 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=\"374\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"25\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"25\" x2=\"25\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"25\" />\n",
       "  <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 25.412616514582485,0.0 25.412616514582485,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"12.706308\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >11</text>\n",
       "  <text x=\"45.412617\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,45.412617,12.706308)\">1</text>\n",
       "\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"109\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"95\" y1=\"75\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"95\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"95.0,0.0 109.9485979497544,14.948597949754403 109.9485979497544,89.9485979497544 95.0,75.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"215\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"109\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"215\" y1=\"0\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"95.0,0.0 215.0,0.0 229.9485979497544,14.948597949754403 109.9485979497544,14.948597949754403\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"89\" x2=\"229\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"229\" y1=\"14\" x2=\"229\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"109.9485979497544,14.948597949754403 229.9485979497544,14.948597949754403 229.9485979497544,89.9485979497544 109.9485979497544,89.9485979497544\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"169.948598\" y=\"109.948598\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1920</text>\n",
       "  <text x=\"249.948598\" y=\"52.448598\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,249.948598,52.448598)\">1200</text>\n",
       "  <text x=\"92.474299\" y=\"102.474299\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,92.474299,102.474299)\">3</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'>(compX_final_current, runs, y, x)</div><div class='xr-var-dtype'>uint16</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(9, 3, 1200, 1920), meta=np.ndarray&gt;</div><input id='attrs-03aad486-7c52-4d72-88c1-26a5ce472582' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-03aad486-7c52-4d72-88c1-26a5ce472582' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-dfe5474a-18e1-4e4a-8e5f-30cd418675c1' class='xr-var-data-in' type='checkbox'><label for='data-dfe5474a-18e1-4e4a-8e5f-30cd418675c1' 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> 145.02 MiB </td>\n",
       "                        <td> 118.65 MiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (11, 3, 1200, 1920) </td>\n",
       "                        <td> (9, 3, 1200, 1920) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 2 chunks in 104 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=\"374\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"25\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"25\" x2=\"25\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"25\" />\n",
       "  <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 25.412616514582485,0.0 25.412616514582485,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"12.706308\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >11</text>\n",
       "  <text x=\"45.412617\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,45.412617,12.706308)\">1</text>\n",
       "\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"109\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"95\" y1=\"75\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"95\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"95.0,0.0 109.9485979497544,14.948597949754403 109.9485979497544,89.9485979497544 95.0,75.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"215\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"109\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"215\" y1=\"0\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"95.0,0.0 215.0,0.0 229.9485979497544,14.948597949754403 109.9485979497544,14.948597949754403\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"89\" x2=\"229\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"229\" y1=\"14\" x2=\"229\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"109.9485979497544,14.948597949754403 229.9485979497544,14.948597949754403 229.9485979497544,89.9485979497544 109.9485979497544,89.9485979497544\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"169.948598\" y=\"109.948598\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1920</text>\n",
       "  <text x=\"249.948598\" y=\"52.448598\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,249.948598,52.448598)\">1200</text>\n",
       "  <text x=\"92.474299\" y=\"102.474299\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,92.474299,102.474299)\">3</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'>(compX_final_current, runs)</div><div class='xr-var-dtype'>&lt;U2</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(11, 3), meta=np.ndarray&gt;</div><input id='attrs-0fe8bb8f-ab0e-401f-a5aa-a4b4ada06ef2' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-0fe8bb8f-ab0e-401f-a5aa-a4b4ada06ef2' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-5dcb4741-d547-41e8-8edd-ccc10624b80a' class='xr-var-data-in' type='checkbox'><label for='data-5dcb4741-d547-41e8-8edd-ccc10624b80a' 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> 264 B </td>\n",
       "                        <td> 264 B </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (11, 3) </td>\n",
       "                        <td> (11, 3) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 1 chunks in 1 graph layer </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Data type </th>\n",
       "                        <td colspan=\"2\"> <U2 numpy.ndarray </td>\n",
       "                    </tr>\n",
       "                </tbody>\n",
       "            </table>\n",
       "        </td>\n",
       "        <td>\n",
       "        <svg width=\"93\" height=\"170\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"43\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"120\" x2=\"43\" y2=\"120\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"120\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"43\" y1=\"0\" x2=\"43\" y2=\"120\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 43.2160407718499,0.0 43.2160407718499,120.0 0.0,120.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"21.608020\" y=\"140.000000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >3</text>\n",
       "  <text x=\"63.216041\" y=\"60.000000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,63.216041,60.000000)\">11</text>\n",
       "</svg>\n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>OD</span></div><div class='xr-var-dims'>(compX_final_current, runs, y, x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(9, 3, 1200, 1920), meta=np.ndarray&gt;</div><input id='attrs-9b7351c0-40ea-46cb-87aa-81e82e2a9bd9' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-9b7351c0-40ea-46cb-87aa-81e82e2a9bd9' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-43315b10-c41f-435d-afd2-182f7bb50ddb' class='xr-var-data-in' type='checkbox'><label for='data-43315b10-c41f-435d-afd2-182f7bb50ddb' 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> 580.08 MiB </td>\n",
       "                        <td> 474.61 MiB </td>\n",
       "                    </tr>\n",
       "                    \n",
       "                    <tr>\n",
       "                        <th> Shape </th>\n",
       "                        <td> (11, 3, 1200, 1920) </td>\n",
       "                        <td> (9, 3, 1200, 1920) </td>\n",
       "                    </tr>\n",
       "                    <tr>\n",
       "                        <th> Dask graph </th>\n",
       "                        <td colspan=\"2\"> 2 chunks in 322 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=\"374\" height=\"139\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"25\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"0\" y1=\"25\" x2=\"25\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"25\" />\n",
       "  <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"0.0,0.0 25.412616514582485,0.0 25.412616514582485,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"12.706308\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >11</text>\n",
       "  <text x=\"45.412617\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,45.412617,12.706308)\">1</text>\n",
       "\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"109\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"95\" y1=\"75\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"95\" y2=\"75\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"95.0,0.0 109.9485979497544,14.948597949754403 109.9485979497544,89.9485979497544 95.0,75.0\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"215\" y2=\"0\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"95\" y1=\"0\" x2=\"109\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"215\" y1=\"0\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"95.0,0.0 215.0,0.0 229.9485979497544,14.948597949754403 109.9485979497544,14.948597949754403\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Horizontal lines -->\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"229\" y2=\"14\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"109\" y1=\"89\" x2=\"229\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Vertical lines -->\n",
       "  <line x1=\"109\" y1=\"14\" x2=\"109\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "  <line x1=\"229\" y1=\"14\" x2=\"229\" y2=\"89\" style=\"stroke-width:2\" />\n",
       "\n",
       "  <!-- Colored Rectangle -->\n",
       "  <polygon points=\"109.9485979497544,14.948597949754403 229.9485979497544,14.948597949754403 229.9485979497544,89.9485979497544 109.9485979497544,89.9485979497544\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
       "\n",
       "  <!-- Text -->\n",
       "  <text x=\"169.948598\" y=\"109.948598\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1920</text>\n",
       "  <text x=\"249.948598\" y=\"52.448598\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,249.948598,52.448598)\">1200</text>\n",
       "  <text x=\"92.474299\" y=\"102.474299\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,92.474299,102.474299)\">3</text>\n",
       "</svg>\n",
       "        </td>\n",
       "    </tr>\n",
       "</table></div></li></ul></div></li><li class='xr-section-item'><input id='section-a63ebf49-9886-4681-ba1a-6e4718d49545' class='xr-section-summary-in' type='checkbox'  ><label for='section-a63ebf49-9886-4681-ba1a-6e4718d49545' class='xr-section-summary' >Indexes: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>compX_final_current</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-67fac2f8-b2f6-4fb9-8d02-3c04ac6d24f9' class='xr-index-data-in' type='checkbox'/><label for='index-67fac2f8-b2f6-4fb9-8d02-3c04ac6d24f9' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Float64Index([0.0, 0.002, 0.004, 0.006, 0.008, 0.01, 0.012, 0.014, 0.016,\n",
       "              0.018, 0.02],\n",
       "             dtype=&#x27;float64&#x27;, name=&#x27;compX_final_current&#x27;))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>runs</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-fea26cbe-902d-436a-9a27-54039881eb60' class='xr-index-data-in' type='checkbox'/><label for='index-fea26cbe-902d-436a-9a27-54039881eb60' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Float64Index([0.0, 1.0, 2.0], dtype=&#x27;float64&#x27;, name=&#x27;runs&#x27;))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-5d03d618-2e62-4ba2-9cc6-da9ff33c423f' class='xr-section-summary-in' type='checkbox'  ><label for='section-5d03d618-2e62-4ba2-9cc6-da9ff33c423f' class='xr-section-summary' >Attributes: <span>(120)</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.022</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>0.001</dd><dt><span>blink_on_time :</span></dt><dd>0.001</dd><dt><span>c_duration :</span></dt><dd>0.2</dd><dt><span>carrier_amp :</span></dt><dd>3</dd><dt><span>carrier_freq :</span></dt><dd>0.85</dd><dt><span>carrier_offset :</span></dt><dd>0</dd><dt><span>carrier_phase :</span></dt><dd>0</dd><dt><span>channel_in_use :</span></dt><dd>1</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</dd><dt><span>compX_current_sg :</span></dt><dd>0.0</dd><dt><span>compX_initial_current :</span></dt><dd>0</dd><dt><span>compY_current :</span></dt><dd>0</dd><dt><span>compY_current_sg :</span></dt><dd>0.0</dd><dt><span>compY_final_current :</span></dt><dd>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.264</dd><dt><span>compZ_initial_current :</span></dt><dd>0</dd><dt><span>default_camera :</span></dt><dd>0</dd><dt><span>deltaf :</span></dt><dd>0.161</dd><dt><span>evap_1_arm_1_final_pow :</span></dt><dd>0.35</dd><dt><span>evap_1_arm_1_mod_depth_final :</span></dt><dd>0</dd><dt><span>evap_1_arm_1_mod_depth_initial :</span></dt><dd>1.0</dd><dt><span>evap_1_arm_1_mod_ramp_duration :</span></dt><dd>1.15</dd><dt><span>evap_1_arm_1_pow_ramp_duration :</span></dt><dd>1.65</dd><dt><span>evap_1_arm_1_start_pow :</span></dt><dd>7</dd><dt><span>evap_1_arm_2_final_pow :</span></dt><dd>5</dd><dt><span>evap_1_arm_2_ramp_duration :</span></dt><dd>0.5</dd><dt><span>evap_1_arm_2_start_pow :</span></dt><dd>0</dd><dt><span>evap_1_mod_ramp_trunc_value :</span></dt><dd>1</dd><dt><span>evap_1_pow_ramp_trunc_value :</span></dt><dd>1.0</dd><dt><span>evap_1_rate_constant_1 :</span></dt><dd>0.525</dd><dt><span>evap_1_rate_constant_2 :</span></dt><dd>0.51</dd><dt><span>evap_2_arm_1_final_pow :</span></dt><dd>0.037</dd><dt><span>evap_2_arm_1_start_pow :</span></dt><dd>0.35</dd><dt><span>evap_2_arm_2_final_pow :</span></dt><dd>0.09</dd><dt><span>evap_2_arm_2_start_pow :</span></dt><dd>5</dd><dt><span>evap_2_ramp_duration :</span></dt><dd>1.0</dd><dt><span>evap_2_ramp_trunc_value :</span></dt><dd>1.0</dd><dt><span>evap_2_rate_constant_1 :</span></dt><dd>0.37</dd><dt><span>evap_2_rate_constant_2 :</span></dt><dd>0.71</dd><dt><span>evap_3_arm_1_final_pow :</span></dt><dd>0.1038</dd><dt><span>evap_3_arm_1_mod_depth_final :</span></dt><dd>0.43</dd><dt><span>evap_3_arm_1_mod_depth_initial :</span></dt><dd>0</dd><dt><span>evap_3_arm_1_start_pow :</span></dt><dd>0.037</dd><dt><span>evap_3_ramp_duration :</span></dt><dd>0.1</dd><dt><span>evap_3_ramp_trunc_value :</span></dt><dd>1.0</dd><dt><span>evap_3_rate_constant_1 :</span></dt><dd>-0.879</dd><dt><span>evap_3_rate_constant_2 :</span></dt><dd>-0.297</dd><dt><span>final_amp :</span></dt><dd>0.00012</dd><dt><span>final_freq :</span></dt><dd>104.0</dd><dt><span>final_pow_1 :</span></dt><dd>0.1038</dd><dt><span>final_pow_2 :</span></dt><dd>0.09</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_fin :</span></dt><dd>0.43</dd><dt><span>mod_depth_ini :</span></dt><dd>0</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_trigger_duration :</span></dt><dd>0.00025</dd><dt><span>mot_3d_freq :</span></dt><dd>102.13</dd><dt><span>mot_load_duration :</span></dt><dd>2</dd><dt><span>odt_axis_camera_trigger_duration :</span></dt><dd>0.002</dd><dt><span>odt_hold_time_1 :</span></dt><dd>0.01</dd><dt><span>odt_hold_time_2 :</span></dt><dd>0.1</dd><dt><span>odt_hold_time_3 :</span></dt><dd>0.1</dd><dt><span>odt_hold_time_4 :</span></dt><dd>1.0</dd><dt><span>odt_hold_time_5 :</span></dt><dd>0.01</dd><dt><span>operation_mode :</span></dt><dd>SWEEP</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>pulse_width :</span></dt><dd>0.01</dd><dt><span>push_amp :</span></dt><dd>0.16</dd><dt><span>push_freq :</span></dt><dd>102.66</dd><dt><span>ramp_duration :</span></dt><dd>1</dd><dt><span>recomp_ramp_duration :</span></dt><dd>0.5</dd><dt><span>recomp_ramp_pow_fin_arm_1 :</span></dt><dd>0.1038</dd><dt><span>recomp_ramp_pow_fin_arm_2 :</span></dt><dd>0.09</dd><dt><span>recomp_ramp_pow_ini_arm_1 :</span></dt><dd>0.1038</dd><dt><span>recomp_ramp_pow_ini_arm_2 :</span></dt><dd>0.09</dd><dt><span>save_results :</span></dt><dd>False</dd><dt><span>sin_mod_amplitude :</span></dt><dd>0.00519</dd><dt><span>sin_mod_dc_offset :</span></dt><dd>0.1038</dd><dt><span>sin_mod_duration :</span></dt><dd>nan</dd><dt><span>sin_mod_freq :</span></dt><dd>nan</dd><dt><span>sin_mod_phase :</span></dt><dd>0.0</dd><dt><span>start_pow_1 :</span></dt><dd>0.037</dd><dt><span>start_pow_2 :</span></dt><dd>0.09</dd><dt><span>stern_gerlach_duration :</span></dt><dd>0.001</dd><dt><span>sweep_duration :</span></dt><dd>0.4</dd><dt><span>sweep_start_freq :</span></dt><dd>0.7695</dd><dt><span>sweep_stop_freq :</span></dt><dd>0.9305</dd><dt><span>tf_meas_ramp_duration :</span></dt><dd>0.1</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>wavetype :</span></dt><dd>SINE</dd><dt><span>x_offset :</span></dt><dd>0.0</dd><dt><span>x_offset_img :</span></dt><dd>0</dd><dt><span>y_offset :</span></dt><dd>0.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>compX_final_current :</span></dt><dd>[0.    0.002 0.004 0.006 0.008 0.01  0.012 0.014 0.016 0.018 0.02  0.\n",
       " 0.002 0.004 0.006 0.008 0.01  0.012 0.014 0.016 0.018 0.02  0.    0.002\n",
       " 0.004 0.006 0.008 0.01  0.012 0.014 0.016 0.018 0.02 ]</dd><dt><span>runs :</span></dt><dd>[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 2. 2.\n",
       " 2. 2. 2. 2. 2. 2. 2. 2. 2.]</dd><dt><span>scanAxis :</span></dt><dd>[&#x27;compX_final_current&#x27; &#x27;runs&#x27;]</dd><dt><span>scanAxisLength :</span></dt><dd>[33. 33.]</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:              (compX_final_current: 11, runs: 3, y: 1200, x: 1920)\n",
       "Coordinates:\n",
       "  * compX_final_current  (compX_final_current) float64 0.0 0.002 ... 0.018 0.02\n",
       "  * runs                 (runs) float64 0.0 1.0 2.0\n",
       "Dimensions without coordinates: y, x\n",
       "Data variables:\n",
       "    atoms                (compX_final_current, runs, y, x) uint16 dask.array<chunksize=(9, 3, 1200, 1920), meta=np.ndarray>\n",
       "    background           (compX_final_current, runs, y, x) uint16 dask.array<chunksize=(9, 3, 1200, 1920), meta=np.ndarray>\n",
       "    dark                 (compX_final_current, runs, y, x) uint16 dask.array<chunksize=(9, 3, 1200, 1920), meta=np.ndarray>\n",
       "    shotNum              (compX_final_current, runs) <U2 dask.array<chunksize=(11, 3), meta=np.ndarray>\n",
       "    OD                   (compX_final_current, runs, y, x) float64 dask.array<chunksize=(9, 3, 1200, 1920), meta=np.ndarray>\n",
       "Attributes: (12/120)\n",
       "    TOF_free:                          0.022\n",
       "    abs_img_freq:                      110.858\n",
       "    absorption_imaging_flag:           True\n",
       "    backup_data:                       True\n",
       "    blink_off_time:                    0.001\n",
       "    blink_on_time:                     0.001\n",
       "    ...                                ...\n",
       "    z_offset:                          0.189\n",
       "    z_offset_img:                      0.189\n",
       "    compX_final_current:               [0.    0.002 0.004 0.006 0.008 0.01  0...\n",
       "    runs:                              [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 1...\n",
       "    scanAxis:                          ['compX_final_current' 'runs']\n",
       "    scanAxisLength:                    [33. 33.]"
      ]
     },
     "execution_count": 15,
     "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_08.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"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calculate an plot OD images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 2506636 characters]",
      "text/plain": [
       "<Figure size 3400x900 with 34 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()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "from DataContainer.MongoDB import MongoDB\n",
    "\n",
    "DB = MongoDB(mongoClient, mongoDB, date='2023/05/23')\n",
    "\n",
    "DB.create_global('0069', dataSet)\n",
    "\n",
    "DB.read_global_all('0069')\n",
    "\n",
    "DB.add_data('0069', dataSet_cropOD, engine='xarray')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'TOF_free': 0.022,\n",
       " 'abs_img_freq': 110.858,\n",
       " 'absorption_imaging_flag': True,\n",
       " 'backup_data': True,\n",
       " 'blink_off_time': 0.001,\n",
       " 'blink_on_time': 0.001,\n",
       " 'c_duration': 0.2,\n",
       " 'carrier_amp': 3,\n",
       " 'carrier_freq': 0.85,\n",
       " 'carrier_offset': 0,\n",
       " 'carrier_phase': 0,\n",
       " 'channel_in_use': 1,\n",
       " 'cmot_final_current': 0.65,\n",
       " 'cmot_hold': 0.06,\n",
       " 'cmot_initial_current': 0.18,\n",
       " 'compX_current': 0,\n",
       " 'compX_current_sg': 0.0,\n",
       " 'compX_initial_current': 0,\n",
       " 'compY_current': 0,\n",
       " 'compY_current_sg': 0.0,\n",
       " 'compY_final_current': 0,\n",
       " 'compY_initial_current': 0,\n",
       " 'compZ_current': 0,\n",
       " 'compZ_current_sg': 0.189,\n",
       " 'compZ_final_current': 0.264,\n",
       " 'compZ_initial_current': 0,\n",
       " 'default_camera': 0,\n",
       " 'deltaf': 0.161,\n",
       " 'evap_1_arm_1_final_pow': 0.35,\n",
       " 'evap_1_arm_1_mod_depth_final': 0,\n",
       " 'evap_1_arm_1_mod_depth_initial': 1.0,\n",
       " 'evap_1_arm_1_mod_ramp_duration': 1.15,\n",
       " 'evap_1_arm_1_pow_ramp_duration': 1.65,\n",
       " 'evap_1_arm_1_start_pow': 7,\n",
       " 'evap_1_arm_2_final_pow': 5,\n",
       " 'evap_1_arm_2_ramp_duration': 0.5,\n",
       " 'evap_1_arm_2_start_pow': 0,\n",
       " 'evap_1_mod_ramp_trunc_value': 1,\n",
       " 'evap_1_pow_ramp_trunc_value': 1.0,\n",
       " 'evap_1_rate_constant_1': 0.525,\n",
       " 'evap_1_rate_constant_2': 0.51,\n",
       " 'evap_2_arm_1_final_pow': 0.037,\n",
       " 'evap_2_arm_1_start_pow': 0.35,\n",
       " 'evap_2_arm_2_final_pow': 0.09,\n",
       " 'evap_2_arm_2_start_pow': 5,\n",
       " 'evap_2_ramp_duration': 1.0,\n",
       " 'evap_2_ramp_trunc_value': 1.0,\n",
       " 'evap_2_rate_constant_1': 0.37,\n",
       " 'evap_2_rate_constant_2': 0.71,\n",
       " 'evap_3_arm_1_final_pow': 0.1038,\n",
       " 'evap_3_arm_1_mod_depth_final': 0.43,\n",
       " 'evap_3_arm_1_mod_depth_initial': 0,\n",
       " 'evap_3_arm_1_start_pow': 0.037,\n",
       " 'evap_3_ramp_duration': 0.1,\n",
       " 'evap_3_ramp_trunc_value': 1.0,\n",
       " 'evap_3_rate_constant_1': -0.879,\n",
       " 'evap_3_rate_constant_2': -0.297,\n",
       " 'final_amp': 0.00012,\n",
       " 'final_freq': 104.0,\n",
       " 'final_pow_1': 0.1038,\n",
       " 'final_pow_2': 0.09,\n",
       " 'gradCoil_current': 0.18,\n",
       " 'gradCoil_current_sg': 0,\n",
       " 'imaging_method': 'in_situ_absorption',\n",
       " 'imaging_pulse_duration': 2.5e-05,\n",
       " 'imaging_wavelength': 4.21291e-07,\n",
       " 'initial_amp': 0.62,\n",
       " 'initial_freq': 102.13,\n",
       " 'mod_depth_fin': 0.43,\n",
       " 'mod_depth_ini': 0,\n",
       " 'mod_depth_initial': 1.0,\n",
       " 'mot_3d_amp': 0.62,\n",
       " 'mot_3d_camera_trigger_duration': 0.00025,\n",
       " 'mot_3d_freq': 102.13,\n",
       " 'mot_load_duration': 2,\n",
       " 'odt_axis_camera_trigger_duration': 0.002,\n",
       " 'odt_hold_time_1': 0.01,\n",
       " 'odt_hold_time_2': 0.1,\n",
       " 'odt_hold_time_3': 0.1,\n",
       " 'odt_hold_time_4': 1.0,\n",
       " 'odt_hold_time_5': 0.01,\n",
       " 'operation_mode': 'SWEEP',\n",
       " 'pow_arm_1': 7,\n",
       " 'pow_arm_2': 0,\n",
       " 'pulse_delay': 8e-05,\n",
       " 'pulse_width': 0.01,\n",
       " 'push_amp': 0.16,\n",
       " 'push_freq': 102.66,\n",
       " 'ramp_duration': 1,\n",
       " 'recomp_ramp_duration': 0.5,\n",
       " 'recomp_ramp_pow_fin_arm_1': 0.1038,\n",
       " 'recomp_ramp_pow_fin_arm_2': 0.09,\n",
       " 'recomp_ramp_pow_ini_arm_1': 0.1038,\n",
       " 'recomp_ramp_pow_ini_arm_2': 0.09,\n",
       " 'save_results': False,\n",
       " 'sin_mod_amplitude': 0.00519,\n",
       " 'sin_mod_dc_offset': 0.1038,\n",
       " 'sin_mod_duration': nan,\n",
       " 'sin_mod_freq': nan,\n",
       " 'sin_mod_phase': 0.0,\n",
       " 'start_pow_1': 0.037,\n",
       " 'start_pow_2': 0.09,\n",
       " 'stern_gerlach_duration': 0.001,\n",
       " 'sweep_duration': 0.4,\n",
       " 'sweep_start_freq': 0.7695,\n",
       " 'sweep_stop_freq': 0.9305,\n",
       " 'tf_meas_ramp_duration': 0.1,\n",
       " 'wait_after_2dmot_off': 0,\n",
       " 'wait_time_between_images': 0.22,\n",
       " 'wavetype': 'SINE',\n",
       " 'x_offset': 0.0,\n",
       " 'x_offset_img': 0,\n",
       " 'y_offset': 0.0,\n",
       " 'y_offset_img': 0,\n",
       " 'z_offset': 0.189,\n",
       " 'z_offset_img': 0.189,\n",
       " 'compX_final_current': array([0.   , 0.002, 0.004, 0.006, 0.008, 0.01 , 0.012, 0.014, 0.016,\n",
       "        0.018, 0.02 , 0.   , 0.002, 0.004, 0.006, 0.008, 0.01 , 0.012,\n",
       "        0.014, 0.016, 0.018, 0.02 , 0.   , 0.002, 0.004, 0.006, 0.008,\n",
       "        0.01 , 0.012, 0.014, 0.016, 0.018, 0.02 ]),\n",
       " 'runs': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1.,\n",
       "        1., 1., 1., 1., 1., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.]),\n",
       " 'scanAxis': ['compX_final_current', 'runs'],\n",
       " 'scanAxisLength': array([33., 33.])}"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DB.read_global_all('0069')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'OD': <xarray.DataArray 'OD' (y: 300, x: 300)>\n",
       " array([[-0.16156055, -0.05236126, -0.06646893, ..., -0.00193041,\n",
       "         -0.04918329, -0.00193041],\n",
       "        [-0.05072057,  0.01406993, -0.00193041, ...,  0.04252135,\n",
       "         -0.03091795,  0.10034844],\n",
       "        [-0.069753  , -0.06862178, -0.12908558, ...,  0.04187221,\n",
       "         -0.00193041, -0.07390391],\n",
       "        ...,\n",
       "        [ 0.12868977, -0.02390931, -0.00193041, ...,  0.01487671,\n",
       "          0.07562783,  0.10343011],\n",
       "        [ 0.09570806,  0.11247994, -0.04739278, ...,  0.01288468,\n",
       "         -0.04845042,  0.02981829],\n",
       "        [ 0.20392165,  0.07039025, -0.04955846, ...,  0.02792256,\n",
       "         -0.12976378, -0.03367911]])\n",
       " Coordinates:\n",
       "     compX_final_current  float64 0.002\n",
       "     runs                 float64 0.0\n",
       " Dimensions without coordinates: y, x\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": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res = DB.load_data_single('0069', 1, field={'OD':None})\n",
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from collections import OrderedDict\n",
    "\n",
    "import numpy as np\n",
    "import pymongo\n",
    "import xarray_mongodb\n",
    "import bson\n",
    "import builtins\n",
    "\n",
    "import xarray as xr\n",
    "\n",
    "from ToolFunction.ToolFunction import get_date\n",
    "\n",
    "\n",
    "npTypeDict = {v: getattr(builtins, k) for k, v in np.sctypeDict.items() if k in vars(builtins)}\n",
    "npArrayType = type(np.array([0]))\n",
    "\n",
    "\n",
    "class MongoDB:\n",
    "    \n",
    "    def __init__(self, mongoClient, mongoDB, date=None) -> None:\n",
    "        self.mongoClient = mongoClient\n",
    "        self.mongoDB = mongoDB\n",
    "        self.xdb = xarray_mongodb.XarrayMongoDB(mongoDB)\n",
    "        \n",
    "        if date is None:\n",
    "            date= get_date()\n",
    "        self.set_date(date)\n",
    "        \n",
    "    def _convert_numpy_type(self, data):\n",
    "        for key in data:\n",
    "            typeKey = type(data[key])\n",
    "            if typeKey in npTypeDict:\n",
    "                data[key] = data[key].item()\n",
    "            elif typeKey == npArrayType:\n",
    "                data[key] = data[key].tolist()\n",
    "            else:\n",
    "                try:\n",
    "                    data[key] = data[key].item()\n",
    "                except:\n",
    "                    pass\n",
    "        return data\n",
    "    \n",
    "    def _break_dataSet(self, dataSet, scanAxis=None):\n",
    "        \n",
    "        if scanAxis is None:\n",
    "            scanAxis = dataSet.attrs['scanAxis'] \n",
    "            \n",
    "        dataArray = dataSet.shotNum\n",
    "            \n",
    "        stackedDataArray = dataArray.stack(_scanAxis=tuple(scanAxis))          \n",
    "\n",
    "        return stackedDataArray\n",
    "        \n",
    "    def set_date(self, date):\n",
    "        date = date.split(\"/\")\n",
    "        self.year = int(date[0])\n",
    "        self.month = int(date[1])\n",
    "        self.day = int(date[2])\n",
    "        \n",
    "    def create_global(self, shotNum, dataSet=None, date=None):\n",
    "        if not date is None:\n",
    "            self.set_date(date)\n",
    "        \n",
    "        data = {\n",
    "            'year': self.year,\n",
    "            'month': self.month,\n",
    "            'day': self.day,\n",
    "            'shotNum': shotNum,\n",
    "        }\n",
    "\n",
    "        self.mongoDB['global'].delete_many(data)\n",
    "        \n",
    "        data = {\n",
    "            'year': self.year,\n",
    "            'month': self.month,\n",
    "            'day': self.day,\n",
    "            'shotNum': shotNum,\n",
    "            'runNum': 0,\n",
    "            'global_parameters' : {},\n",
    "        }\n",
    "        \n",
    "        global_parameters = self._convert_numpy_type(dataSet.attrs)\n",
    "        \n",
    "        if not dataSet is None:\n",
    "            data['global_parameters'].update(global_parameters)\n",
    "          \n",
    "        data = self._convert_numpy_type(data)\n",
    "        \n",
    "        if 'scanAxis' in dataSet.attrs:\n",
    "            \n",
    "            del data['global_parameters']['scanAxis']\n",
    "            del data['global_parameters']['scanAxisLength']\n",
    "            \n",
    "            scanAxis = dataSet.attrs['scanAxis']\n",
    "            data['global_parameters'].update(\n",
    "                {\n",
    "                    key:0\n",
    "                    for key in scanAxis\n",
    "                }\n",
    "            )\n",
    "            \n",
    "            stackedDataArray = self._break_dataSet(dataSet)\n",
    "            try:\n",
    "                stackedDataArray.load()\n",
    "            except:\n",
    "                pass\n",
    "            \n",
    "            stackedDataArray = stackedDataArray.groupby('_scanAxis')\n",
    "            \n",
    "            for i in stackedDataArray:\n",
    "                \n",
    "                stackedDataArray_single = i[1]\n",
    "                \n",
    "                data.update(\n",
    "                    {\n",
    "                        'runNum': int(stackedDataArray_single.item())\n",
    "                    }\n",
    "                )\n",
    "                \n",
    "                data['global_parameters'].update(\n",
    "                    {\n",
    "                        key: stackedDataArray_single[key].item()\n",
    "                        for key in scanAxis\n",
    "                    }\n",
    "                )\n",
    "                \n",
    "                if '_id' in data:\n",
    "                    del data['_id']\n",
    "                \n",
    "                self.mongoDB['global'].insert_one(data)\n",
    "        \n",
    "        else:\n",
    "            self.mongoDB['global'].insert_one(data)\n",
    "    \n",
    "    def _add_data_normal(self, shotNum, runNum, data):\n",
    "        \n",
    "        if runNum is None:\n",
    "            runNum = 0\n",
    "        \n",
    "        filter = {   \n",
    "            'year': self.year,\n",
    "            'month': self.month,\n",
    "            'day': self.day,\n",
    "            'shotNum': shotNum,\n",
    "            'runNum': runNum,\n",
    "        }\n",
    "        \n",
    "        self.mongoDB['global'].update_one(filter, {\"$set\": data}, upsert=False)\n",
    "        \n",
    "    def _add_data_xarray_dataArray(self, shotNum, dataArray, name=None, scanAxis=None):\n",
    "        \n",
    "        if scanAxis is None:\n",
    "            scanAxis = list(dataArray.coords)\n",
    "            \n",
    "        dataArray.attrs = self._convert_numpy_type(dataArray.attrs)\n",
    "            \n",
    "        stackedDataArray = dataArray.stack(_scanAxis=tuple(scanAxis))\n",
    "        stackedDataArray = stackedDataArray.groupby('_scanAxis')\n",
    "        \n",
    "        filter = {   \n",
    "                'year': self.year,\n",
    "                'month': self.month,\n",
    "                'day': self.day,\n",
    "                'shotNum': shotNum,\n",
    "            }\n",
    "        \n",
    "        for i in stackedDataArray:\n",
    "            \n",
    "            stackedDataArray_single = i[1].drop('_scanAxis')\n",
    "            \n",
    "            global_parameters = {\n",
    "                'global_parameters.' + key: stackedDataArray_single[key].item()\n",
    "                for key in scanAxis\n",
    "            }\n",
    "\n",
    "            filter.update(global_parameters)\n",
    "            \n",
    "            mongoID, _ = self.xdb.put(stackedDataArray_single)\n",
    "            \n",
    "            data_label = {\n",
    "                dataArray.name: \n",
    "                    {\n",
    "                        'name': dataArray.name,\n",
    "                        'mongoID': mongoID,\n",
    "                        'engine': 'xarray',\n",
    "                        'dtype': 'dataArray',\n",
    "                    }\n",
    "            }\n",
    "            \n",
    "            self.mongoDB['global'].update_one(filter, {\"$set\": data_label}, upsert=False)\n",
    "    \n",
    "    def _add_data_xarray_dataSet(self, shotNum, dataSet, name, scanAxis=None):\n",
    "        \n",
    "        if scanAxis is None:\n",
    "            scanAxis = list(dataSet.coords)\n",
    "            \n",
    "        dataSet.attrs = self._convert_numpy_type(dataSet.attrs)\n",
    "        \n",
    "        for key in list(dataSet.data_vars):\n",
    "            dataSet[key].attrs = self._convert_numpy_type(dataSet[key].attrs)\n",
    "            \n",
    "        stackedDataSet = dataSet.stack(_scanAxis=tuple(scanAxis))\n",
    "        stackedDataSet = stackedDataSet.groupby('_scanAxis')\n",
    "        \n",
    "        filter = {   \n",
    "            'year': self.year,\n",
    "            'month': self.month,\n",
    "            'day': self.day,\n",
    "            'shotNum': shotNum,\n",
    "        }\n",
    "        \n",
    "        for i in stackedDataSet:\n",
    "            \n",
    "            stackedDataSet_single = i[1].drop('_scanAxis')\n",
    "            \n",
    "            global_parameters = {\n",
    "                'global_parameters.' + key: stackedDataSet_single[key].item()\n",
    "                for key in scanAxis\n",
    "            }\n",
    "\n",
    "            filter.update(global_parameters)\n",
    "        \n",
    "            mongoID, _ = self.xdb.put(dataSet)\n",
    "        \n",
    "            data_label = {\n",
    "                name: \n",
    "                    {\n",
    "                        'name': name,\n",
    "                        'mongoID': mongoID,\n",
    "                        'engine': 'xarray',\n",
    "                        'dtype': 'dataSet',\n",
    "                    }\n",
    "            }\n",
    "        \n",
    "            self.mongoDB['global'].update_one(filter, {\"$set\": data_label}, upsert=False)\n",
    "    \n",
    "    def _add_data_additional(self, shotNum, runNum, data, name):\n",
    "        \n",
    "        if runNum is None:\n",
    "            runNum = 0\n",
    "        \n",
    "        filter = {   \n",
    "            'year': self.year,\n",
    "            'month': self.month,\n",
    "            'day': self.day,\n",
    "            'shotNum': shotNum,\n",
    "            'runNum': runNum,\n",
    "        }\n",
    "        \n",
    "        mongoID = self.mongoDB.additional.insert_one(data).inserted_id\n",
    "        \n",
    "        data_label = {\n",
    "            name: \n",
    "                {\n",
    "                    'name': name,\n",
    "                    'mongoID': mongoID,\n",
    "                    'engine': 'additional',\n",
    "                    'dtype': 'dict',\n",
    "                }\n",
    "        }\n",
    "        \n",
    "        self.mongoDB['global'].update_one(filter, {\"$set\": data_label}, upsert=False)\n",
    "        \n",
    "    def add_data(self, shotNum, data, runNum=None, date=None, name=None, engine='normal'):\n",
    "        if not date is None:\n",
    "            self.set_date(date)\n",
    "            \n",
    "        if engine == 'normal':\n",
    "            self._add_data_normal(shotNum=shotNum, runNum=runNum, data=data)\n",
    "        elif engine == 'xarray':\n",
    "            if isinstance(data, type(xr.Dataset())):\n",
    "                self._add_data_xarray_dataSet(shotNum=shotNum, dataSet=data, name=name)\n",
    "            else:\n",
    "                self._add_data_xarray_dataArray(shotNum=shotNum, dataArray=data, name=name)\n",
    "        elif engine == 'additional':\n",
    "            self._add_data_additional(shotNum=shotNum, runNum=runNum, data=data, name=name)\n",
    "    \n",
    "    def read_global_single(self, shotNum, runNum, date=None):\n",
    "        \n",
    "        if not date is None:\n",
    "            self.set_date(date)\n",
    "        \n",
    "        filter = {   \n",
    "            'year': self.year,\n",
    "            'month': self.month,\n",
    "            'day': self.day,\n",
    "            'shotNum': shotNum,\n",
    "            'runNum': runNum,\n",
    "        }\n",
    "        \n",
    "        return self.mongoDB['global'].find_one(filter)\n",
    "    \n",
    "    def read_global_all(self, shotNum, date=None):\n",
    "        \n",
    "        from xarray.core.utils import equivalent\n",
    "        \n",
    "        if not date is None:\n",
    "            self.set_date(date)\n",
    "        \n",
    "        filter = {   \n",
    "            'year': self.year,\n",
    "            'month': self.month,\n",
    "            'day': self.day,\n",
    "            'shotNum': shotNum,\n",
    "        }\n",
    "        \n",
    "        result = {}\n",
    "        dropped_attrs = OrderedDict()\n",
    "        \n",
    "        docs = self.mongoDB['global'].find(filter).sort('runNum')\n",
    "        docs = [doc['global_parameters'] for doc in docs]\n",
    "        \n",
    "        for doc in docs:\n",
    "            \n",
    "            global_parameters = doc\n",
    "            \n",
    "            result.update(\n",
    "                {\n",
    "                    key: value\n",
    "                    for key, value in global_parameters.items()\n",
    "                    if key not in result and key not in dropped_attrs.keys()\n",
    "                }\n",
    "            )\n",
    "            \n",
    "            result = {\n",
    "                key: value\n",
    "                for key, value in result.items()\n",
    "                if key not in global_parameters or equivalent(global_parameters[key], value)\n",
    "            }\n",
    "            \n",
    "            dropped_attrs.update(\n",
    "                {\n",
    "                    key: []\n",
    "                    for key in global_parameters if key not in result \n",
    "                }\n",
    "            )\n",
    "            \n",
    "        for doc in docs:\n",
    "            \n",
    "            global_parameters = doc\n",
    "            \n",
    "            dropped_attrs.update(\n",
    "                {\n",
    "                    key: np.append(dropped_attrs[key], global_parameters[key])\n",
    "                    for key in dropped_attrs.keys()\n",
    "                }\n",
    "            )        \n",
    "    \n",
    "        scan_attrs = OrderedDict()\n",
    "        scan_length = []\n",
    "        \n",
    "        for attrs_key in dropped_attrs.keys():\n",
    "            flag = True\n",
    "            for key in scan_attrs.keys():\n",
    "                if equivalent(scan_attrs[key], dropped_attrs[attrs_key]):\n",
    "                    flag = False\n",
    "                    result.update({attrs_key: key})\n",
    "                break\n",
    "            if flag:\n",
    "                scan_attrs.update({\n",
    "                    attrs_key: dropped_attrs[attrs_key]\n",
    "                })\n",
    "                scan_length = np.append(scan_length, len(dropped_attrs[attrs_key]))\n",
    "\n",
    "        result.update(\n",
    "            {\n",
    "                key: value\n",
    "                for key, value in scan_attrs.items()\n",
    "            }\n",
    "        )\n",
    "\n",
    "        result.update(\n",
    "            {\n",
    "                \"scanAxis\": list(scan_attrs.keys()),\n",
    "                \"scanAxisLength\": scan_length,\n",
    "            }\n",
    "        )\n",
    "\n",
    "        return result\n",
    "    \n",
    "    def _load_data_single(self, mongoID, engine):\n",
    "        if engine == 'xarray':\n",
    "            return self.xdb.get(mongoID)\n",
    "        if engine == 'additional':\n",
    "            return self.mongoDB.additional.find_one({'_id': mongoID})\n",
    "    \n",
    "    def load_data_single(self, shotNum=None, runNum=None, globalDict=None, date=None, field=None):\n",
    "        \n",
    "        if not date is None:\n",
    "            self.set_date(date)\n",
    "        \n",
    "        if globalDict is None:\n",
    "            globalDict = self.read_global_single(shotNum=shotNum, runNum=runNum)\n",
    "        \n",
    "        if field is None:\n",
    "            field = globalDict\n",
    "        \n",
    "        res = {}\n",
    "        \n",
    "        for key in field:\n",
    "            if isinstance(globalDict[key], dict) and ('mongoID' in globalDict[key]):\n",
    "                mongoID = globalDict[key]['mongoID']\n",
    "                engine = globalDict[key]['engine']\n",
    "                \n",
    "                res.update(\n",
    "                    {\n",
    "                        key: self._load_data_single(mongoID=mongoID, engine=engine)\n",
    "                    }\n",
    "                )\n",
    "                \n",
    "        return res\n",
    "                \n",
    "    def load_data(self, shotNum=None, globalDict=None, date=None, field=None):\n",
    "        pass\n",
    "    \n",
    "DB = MongoDB(mongoClient, mongoDB, date='2023/05/23')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "res = DB.load_data_single(shotNum='0069', field=['test'])\n",
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "DB.add_data('0069', dataSet_cropOD, engine='xarray')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {\n",
    "    'test':100\n",
    "}\n",
    "DB._add_data_additional(shotNum, data, name='test')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "DB._add_data_xarray_dataArray(shotNum, dataSet_cropOD)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test = DB._convert_numpy_type(dataSet.OD.attrs)\n",
    "\n",
    "type(test['IMAGE_WHITE_IS_ZERO'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "type(dataSet.OD.attrs['IMAGE_WHITE_IS_ZERO'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "DB._add_data_xarray_dataSet(shotNum, dataSet, 'aaa')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "xdb.put(dataSet_cropOD)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "DB.create_global(shotNum, dataSet)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'TOF_free': 0.022,\n",
       " 'abs_img_freq': 110.858,\n",
       " 'absorption_imaging_flag': True,\n",
       " 'backup_data': True,\n",
       " 'blink_off_time': 0.001,\n",
       " 'blink_on_time': 0.001,\n",
       " 'c_duration': 0.2,\n",
       " 'carrier_amp': 3,\n",
       " 'carrier_freq': 0.85,\n",
       " 'carrier_offset': 0,\n",
       " 'carrier_phase': 0,\n",
       " 'channel_in_use': 1,\n",
       " 'cmot_final_current': 0.65,\n",
       " 'cmot_hold': 0.06,\n",
       " 'cmot_initial_current': 0.18,\n",
       " 'compX_current': 0,\n",
       " 'compX_current_sg': 0.0,\n",
       " 'compX_initial_current': 0,\n",
       " 'compY_current': 0,\n",
       " 'compY_current_sg': 0.0,\n",
       " 'compY_final_current': 0,\n",
       " 'compY_initial_current': 0,\n",
       " 'compZ_current': 0,\n",
       " 'compZ_current_sg': 0.189,\n",
       " 'compZ_final_current': 0.264,\n",
       " 'compZ_initial_current': 0,\n",
       " 'default_camera': 0,\n",
       " 'deltaf': 0.161,\n",
       " 'evap_1_arm_1_final_pow': 0.35,\n",
       " 'evap_1_arm_1_mod_depth_final': 0,\n",
       " 'evap_1_arm_1_mod_depth_initial': 1.0,\n",
       " 'evap_1_arm_1_mod_ramp_duration': 1.15,\n",
       " 'evap_1_arm_1_pow_ramp_duration': 1.65,\n",
       " 'evap_1_arm_1_start_pow': 7,\n",
       " 'evap_1_arm_2_final_pow': 5,\n",
       " 'evap_1_arm_2_ramp_duration': 0.5,\n",
       " 'evap_1_arm_2_start_pow': 0,\n",
       " 'evap_1_mod_ramp_trunc_value': 1,\n",
       " 'evap_1_pow_ramp_trunc_value': 1.0,\n",
       " 'evap_1_rate_constant_1': 0.525,\n",
       " 'evap_1_rate_constant_2': 0.51,\n",
       " 'evap_2_arm_1_final_pow': 0.037,\n",
       " 'evap_2_arm_1_start_pow': 0.35,\n",
       " 'evap_2_arm_2_final_pow': 0.09,\n",
       " 'evap_2_arm_2_start_pow': 5,\n",
       " 'evap_2_ramp_duration': 1.0,\n",
       " 'evap_2_ramp_trunc_value': 1.0,\n",
       " 'evap_2_rate_constant_1': 0.37,\n",
       " 'evap_2_rate_constant_2': 0.71,\n",
       " 'evap_3_arm_1_final_pow': 0.1038,\n",
       " 'evap_3_arm_1_mod_depth_final': 0.43,\n",
       " 'evap_3_arm_1_mod_depth_initial': 0,\n",
       " 'evap_3_arm_1_start_pow': 0.037,\n",
       " 'evap_3_ramp_duration': 0.1,\n",
       " 'evap_3_ramp_trunc_value': 1.0,\n",
       " 'evap_3_rate_constant_1': -0.879,\n",
       " 'evap_3_rate_constant_2': -0.297,\n",
       " 'final_amp': 0.00012,\n",
       " 'final_freq': 104.0,\n",
       " 'final_pow_1': 0.1038,\n",
       " 'final_pow_2': 0.09,\n",
       " 'gradCoil_current': 0.18,\n",
       " 'gradCoil_current_sg': 0,\n",
       " 'imaging_method': 'in_situ_absorption',\n",
       " 'imaging_pulse_duration': 2.5e-05,\n",
       " 'imaging_wavelength': 4.21291e-07,\n",
       " 'initial_amp': 0.62,\n",
       " 'initial_freq': 102.13,\n",
       " 'mod_depth_fin': 0.43,\n",
       " 'mod_depth_ini': 0,\n",
       " 'mod_depth_initial': 1.0,\n",
       " 'mot_3d_amp': 0.62,\n",
       " 'mot_3d_camera_trigger_duration': 0.00025,\n",
       " 'mot_3d_freq': 102.13,\n",
       " 'mot_load_duration': 2,\n",
       " 'odt_axis_camera_trigger_duration': 0.002,\n",
       " 'odt_hold_time_1': 0.01,\n",
       " 'odt_hold_time_2': 0.1,\n",
       " 'odt_hold_time_3': 0.1,\n",
       " 'odt_hold_time_4': 1.0,\n",
       " 'odt_hold_time_5': 0.01,\n",
       " 'operation_mode': 'SWEEP',\n",
       " 'pow_arm_1': 7,\n",
       " 'pow_arm_2': 0,\n",
       " 'pulse_delay': 8e-05,\n",
       " 'pulse_width': 0.01,\n",
       " 'push_amp': 0.16,\n",
       " 'push_freq': 102.66,\n",
       " 'ramp_duration': 1,\n",
       " 'recomp_ramp_duration': 0.5,\n",
       " 'recomp_ramp_pow_fin_arm_1': 0.1038,\n",
       " 'recomp_ramp_pow_fin_arm_2': 0.09,\n",
       " 'recomp_ramp_pow_ini_arm_1': 0.1038,\n",
       " 'recomp_ramp_pow_ini_arm_2': 0.09,\n",
       " 'save_results': False,\n",
       " 'sin_mod_amplitude': 0.00519,\n",
       " 'sin_mod_dc_offset': 0.1038,\n",
       " 'sin_mod_duration': nan,\n",
       " 'sin_mod_freq': nan,\n",
       " 'sin_mod_phase': 0.0,\n",
       " 'start_pow_1': 0.037,\n",
       " 'start_pow_2': 0.09,\n",
       " 'stern_gerlach_duration': 0.001,\n",
       " 'sweep_duration': 0.4,\n",
       " 'sweep_start_freq': 0.7695,\n",
       " 'sweep_stop_freq': 0.9305,\n",
       " 'tf_meas_ramp_duration': 0.1,\n",
       " 'wait_after_2dmot_off': 0,\n",
       " 'wait_time_between_images': 0.22,\n",
       " 'wavetype': 'SINE',\n",
       " 'x_offset': 0.0,\n",
       " 'x_offset_img': 0,\n",
       " 'y_offset': 0.0,\n",
       " 'y_offset_img': 0,\n",
       " 'z_offset': 0.189,\n",
       " 'z_offset_img': 0.189,\n",
       " 'compX_final_current': array([0.   , 0.002, 0.004, 0.006, 0.008, 0.01 , 0.012, 0.014, 0.016,\n",
       "        0.018, 0.02 , 0.   , 0.002, 0.004, 0.006, 0.008, 0.01 , 0.012,\n",
       "        0.014, 0.016, 0.018, 0.02 , 0.   , 0.002, 0.004, 0.006, 0.008,\n",
       "        0.01 , 0.012, 0.014, 0.016, 0.018, 0.02 ]),\n",
       " 'runs': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1.,\n",
       "        1., 1., 1., 1., 1., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.]),\n",
       " 'scanAxis': ['compX_final_current', 'runs'],\n",
       " 'scanAxisLength': array([33., 33.])}"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DB.read_global_all('0069')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "DB.load_data_single(shotNum='0069', runNum=0).keys()"
   ]
  },
  {
   "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": null,
   "metadata": {},
   "outputs": [],
   "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": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "params.compute().item()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "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": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fitModel2 = Polylog22dModel(prefix='thermal_')\n",
    "fitAnalyser2 = FitAnalyser(fitModel2, fitDim=2)\n",
    "fitCurve2 = fitAnalyser2.eval(fitResult, x=np.arange(300), y=np.arange(300), dask=\"parallelized\").load()\n",
    "\n",
    "fitModel3 = ThomasFermi2dModel(prefix='BEC_')\n",
    "fitAnalyser3 = FitAnalyser(fitModel3, fitDim=2)\n",
    "fitCurve3 = fitAnalyser3.eval(fitResult, x=np.arange(300), y=np.arange(300), dask=\"parallelized\").load()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "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": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "value = fitAnalyser.get_fit_value(fitResult)\n",
    "std = fitAnalyser.get_fit_std(fitResult)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fitResult.item()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "value"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# upload data to MongoDB"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "xdb = xarray_mongodb.XarrayMongoDB(mongoDB)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "value = fitAnalyser.get_fit_value(fitResult)\n",
    "value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataSet_cropOD"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataSet_cropOD.attrs['name'] = 'name'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataSet_cropOD.attrs['IMAGE_WHITE_IS_ZERO']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataSet_cropOD"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "type(dataSet_cropOD.attrs['absorption_imaging_flag'].item())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "del dataSet_cropOD.attrs['IMAGE_WHITE_IS_ZERO']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import builtins\n",
    "npTypeDict = {v: getattr(builtins, k) for k, v in np.typeDict.items() if k in vars(builtins)}\n",
    "\n",
    "for key in dataSet_cropOD.attrs:\n",
    "    typeKey = type(dataSet_cropOD.attrs[key])\n",
    "    if typeKey in npTypeDict:\n",
    "        dataSet_cropOD.attrs[key] = dataSet_cropOD.attrs[key].item()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import builtins\n",
    "a = {v: getattr(builtins, k) for k, v in np.typeDict.items() if k in vars(builtins)}\n",
    "a\n",
    "a[type(dataSet_cropOD.attrs['absorption_imaging_flag'])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "_id, _ = xdb.put(dataSet_cropOD)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "_id"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# _id = '646e3cbbdb91e17db4b4cbd2'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "xdb.get(_id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "c = bson.objectid.ObjectId('646e4919802812f029b385d7')\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "xdb.get(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "post = {\"author\": \"Mike\",\n",
    "        \"data_id\": _id,\n",
    "        \"tags\": [\"mongodb\", \"python\", \"pymongo\"],\n",
    "        \"date\": datetime.datetime.utcnow(),\n",
    "        }\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "posts = mongoCollection\n",
    "post_id = posts.insert_one(post).inserted_id\n",
    "post_id"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "posts.find_one({'_id': bson.objectid.ObjectId('648318ae129ec5a1a24a7353')})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in posts.find_one({'_id': bson.objectid.ObjectId('648318ae129ec5a1a24a7353')}):\n",
    "    bb = i\n",
    "    \n",
    "bb['test']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import gridfs\n",
    "\n",
    "fs = gridfs.GridFS(mongoDB, 'xarray')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "f = dataSet_cropOD.to_dict()\n",
    "f"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(ff)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "ff = json.dumps(f) \n",
    "fs.put(ff, encoding='utf-8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fs.put(b\"hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "c = bson.objectid.ObjectId('6482f4a3129ec5a1a24a7342')\n",
    "\n",
    "fs.get(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(fs.get(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.sqrt(np.sum([0.061**2, 0.334**2, 0.447**2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py39",
   "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
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
