2023-04-24 13:03:23 +02:00
|
|
|
{
|
|
|
|
"cells": [
|
2023-05-04 13:47:33 +02:00
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Import supporting package"
|
|
|
|
]
|
|
|
|
},
|
2023-04-24 13:03:23 +02:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-04-24 13:03:23 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-05-04 13:47:33 +02:00
|
|
|
"import xarray as xr\n",
|
|
|
|
"import numpy as np\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",
|
|
|
|
"\n",
|
|
|
|
"imageAnalyser = ImageAnalyser()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Start a client for parallel computing"
|
2023-04-24 13:03:23 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
2023-05-04 18:32:17 +02:00
|
|
|
"outputs": [],
|
2023-05-04 13:47:33 +02:00
|
|
|
"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": [
|
|
|
|
"# Read data"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Set file path"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-04-24 13:03:23 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-05-04 18:32:17 +02:00
|
|
|
"# filepath = \"//DyLabNAS/Data/Evaporative_Cooling/2023/05/03/0043/*.h5\"\n",
|
2023-04-24 13:03:23 +02:00
|
|
|
"# filepath = \"//DyLabNAS/Data/Evaporative_Cooling/2023/04/18/0003/2023-04-18_0003_Evaporative_Cooling_000.h5\"\n",
|
|
|
|
"\n",
|
2023-05-04 18:32:17 +02:00
|
|
|
"filepath = \"//DyLabNAS/Data/Repetition_scan/2023/04/21/0002/*.h5\"\n",
|
2023-05-04 13:47:33 +02:00
|
|
|
"\n",
|
2023-05-04 18:32:17 +02:00
|
|
|
"# filepath = r\"./testData/0000/*.h5\"\n",
|
2023-04-24 13:03:23 +02:00
|
|
|
"\n",
|
2023-05-04 18:32:17 +02:00
|
|
|
"# filepath = \"//DyLabNAS/Data/Evaporative_Cooling/2023/04/18/0003/*.h5\""
|
2023-05-04 13:47:33 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-04-24 13:03:23 +02:00
|
|
|
"groupList = [\n",
|
|
|
|
" \"images/MOT_3D_Camera/in_situ_absorption\",\n",
|
2023-05-04 13:47:33 +02:00
|
|
|
" # \"images/ODT_1_Axis_Camera/in_situ_absorption\",\n",
|
2023-04-24 13:03:23 +02:00
|
|
|
"]\n",
|
|
|
|
"\n",
|
|
|
|
"dskey = {\n",
|
|
|
|
" \"images/MOT_3D_Camera/in_situ_absorption\": \"camera_1\",\n",
|
2023-05-04 13:47:33 +02:00
|
|
|
" # \"images/ODT_1_Axis_Camera/in_situ_absorption\": \"camera_2\",\n",
|
2023-04-24 13:03:23 +02:00
|
|
|
"}\n",
|
|
|
|
"\n",
|
2023-05-04 13:47:33 +02:00
|
|
|
"datasetDict = {\n",
|
2023-04-24 13:03:23 +02:00
|
|
|
" dskey[groupList[i]]: read_hdf5_file(filepath, groupList[i])\n",
|
|
|
|
" for i in range(len(groupList))\n",
|
|
|
|
"}"
|
|
|
|
]
|
|
|
|
},
|
2023-05-04 13:47:33 +02:00
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Rechunk the data for parallel computing"
|
|
|
|
]
|
|
|
|
},
|
2023-04-24 13:03:23 +02:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"dataset = datasetDict[\"camera_1\"]\n",
|
|
|
|
"\n",
|
|
|
|
"scanAxis = dataset.scanAxis\n",
|
|
|
|
"\n",
|
2023-05-04 18:32:17 +02:00
|
|
|
"# dataset = dataset.chunk(\n",
|
|
|
|
"# {\n",
|
|
|
|
"# # \"compZ_current_sg\": \"auto\",\n",
|
|
|
|
"# \"sin_mod_freq\": \"auto\",\n",
|
|
|
|
"# \"runs\": 2,\n",
|
|
|
|
"# \"x\": \"auto\",\n",
|
|
|
|
"# \"y\": \"auto\",\n",
|
|
|
|
"# }\n",
|
|
|
|
"# )"
|
2023-05-04 13:47:33 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Calculate absorption imaging"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## get OD images"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-04-24 13:03:23 +02:00
|
|
|
"metadata": {},
|
2023-05-04 18:32:17 +02:00
|
|
|
"outputs": [],
|
2023-05-04 13:47:33 +02:00
|
|
|
"source": [
|
|
|
|
"dataset = imageAnalyser.get_absorption_images(dataset)\n",
|
|
|
|
"\n",
|
|
|
|
"dataset"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Select region of interests"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-05-04 18:32:17 +02:00
|
|
|
"imageAnalyser.center = (529, 962)\n",
|
2023-05-04 13:47:33 +02:00
|
|
|
"imageAnalyser.span = (100,100)\n",
|
|
|
|
"imageAnalyser.fraction = (0.1, 0.1)\n",
|
|
|
|
"\n",
|
|
|
|
"# imageAnalyser.center = (890, 1150)\n",
|
|
|
|
"# imageAnalyser.span = (600,600)\n",
|
|
|
|
"# imageAnalyser.fraction = (0.1, 0.1)\n",
|
|
|
|
"\n",
|
|
|
|
"# imageAnalyser.center = (890, 950)\n",
|
|
|
|
"# imageAnalyser.span = (100,100)\n",
|
|
|
|
"# imageAnalyser.fraction = (0.1, 0.1)\n",
|
|
|
|
"\n",
|
|
|
|
"dataset_crop = imageAnalyser.crop_image(dataset)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
2023-05-04 18:32:17 +02:00
|
|
|
"outputs": [],
|
2023-04-24 13:03:23 +02:00
|
|
|
"source": [
|
2023-05-04 18:32:17 +02:00
|
|
|
"dataset_crop.OD.isel(runs=[0]).plot.pcolormesh(cmap='jet', vmin=0, col=scanAxis[0], row=scanAxis[1])\n",
|
|
|
|
"# dataset_crop.OD.plot()"
|
2023-05-04 13:47:33 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Remove the background"
|
2023-04-24 13:03:23 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-04-24 13:03:23 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-05-04 13:47:33 +02:00
|
|
|
"dataset_crop['OD'] = dataset_crop['OD'] + 500"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"dataset_crop['OD'] = imageAnalyser.substract_offset(dataset_crop['OD'])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Test Fit"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-05-04 18:32:17 +02:00
|
|
|
"fitAnalyser = FitAnalyser(\"Two Gaussian-2D\", fitDim=2)\n",
|
2023-04-24 13:03:23 +02:00
|
|
|
"\n",
|
2023-05-04 13:47:33 +02:00
|
|
|
"params = fitAnalyser.guess(dataset_crop.OD, dask=\"parallelized\")"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"fitResult = fitAnalyser.fit(dataset_crop.OD, params, dask=\"parallelized\")"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2023-05-04 18:32:17 +02:00
|
|
|
"fitCurve = fitAnalyser.eval(fitResult, x=np.arange(100), y=np.arange(100)).load()"
|
2023-05-04 13:47:33 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
2023-05-04 18:32:17 +02:00
|
|
|
"outputs": [],
|
2023-05-04 13:47:33 +02:00
|
|
|
"source": [
|
2023-05-04 18:32:17 +02:00
|
|
|
"fitCurve.isel(**{scanAxis[0]:np.arange(30), 'runs':range(dataset_crop.OD['runs'].size)}).plot.pcolormesh(cmap='jet', vmin=0, col=scanAxis[0], row=scanAxis[1])"
|
2023-05-04 13:47:33 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"attachments": {},
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# Get the Ncount"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"Ncount = dataset_crop.OD.sum(dim=(scanAxis[1], 'x', 'y'))"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-05-04 18:32:17 +02:00
|
|
|
"execution_count": null,
|
2023-05-04 13:47:33 +02:00
|
|
|
"metadata": {},
|
2023-05-04 18:32:17 +02:00
|
|
|
"outputs": [],
|
2023-05-04 13:47:33 +02:00
|
|
|
"source": [
|
2023-05-04 18:32:17 +02:00
|
|
|
"fig = plt.figure()\n",
|
|
|
|
"Ncount.plot(fig=fig)"
|
2023-04-24 13:03:23 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
2023-05-04 13:47:33 +02:00
|
|
|
"display_name": "env",
|
2023-04-24 13:03:23 +02:00
|
|
|
"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",
|
2023-05-04 18:32:17 +02:00
|
|
|
"version": "3.9.13"
|
2023-04-24 13:03:23 +02:00
|
|
|
},
|
2023-05-04 13:47:33 +02:00
|
|
|
"orig_nbformat": 4,
|
|
|
|
"vscode": {
|
|
|
|
"interpreter": {
|
|
|
|
"hash": "c05913ad4f24fdc6b2418069394dc5835b1981849b107c9ba6df693aafd66650"
|
|
|
|
}
|
|
|
|
}
|
2023-04-24 13:03:23 +02:00
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 2
|
|
|
|
}
|