analyseScript/backupScript/20230530_Data_Analysis.ipynb

1583 lines
187 KiB
Plaintext
Raw Normal View History

2023-06-02 18:42:18 +02:00
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Import supporting package"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"import numpy as np\n",
"import copy\n",
"\n",
"from uncertainties import ufloat\n",
"from uncertainties import unumpy as unp\n",
"from uncertainties import umath\n",
"import random\n",
"import matplotlib.pyplot as plt\n",
"plt.rcParams['font.size'] = 12\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 NewFitModel, DensityProfileBEC2dModel\n",
"from ToolFunction.ToolFunction import *\n",
"\n",
"from scipy.optimize import curve_fit\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()\n",
"\n",
"# %matplotlib notebook"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Start a client for parallel computing"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
" <div style=\"width: 24px; height: 24px; background-color: #e1e1e1; border: 3px solid #9D9D9D; border-radius: 5px; position: absolute;\"> </div>\n",
" <div style=\"margin-left: 48px;\">\n",
" <h3 style=\"margin-bottom: 0px;\">Client</h3>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Client-23571205-fef2-11ed-8994-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;\">3caf8456</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> 8\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads:</strong> 128\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total memory:</strong> 149.01 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-7358e8cb-f1c0-435a-b9a6-1ae89646703d</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:52558\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Workers:</strong> 8\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> 128\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> 149.01 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:52603\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52607/status\" target=\"_blank\">http://127.0.0.1:52607/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 18.63 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:52561\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-_emdmb6_\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:52604\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52606/status\" target=\"_blank\">http://127.0.0.1:52606/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 18.63 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:52562\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-ztl68fct\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:52590\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52595/status\" target=\"_blank\">http://127.0.0.1:52595/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 18.63 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:52563\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-55i03qxs\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:52597\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52599/status\" target=\"_blank\">http://127.0.0.1:52599/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 18.63 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:52564\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-a9s2v84x\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:52605\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52610/status\" target=\"_blank\">http://127.0.0.1:52610/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 18.63 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:52565\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-jb353de7\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:52617\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52618/status\" target=\"_blank\">http://127.0.0.1:52618/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 18.63 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:52566\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-g3juqn2t\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: 6</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:52612\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52613/status\" target=\"_blank\">http://127.0.0.1:52613/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 18.63 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:52567\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-xu67jkqc\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: 7</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:52598\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:52601/status\" target=\"_blank\">http://127.0.0.1:52601/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 18.63 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:52568\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-kdvp5zu9\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:52558' processes=8 threads=128, memory=149.01 GiB>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from dask.distributed import Client\n",
"client = Client(n_workers=8, threads_per_worker=16, processes=True, memory_limit='20GB')\n",
"client"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set global path for experiment"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"groupList = [\n",
" \"images/MOT_3D_Camera/in_situ_absorption\",\n",
" \"images/ODT_1_Axis_Camera/in_situ_absorption\",\n",
" \"images/ODT_2_Axis_Camera/in_situ_absorption\",\n",
"]\n",
"\n",
"dskey = {\n",
" \"images/MOT_3D_Camera/in_situ_absorption\": \"camera_0\",\n",
" \"images/ODT_1_Axis_Camera/in_situ_absorption\": \"camera_1\",\n",
" \"images/ODT_2_Axis_Camera/in_situ_absorption\": \"camera_2\",\n",
"}\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"img_dir = '//DyLabNAS/Data/'\n",
"SequenceName = \"Repetition_scan\" + \"/\"\n",
"folderPath = img_dir + SequenceName + get_date()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Repetition Scans"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## scan MOT freq - Z Comp 0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"shotNum = \"0000\"\n",
"filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
"\n",
"dataSetDict = {\n",
" dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i])\n",
" for i in range(len(groupList))\n",
"}\n",
"\n",
"dataSet = dataSetDict[\"camera_1\"]\n",
"\n",
"print_scanAxis(dataSet)\n",
"\n",
"scanAxis = get_scanAxis(dataSet)\n",
"\n",
"dataSet = auto_rechunk(dataSet)\n",
"\n",
"dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
"\n",
"imageAnalyser.center = (310, 825)\n",
"imageAnalyser.span = (550, 1200)\n",
"imageAnalyser.fraction = (0.1, 0.1)\n",
"\n",
"dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
"dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
"\n",
"Ncount = imageAnalyser.get_Ncount(dataSet_cropOD)\n",
"Ncount_mean = Ncount.mean(dim='runs')\n",
"Ncount_std = Ncount.std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"Ncount_mean.plot.errorbar(ax=ax, yerr = Ncount_std, fmt='ob')\n",
"plt.xlabel('MOT AOM Freq (MHz)')\n",
"plt.ylabel('NCount')\n",
"plt.tight_layout()\n",
"plt.grid(visible=1)\n",
"plt.show()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## scan Push freq"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"shotNum = \"0001\"\n",
"filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
"\n",
"dataSetDict = {\n",
" dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i])\n",
" for i in range(len(groupList))\n",
"}\n",
"\n",
"dataSet = dataSetDict[\"camera_1\"]\n",
"\n",
"print_scanAxis(dataSet)\n",
"\n",
"scanAxis = get_scanAxis(dataSet)\n",
"\n",
"dataSet = auto_rechunk(dataSet)\n",
"\n",
"dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
"\n",
"imageAnalyser.center = (310, 825)\n",
"imageAnalyser.span = (550, 1200)\n",
"imageAnalyser.fraction = (0.1, 0.1)\n",
"\n",
"dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
"dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
"\n",
"Ncount = imageAnalyser.get_Ncount(dataSet_cropOD)\n",
"Ncount_mean = Ncount.mean(dim='runs')\n",
"Ncount_std = Ncount.std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"Ncount_mean.plot.errorbar(ax=ax, yerr = Ncount_std, fmt='ob')\n",
"plt.xlabel('Push AOM Freq (MHz)')\n",
"plt.ylabel('NCount')\n",
"plt.tight_layout()\n",
"plt.grid(visible=1)\n",
"plt.show()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## scan cMOT final Amp"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"shotNum = \"0003\"\n",
"filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
"\n",
"dataSetDict = {\n",
" dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i])\n",
" for i in range(len(groupList))\n",
"}\n",
"\n",
"dataSet = dataSetDict[\"camera_1\"]\n",
"\n",
"print_scanAxis(dataSet)\n",
"\n",
"scanAxis = get_scanAxis(dataSet)\n",
"\n",
"dataSet = auto_rechunk(dataSet)\n",
"\n",
"dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
"\n",
"imageAnalyser.center = (306, 874)\n",
"imageAnalyser.span = (550, 500)\n",
"imageAnalyser.fraction = (0.1, 0.1)\n",
"\n",
"dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
"dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
"\n",
"Ncount = imageAnalyser.get_Ncount(dataSet_cropOD)\n",
"Ncount_mean = Ncount.mean(dim='runs')\n",
"Ncount_std = Ncount.std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"Ncount_mean.plot.errorbar(ax=ax, yerr = Ncount_std, fmt='ob')\n",
"plt.xlabel('cMOT final Amp (%)')\n",
"plt.ylabel('NCount')\n",
"#plt.ylim([0, 25000])\n",
"plt.tight_layout()\n",
"plt.grid(visible=1)\n",
"plt.show()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## scan Z comp current"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"shotNum = \"0004\"\n",
"filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
"\n",
"dataSetDict = {\n",
" dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i])\n",
" for i in range(len(groupList))\n",
"}\n",
"\n",
"dataSet = dataSetDict[\"camera_1\"]\n",
"\n",
"print_scanAxis(dataSet)\n",
"\n",
"scanAxis = get_scanAxis(dataSet)\n",
"\n",
"dataSet = auto_rechunk(dataSet)\n",
"\n",
"dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
"\n",
"imageAnalyser.center = (310, 825)\n",
"imageAnalyser.span = (550, 1200)\n",
"imageAnalyser.fraction = (0.1, 0.1)\n",
"\n",
"dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
"dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
"\n",
"Ncount = imageAnalyser.get_Ncount(dataSet_cropOD)\n",
"Ncount_mean = Ncount.mean(dim='runs')\n",
"Ncount_std = Ncount.std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"Ncount_mean.plot.errorbar(ax=ax, yerr = Ncount_std, fmt='ob')\n",
"plt.xlabel('comp Z current (A)')\n",
"plt.ylabel('NCount')\n",
"plt.tight_layout()\n",
"plt.grid(visible=1)\n",
"plt.show()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Evaporative Cooling"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"img_dir = '//DyLabNAS/Data/'\n",
"SequenceName = \"Evaporative_Cooling\" + \"/\"\n",
"folderPath = img_dir + SequenceName + get_date()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Check our BEC"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"shotNum = \"0001\"\n",
"filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
"\n",
"# datesetOfGlobal = xr.Dataset(\n",
"# data_vars={}\n",
"# )\n",
"\n",
"# datesetOfGlobal.attrs['scanAxis'] = ['sin_mod_freq']\n",
"# datesetOfGlobal.attrs['sin_mod_freq'] = [40.0, 40.5, 41.0, 41.5, 42.0, 42.5, 43.0, 43.5, 44.0, 44.5, 45.0, 45.5, 46.0, 46.5, 47.0, 47.5, 48.0, 48.5, 49.0, 49.5, 50.0, 50.5, 51.0, 51.5, 52.0, 52.5, 53.0, 53.5, 54.0, 54.5, 55.0, 55.5, 56.0, 56.5, 57.0, 57.5, 58.0, 58.5, 59.0, 59.5, 60.0]\n",
"dataSetDict = {\n",
" dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i], excludeAxis = ['sweep_start_freq', 'sweep_stop_freq'])\n",
" for i in [0]\n",
"}\n",
"\n",
"dataSet = dataSetDict[\"camera_0\"]\n",
"\n",
"print_scanAxis(dataSet)\n",
"\n",
"scanAxis = get_scanAxis(dataSet)\n",
"\n",
"dataSet = auto_rechunk(dataSet)\n",
"\n",
"dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
"\n",
"imageAnalyser.center = (884, 953)\n",
"imageAnalyser.span = (100, 100)\n",
"imageAnalyser.fraction = (0.1, 0.1)\n",
"\n",
"dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
"dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
"\n",
"Ncount = imageAnalyser.get_Ncount(dataSet_cropOD)\n",
"Ncount_mean = Ncount# .mean(dim='runs')\n",
"Ncount_std = Ncount# .std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"Ncount_mean.plot.errorbar(ax=ax, yerr = None, fmt='ob')\n",
"\n",
"plt.ylabel('NCount')\n",
"plt.tight_layout()\n",
"#plt.ylim([0, 500])\n",
"plt.grid(visible=1)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataSet_cropOD.plot.pcolormesh(cmap='jet', vmin=0, col=scanAxis[0], row=scanAxis[1])\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"fitModel = DensityProfileBEC2dModel()\n",
"fitAnalyser = FitAnalyser(fitModel, fitDim=2)\n",
"params = fitAnalyser.guess(dataSet_cropOD, guess_kwargs=dict(pureBECThreshold=0.3), dask=\"parallelized\")\n",
"# params = fitAnalyser_1.fitModel.make_params()\n",
"# params.add(name=\"amplitude\", value= -4000, max=np.inf, min=-np.inf, vary=True)\n",
"# params.add(name=\"center\", value= 0.435, max=np.inf, min=-np.inf, vary=True)\n",
"# params.add(name=\"sigma\", value= 0.01, max=np.inf, min= 0, vary=True)\n",
"# params.add(name=\"offset\", value= 1000, max=np.inf, min=-np.inf, vary=True)\n",
"\n",
"fitResult = fitAnalyser.fit(dataSet_cropOD, params).load()\n",
"\n",
"val = fitAnalyser.get_fit_value(fitResult)\n",
"std = fitAnalyser.get_fit_std(fitResult)\n",
"\n",
"fitCurve = fitAnalyser.eval(fitResult, x=np.arange(100), y=np.arange(100), 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": [
"val"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Measure trap frequency at the end of evap. 3, blink off time = 275 µs"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The detected scaning axes and values are: \n",
"\n",
"{'blink_on_time': array([0.005 , 0.0057, 0.0064, 0.0071, 0.0078, 0.0085, 0.0092, 0.0099,\n",
" 0.0106, 0.0113, 0.012 , 0.0127, 0.0134, 0.0141, 0.0148, 0.0155,\n",
" 0.0162, 0.0169, 0.0176, 0.0183, 0.019 , 0.0197, 0.0204, 0.0211,\n",
" 0.0218, 0.0225, 0.0232, 0.0239, 0.0246, 0.0253, 0.026 , 0.0267,\n",
" 0.0274, 0.0281, 0.0288, 0.0295, 0.0302, 0.0309, 0.0316, 0.0323,\n",
" 0.033 , 0.0337, 0.0344, 0.0351, 0.0358, 0.0365, 0.0372, 0.0379,\n",
" 0.0386, 0.0393, 0.04 ]), 'runs': array([0., 1., 2.])}\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAm4AAAHPCAYAAADqAFbFAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAABUCElEQVR4nO3deXxU1f3/8feQhAlblCQoIQkGUaEIYkUjsVqCyiJLAxFboSjGQmqFArWoLKEkFVAULRSRigs7iNhIXQO0BIsLLT/71UK/tvVbQTGANGGJAglJuL8/xhkY5mZllntnXs/Hg8eQM2fuPfPJTfKZc8/iMAzDEAAAACyvWagbAAAAgIYhcQMAALAJEjcAAACbIHEDAACwCRI3AAAAmyBxAwAAsAkSNwAAAJuIDnUDrOz06dPav3+/2rRpI4fDEermAACAMGUYhr7++mt16NBBzZrV3q9G4laH/fv3KzU1NdTNAAAAEWLfvn1KSUmp9XkStzq0adNGkiuIcXFxATlHVVWVNm/erP79+ysmJiYg57Aj4mKOuJgjLrUjNuaIizniYi4YcSkvL1dqaqon96gNiVsd3LdH4+LiApq4tWzZUnFxcfyQnIW4mCMu5ohL7YiNOeJijriYC2Zc6huaxeQEAAAAmyBxAwAAsAkSNwAAAJsgcQMAALAJEjcAAACbIHEDAACwCRI3AAAAmyBxAwAAsAkSNwAAAJsgcQMAALAJtrwCAABho6ZG2r5dOnBASkqSbrpJiooKdav8h8QNAACEhcJCadIk6csvz5SlpEgLF0rZ2aFrlz9xqxQAANheYaE0YoR30iZJJSWu8sLC0LTL30jcAACArdXUuHraDMP3OXfZ5MmuenZH4gYAAGxt+3bfnrazGYa0b5+rnt2RuA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iJSd7l6ekuMpZxw1NUVMjbdsmrVvnegy3Qfp86AFgNSRuESQ7W9q7VyoultaudT3u2UPShqaJlLXN+NADwErYOSHCREVJmZmhbgXszr222bnLZLjXNgu3hCY7W8rKYucEAKFH4gagUepb28zhcK1tlpUVXokNH3oAWAG3SgE0CmubAUDokLgBaBTWNgOA0CFxA9AorG0GAKFD4gagUVjbDABCh8QNQKOwthkAhA6JG4BGY20zAAgNlgMB0CSsbQYAwUfiBqDJGrK2WU0NyR0A+AuJG4CAKSx0LdZ79rpvKSmuMXLcTgWAxmOMG4CAcG+Lde5ive5tscJtT1MACAYSNwB+V9+2WJJrW6yamqA2CwBsj8QNYaumRtq2TVq3zvVIkhA8bIsFAIHBGDeEJcZWhRbbYgFAYNDjhrDD2KrQY1ssAAgMEjeEFcZWWQPbYgFAYJC4Iawwtsoa2BYLAAKDxA1hhbFV1sG2WADgf0xOQFhhbJW1sC0WAPgXiRvCintsVUmJ+Tg3h8P1PGOrgqch22IBABqGW6UIK4ytAgCEMxI3hB3GVgEAwhW3ShGWGFsFAAhHJG4IW4ytAgCEG26VAgAA2ASJGwAAgE2EPHH76KOPNHjwYHXs2FEtWrRQfHy8MjIytHr1ap+6VVVVeuqpp9SjRw+1aNFCF154oW644Qa9//77PnUXLVqkrl27yul0qlOnTiooKFBVVVUw3hIAAEBAhHyM29GjR5WamqqRI0cqOTlZx48f15o1a3TXXXdp7969ysvLkyTV1NRo+PDhevfdd/XQQw/phhtu0PHjx/Xhhx/q+PHjXsecM2eOZs6cqalTp6p///7auXOn8vLyVFJSoqVLl4bibQIAAJy3kCdumZmZyjxnBPmQIUO0Z88eLV261JO4LVq0SG+//bbee+899e7d21N38ODBXq8tKyvT7NmzNW7cOM2
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"shotNum = \"0015\"\n",
"filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
"\n",
"dataSetDict = {\n",
" dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i], maxFileNum=153, excludeAxis = ['sweep_start_freq', 'sweep_stop_freq'])\n",
" for i in [0]\n",
"}\n",
"\n",
"dataSet = dataSetDict[\"camera_0\"]\n",
"\n",
"print_scanAxis(dataSet)\n",
"\n",
"scanAxis = get_scanAxis(dataSet)\n",
"\n",
"dataSet = auto_rechunk(dataSet)\n",
"\n",
"dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
"\n",
"imageAnalyser.center = (180, 958)\n",
"imageAnalyser.span = (100, 100)\n",
"imageAnalyser.fraction = (0.1, 0.1)\n",
"\n",
"dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
"dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
"\n",
"Ncount = imageAnalyser.get_Ncount(dataSet_cropOD)\n",
"Ncount_mean = Ncount.mean(dim='runs')\n",
"Ncount_std = Ncount.std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"Ncount_mean.plot.errorbar(ax=ax, yerr = None, fmt='ob')\n",
"\n",
"plt.ylabel('NCount')\n",
"plt.tight_layout()\n",
"#plt.ylim([0, 500])\n",
"plt.grid(visible=1)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"dataSet_cropOD.plot.pcolormesh(cmap='jet', vmin=0, col=scanAxis[0], row=scanAxis[1])\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"fitAnalyser = FitAnalyser(\"Gaussian-2D\", fitDim=2)\n",
"params = fitAnalyser.guess(dataSet_cropOD, dask=\"parallelized\")\n",
"# params = fitAnalyser_1.fitModel.make_params()\n",
"# params.add(name=\"amplitude\", value= -4000, max=np.inf, min=-np.inf, vary=True)\n",
"# params.add(name=\"center\", value= 0.435, max=np.inf, min=-np.inf, vary=True)\n",
"# params.add(name=\"sigma\", value= 0.01, max=np.inf, min= 0, vary=True)\n",
"# params.add(name=\"offset\", value= 1000, max=np.inf, min=-np.inf, vary=True)\n",
"\n",
"fitResult = fitAnalyser.fit(dataSet_cropOD, params).load()\n",
"\n",
"val = fitAnalyser.get_fit_value(fitResult)\n",
"std = fitAnalyser.get_fit_std(fitResult)\n",
"\n",
"fitCurve = fitAnalyser.eval(fitResult, x=np.arange(100), y=np.arange(100), dask=\"parallelized\").load()\n",
"\n",
"# fitCurve.plot.pcolormesh(cmap='jet', vmin=0, col=scanAxis[0], row=scanAxis[1])"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAj4AAAG0CAYAAAAy8S2PAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAACIAElEQVR4nO2dd3gUVdvG78km2RAgQBJ6Il2QDtKi9G4EgQiIyIsI2EVA/cQONgQUBV8FRBFQqmKwEaUjHQu+CkjvhB5KICRhs5nvj+PJlmyZ3Z1ydvf5XVeuzc7OnDlnZnbnnuc8RZJlWQZBEARBEEQYEGF0BwiCIAiCIPSChA9BEARBEGEDCR+CIAiCIMIGEj4EQRAEQYQNJHwIgiAIgggbSPgQBEEQBBE2kPAhCIIgCCJsIOFDEARBEETYEGl0B0ShsLAQp0+fRunSpSFJktHdIQiCIAhCAbIs49q1a6hSpQoiIrzbc0j4/Mvp06eRnJxsdDcIgiAIgvCDkydPIikpyet6JHz+pXTp0gDYgYuLi1OtXYvFglWrVqF79+6IiopSrd1gItyPQbiPH6BjQOMP7/EDdAy0HH92djaSk5OL7uPeIOHzL3x6Ky4uTnXhExsbi7i4uLC82AE6BuE+foCOAY0/vMcP0DHQY/xK3VTIuZkgCIIgiLCBhA9BEARBEGEDCR+CIAiCIMIGEj4EQR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XXpS1aWTYDal6uoVIm9nj/PipcSYjNwIPDAA0D58kb3JLywWoHRo12XduHLxoyhaLtQhoQPoRgufKpVY6/lyrHXK1c
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"dataKey = 'sigmax'\n",
"# dataKey = 'centerx'\n",
"# dataKey = 'sigmay'\n",
"# dataKey = 'centery'\n",
"\n",
"val_mean = val[dataKey].mean(dim='runs')\n",
"std_mean = val[dataKey].std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"val_mean.plot.errorbar(ax=ax, yerr=std_mean, fmt='--ob')\n",
"\n",
"plt.grid()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
"def dampingOscillation(x, center=0, amplitude=1.0, frequency=1.0, decay=1.0, slope=1.0, intercept=0.0):\n",
" return amplitude * np.exp(-decay*x)*np.sin(2*np.pi*frequency*(x-center)) + (slope * x + intercept)\n",
"\n",
"fitModel = NewFitModel(dampingOscillation)\n",
"\n",
"fitAnalyser = FitAnalyser(fitModel, fitDim=1)\n",
"\n",
"params = fitAnalyser.fitModel.make_params()\n",
"params.add(name=\"center\", value= 0, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"amplitude\", value= 1, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"frequency\", value= 260, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"decay\", value= 0.1, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"slope\", value= 30, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"intercept\", value= 5.5, max=np.inf, min=-np.inf, vary=True)\n",
"\n",
"fitResult = fitAnalyser.fit(val_mean, params, x=scanAxis[0]).load()\n",
"\n",
"x = np.linspace(val_mean[scanAxis[0]][0], val_mean[scanAxis[0]][-1], 500)\n",
"fitCurve = fitAnalyser.eval(fitResult, x=x, dask=\"parallelized\").load()"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAj4AAAGyCAYAAADkqM6SAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAACpp0lEQVR4nOydd3xT5f7H32ma7r2hLS0bGWXvLRtBpaJy1etVcS/Q697j/twDrntdcS8EFQWZgoAs2Xu2Bdoyunebpvn9cXJCW9I245yclD5vX75oT57z5HvSjE++U2c2m80IBAKBQCAQtAC8tDZAIBAIBAKBwF0I4SMQCAQCgaDFIISPQCAQCASCFoMQPgKBQCAQCFoMQvgIBAKBQCBoMQjhIxAIBAKBoMUghI9AIBAIBIIWg7fWBngKNTU1ZGVlERwcjE6n09ocgUAgEAgEdmA2mykuLqZ169Z4eTXtzxHCx0JWVhaJiYlamyEQCAQCgcAJTpw4QUJCQpPrhPCxEBwcDEgPXEhIiGL7Go1Gli1bxvjx4zEYDIrt25xo6Y9BS79+EI+BuP6Wff0gHgM1r7+oqIjExETr53hTCOFjQQ5vhYSEKC58AgICCAkJaZFPdhCPQUu/fhCPgbj+ln39IB4Dd1y/vWkqIrlZIBAIBAJBi0EIH4FAIBAIBC0GIXwEAoFAIBC0GITwEQgEAoFA0GIQwkcgEAgEAkGLQQgfgUAgEAgELQYhfAQCgUAgELQYhPARCAQCgUDQYhDCRyAQCAQCQYtBCB+BQCAQCAQtBiF8BAKBQCAQtBiE8BEIBAKBQNBiEMJHIBAIBAJBi0EIH4FAIBAIBC0GIXwEAoFAKUpLQaeT/i8t1doagUBgAyF8BILmjviwFQgEArsRwkcgEAgEAkGLQQgfgUAgEAgELQYhfAQCgUAgELQYhPARCAQCgUDQYhDCR+A4IplWIBAIBM0UIXwEAoFAIBC0GITwEQgEAoFA0GIQwkcgEAgEAkGLQQgfgUAgc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z2ZKx4X4uaARwkcgEAgELQeTCWbNkr4o1Ec+Nnu2CHtdwAjhI3Ac4WEQCATNlbVr4eTJhm83m+HECWmd4IJECB+BQCAQtByys5VdJ2h2COEjEAgEgpZDq1bKrhM0O4TwEQgEAkHLYfhwSEgAnc727TodJCZK6wQXJEL4CAQCgaDloNfD3LnSz/XFj/z7nDnSOsEFiRA+AoFAIGhZpKbC/PlQf6xRQoJ0PDVVG7vsYN/ZfdSYa7Q2o1kjhI9AIBAIWh6pqbBv37nfFy+GtDSPFj2r0lbR78N+bDq5qfGFpaWS90qnk34W1EEIH4FAIBC0TGqHs0aM8OjwVk5ZDlfPv5ry6nJWXjcEdDryc09yw083sCVzi9bmNSuE8BEIBAJB4wgPguY8vvJxcspy6B7VlQfXS8eeWPccn+38jNt+va3OHEtP5OGVD/NH3h+UVmn//BHCRyAQCAQCDyarOItPd3wKwLtj38TX0lT6mSGPEWgIZPup7Sw+vFhDCxun3FjOztM7ef/k+1SZqrQ2RwgfgUAgEAg8mXc2v4OxxsiwNsMYnjDUejw6IJo7+98JwGsbXtPKvCbxN/jz+zW/82X3Lwn3D9faHCF8BAKBQNBCaQbjd2rMNXy+63MAZg2cdd7t9wy4Bx06Vqev5mjeUXeb5xAGL4PWJgBC+AgEAoHgAqfKVMWC/Qv4ZNsn5JXnaW2OQ/x14i9OFp0kzC+MqZ2m1h2e+uefJAa1Znz78QDWcJgnYTabyS3L1dqMOgjhI6iLSGIUCAQXEHn+MPLbiVzx/RXcvOhmOr3Vib+z/tbaLLsZmjiUv2/5mw+mfIDvL79B167nbpw8GZKT+VfVRQD8sO8Hj0tyPph7kKhXoxj86WCPsU0IH4FAIBBcsNx
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"f_y = 126.5119 ± 0.7136 kHz\n"
]
}
],
"source": [
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"val_mean.plot.errorbar(ax=ax, yerr=std_mean, fmt='or')\n",
"fitCurve.plot.errorbar(ax=ax, yerr=None, fmt='--g')\n",
"\n",
"plt.grid()\n",
"\n",
"plt.xlabel('hold time after switch on the trap (s)')\n",
"plt.ylabel('y center (pixels)')\n",
"\n",
"plt.show()\n",
"\n",
"val = fitAnalyser.get_fit_full_result(fitResult)\n",
"f = val.frequency.item() / 2\n",
"\n",
"print('f_y = %.4f \\u00B1 %.4f kHz'% tuple([f.n,f.s]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from lmfit.models import LinearModel\n",
"from Analyser.FitAnalyser import DampingOscillationModel\n",
"\n",
"fitModel = LinearModel() * DampingOscillationModel()\n",
"\n",
"fitAnalyser = FitAnalyser(fitModel, fitDim=1)\n",
"\n",
"params = fitAnalyser.fitModel.make_params()\n",
"params.add(name=\"slope\", value= 30, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"intercept\", value= 5.5, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"center\", value= 0, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"amplitude\", value= 1, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"frequency\", value= 260, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"decay\", value= 0.1, max=np.inf, min=-np.inf, vary=True)\n",
"params.add(name=\"offset\", value= 0, max=np.inf, min=-np.inf, vary=False)\n",
"\n",
"fitResult = fitAnalyser.fit(val_mean, params, x=scanAxis[0]).load()\n",
"\n",
"fitCurve = fitAnalyser.eval(fitResult, x=np.arange(100), y=np.arange(100), 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": [
"val_mean = val[dataKey].mean(dim='runs')\n",
"std_mean = val[dataKey].std(dim='runs')\n",
"val"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"def damp_osci(t, t0, A, B, nu, gamma):\n",
" return A * np.exp(-gamma*t)*np.sin(2*np.pi*nu*(t-t0)) + B\n",
"\n",
"fitted_qtys_1 = val_mean.to_numpy()\n",
"fitted_qtys_err_1 = std_mean.to_numpy()\n",
"scan_para = dataSet_cropOD[scanAxis[0]].to_numpy()\n",
"\n",
"# fitted_qtys_1 = np.delete(fitted_qtys_1, 27)\n",
"# fitted_qtys_err_1 = np.delete(fitted_qtys_err_1, 27)\n",
"# scan_para = np.delete(scan_para, 27)\n",
"\n",
"plt.figure()\n",
"popt_x, pcov_x = curve_fit(damp_osci, scan_para, fitted_qtys_1, np.array([0, 7.5, 42.5, 1.3e2, 0.1]))\n",
"freqdata = np.linspace(0.005, 40e-3, 500)\n",
"plt.plot(freqdata, damp_osci(freqdata, *popt_x), 'g--',label='fit: t0=%5.3f, A=%5.3f, B=%5.3f, nu=%5.3f, Gamma=%5.3f' % tuple(popt_x))\n",
"plt.errorbar(scan_para, fitted_qtys_1, yerr=fitted_qtys_err_1, fmt='or')\n",
"plt.xlabel('hold time after switch on the trap (s)')\n",
"plt.ylabel('y center (pixels)')\n",
"plt.tight_layout()\n",
"plt.grid(visible=1)\n",
"#plt.ylim([0,750])\n",
"#plt.xlim([90, 121])\n",
"#plt.legend(prop={'size': 14})\n",
"plt.show()\n",
"\n",
"f_x = popt_x[3] / 1000\n",
"df_x = pcov_x[3][3]**0.5 / 1000\n",
"\n",
"print('f_y = %.4f \\u00B1 %.4f kHz'% tuple([np.abs(f_x),df_x]))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Measure trap frequency at the end of evap. 3, blink off time = 250 µs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"%matplotlib notebook\n",
"shotNum = \"0015\"\n",
"filePath = folderPath + \"/\" + shotNum + \"/*.h5\"\n",
"\n",
"dataSetDict = {\n",
" dskey[groupList[i]]: read_hdf5_file(filePath, groupList[i], maxFileNum=102, excludeAxis = ['sweep_start_freq', 'sweep_stop_freq'])\n",
" for i in [0]\n",
"}\n",
"\n",
"dataSet = dataSetDict[\"camera_0\"]\n",
"\n",
"print_scanAxis(dataSet)\n",
"\n",
"scanAxis = get_scanAxis(dataSet)\n",
"\n",
"dataSet = auto_rechunk(dataSet)\n",
"\n",
"dataSet = imageAnalyser.get_absorption_images(dataSet)\n",
"\n",
"imageAnalyser.center = (180, 958)\n",
"imageAnalyser.span = (100, 100)\n",
"imageAnalyser.fraction = (0.1, 0.1)\n",
"\n",
"dataSet_cropOD = imageAnalyser.crop_image(dataSet.OD)\n",
"dataSet_cropOD = imageAnalyser.substract_offset(dataSet_cropOD).load()\n",
"\n",
"Ncount = imageAnalyser.get_Ncount(dataSet_cropOD)\n",
"Ncount_mean = Ncount.mean(dim='runs')\n",
"Ncount_std = Ncount.std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"Ncount_mean.plot.errorbar(ax=ax, yerr = None, fmt='ob')\n",
"\n",
"plt.ylabel('NCount')\n",
"plt.tight_layout()\n",
"#plt.ylim([0, 500])\n",
"plt.grid(visible=1)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"dataSet_cropOD.plot.pcolormesh(cmap='jet', vmin=0, col=scanAxis[0], row=scanAxis[1])\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"fitAnalyser = FitAnalyser(\"Gaussian-2D\", fitDim=2)\n",
"params = fitAnalyser.guess(dataSet_cropOD, dask=\"parallelized\")\n",
"# params = fitAnalyser_1.fitModel.make_params()\n",
"# params.add(name=\"amplitude\", value= -4000, max=np.inf, min=-np.inf, vary=True)\n",
"# params.add(name=\"center\", value= 0.435, max=np.inf, min=-np.inf, vary=True)\n",
"# params.add(name=\"sigma\", value= 0.01, max=np.inf, min= 0, vary=True)\n",
"# params.add(name=\"offset\", value= 1000, max=np.inf, min=-np.inf, vary=True)\n",
"\n",
"fitResult = fitAnalyser.fit(dataSet_cropOD, params).load()\n",
"\n",
"val = fitAnalyser.get_fit_value(fitResult)\n",
"std = fitAnalyser.get_fit_std(fitResult)\n",
"\n",
"fitCurve = fitAnalyser.eval(fitResult, x=np.arange(100), y=np.arange(100), 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": [
"# dataKey = 'sigmax'\n",
"dataKey = 'centerx'\n",
"# dataKey = 'sigmay'\n",
"# dataKey = 'centery'\n",
"\n",
"val_mean = val[dataKey].mean(dim='runs')\n",
"std_mean = val[dataKey].std(dim='runs')\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"val_mean.plot.errorbar(yerr=std_mean, fmt='--ob')\n",
"\n",
"plt.grid()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"def damp_osci(t, t0, A, B, nu, gamma):\n",
" return A * np.exp(-gamma*t)*np.sin(2*np.pi*nu*(t-t0)) + B\n",
"\n",
"fitted_qtys_1 = val_mean.to_numpy()\n",
"fitted_qtys_err_1 = std_mean.to_numpy()\n",
"scan_para = dataSet_cropOD[scanAxis[0]].to_numpy()\n",
"\n",
"# fitted_qtys_1 = np.delete(fitted_qtys_1, 27)\n",
"# fitted_qtys_err_1 = np.delete(fitted_qtys_err_1, 27)\n",
"# scan_para = np.delete(scan_para, 27)\n",
"\n",
"plt.figure()\n",
"popt_x, pcov_x = curve_fit(damp_osci, scan_para, fitted_qtys_1, np.array([0, 7.5, 42.5, 1.3e2, 0.1]))\n",
"freqdata = np.linspace(0.005, 40e-3, 500)\n",
"plt.plot(freqdata, damp_osci(freqdata, *popt_x), 'g--',label='fit: t0=%5.3f, A=%5.3f, B=%5.3f, nu=%5.3f, Gamma=%5.3f' % tuple(popt_x))\n",
"plt.errorbar(scan_para, fitted_qtys_1, yerr=fitted_qtys_err_1, fmt='or')\n",
"plt.xlabel('hold time after switch on the trap (s)')\n",
"plt.ylabel('y center (pixels)')\n",
"plt.tight_layout()\n",
"plt.grid(visible=1)\n",
"#plt.ylim([0,750])\n",
"#plt.xlim([90, 121])\n",
"#plt.legend(prop={'size': 14})\n",
"plt.show()\n",
"\n",
"f_x = popt_x[3] / 1000\n",
"df_x = pcov_x[3][3]**0.5 / 1000\n",
"\n",
"print('f_y = %.4f \\u00B1 %.4f kHz'% tuple([np.abs(f_x),df_x]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"np.sqrt(0.091**2 + 0.334**2 + 0.447**2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"muB = 9.274e-24\n",
"hbar = 6.626e-34 / (2 * np.pi)\n",
"gJ = 1.24\n",
"Delta = 2 * np.pi * 579.12 * 1e3\n",
"\n",
"Bz = (Delta*hbar) / (muB*gJ)\n",
"print(Bz * 1e4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"(fitted_SlopeInkHz * 0.5) + fitted_offsetInkHz"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"l = list(np.arange(0.005, 0.04, 0.0007))\n",
"# l = np.logspace(np.log10(250e-6), np.log10(500e-3), num=15)\n",
"\n",
"l = [round(item, 7) for item in l]\n",
"#random.shuffle(l)\n",
"\n",
"print(l)\n",
"print(len(l))\n",
"np.mean(l)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## ODT 1 Calibration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"v_high = 2.7\n",
"\"\"\"High Power\"\"\"\n",
"P_arm1_high = 5.776 * v_high - 0.683\n",
"\n",
"v_mid = 0.2076\n",
"\"\"\"Intermediate Power\"\"\"\n",
"P_arm1_mid = 5.815 * v_mid - 0.03651\n",
"\n",
"v_low = 0.0587\n",
"\"\"\"Low Power\"\"\"\n",
"P_arm1_low = 5271 * v_low - 27.5\n",
"\n",
"print(round(P_arm1_high, 3))\n",
"print(round(P_arm1_mid, 3))\n",
"print(round(P_arm1_low, 3))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## ODT 2 Power Calibration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"v = 0.7607\n",
"P_arm2 = 2.302 * v - 0.06452\n",
"print(round(P_arm2, 3))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
},
"vscode": {
"interpreter": {
"hash": "c05913ad4f24fdc6b2418069394dc5835b1981849b107c9ba6df693aafd66650"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}