analyseScript/magenticField.ipynb

2381 lines
334 KiB
Plaintext
Raw Normal View History

2023-06-29 11:54:10 +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-6b96bd98-14cc-11ee-84cc-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;\">4e95eff3</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-06ee832c-dd0b-4c48-a7b6-ae1064b4a1bf</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:62877\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:62921\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:62923/status\" target=\"_blank\">http://127.0.0.1:62923/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:62880\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-he_941fu\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:62922\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:62924/status\" target=\"_blank\">http://127.0.0.1:62924/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:62881\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-3sii11m3\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:62916\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:62919/status\" target=\"_blank\">http://127.0.0.1:62919/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:62882\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-fs_kjhm5\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:62931\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:62934/status\" target=\"_blank\">http://127.0.0.1:62934/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:62883\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-bc9tduav\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:62930\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:62932/status\" target=\"_blank\">http://127.0.0.1:62932/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:62884\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-xjws4_zw\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:62915\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:62917/status\" target=\"_blank\">http://127.0.0.1:62917/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:62885\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-8j774v71\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:62898\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:62913/status\" target=\"_blank\">http://127.0.0.1:62913/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:62886\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-yeltpw2b\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:62927\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:62928/status\" target=\"_blank\">http://127.0.0.1:62928/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:62887\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-z6tlv47i\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:62877' 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": [
"## Start a client for Mongo DB"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import pymongo\n",
"import xarray_mongodb\n",
"\n",
"from DataContainer.MongoDB import MongoDB\n",
"\n",
"mongoClient = pymongo.MongoClient('mongodb://control:DyLab2021@127.0.0.1:27017/?authMechanism=DEFAULT')"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set global path for experiment"
]
},
{
"cell_type": "code",
"execution_count": 4,
"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": 5,
"metadata": {},
"outputs": [],
"source": [
"# img_dir = 'C:/Users/control/DyLab/Experiments/DyBEC/'\n",
"# SequenceName = \"Repetition_scan\"\n",
"# folderPath = img_dir + SequenceName + \"/\" + get_date()\n",
"\n",
"# mongoDB = mongoClient[SequenceName]\n",
"\n",
"# DB = MongoDB(mongoClient, mongoDB, date=get_date())"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAm8AAAHPCAYAAAAFwj37AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAACo9UlEQV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2PDq6++atYYqlevTr16//0i0Ov1xMbG5onYhBCioDrzzykmHRptmN+2GFcaDNjyQs9vy4oMm+YXqgopCTn7SU3Med1n+THi2C5jZDU06efnh6IoXLp0iT59+lCsWDFcXV0ZPHgwMTExj3SVyqpVq6hduzZ2dnYUL16cHj16cOPGjVyPzc/PjylTpgBQsWJFwzDrkSNHnvmzhBBCpEmf3zbswFCi9clUS07hWxdvGvTfX+ASN5Anb/lHaiLMK/XEahaAo8mD+df7/0Chws/r0wDo3r07vXr1YsiQIVy4cIFp06YBsH79ekOdESNGEBAQwNixY1m4cCFRUVHMmTOHxo0b8/vvv+Pq6vrEz9HpdIb99iDtyVtWhg4dSlRUFCtWrGD79u24u7sD4Onp+Sy3KYQQ4l8arYY5R6awO/gIAB0SkpjdYBq29YaYNzAzkuRN5CtDhgwxPOlq3bo1f//9N+vXr2fdunUoisLJkydZu3YtS5YsYeLEiYb3NW3alMqVK7N06VIWLlz4xM/Jamg0PDw8U1mZMmUoV64cAHXq1KFChQpPeWdCCCEelTa/bTB/Jtz7b35bx80o5RqYOzSzkuQtv7C2T3vS9QR6vZ7YuDiKOjiY/gxOa3vTtp+
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fx = [751.71168, 736.56597, 885.97705, 1118.95297, 1538.68901, 3085.17389, 4700.81524, 6434.98779, 8223.48942]\n",
"dfx = [1.32859, 1.28606, 0.99619, 0.99134, 1.03403, 0.35958, 0.33758, 0.38790, 0.31241]\n",
"x_offset_current = [0, 0.03, 0.05, 0.07, 0.1, 0.2, 0.3, 0.4, 0.515]\n",
"\n",
"fy = [751.71168, 918.67701, 1129.74687, 1429.82911, 1749.75310, 3089.87897, 4314.90128, 5387.64638, 6666.03670]\n",
"dfy = [1.32859, 0.90271, 1.33691, 1.77735, 1.42421, 1.58909, 1.73638, 1.40175, 1.00526]\n",
"y_offset_current = [0.0, 0.015, 0.03, 0.05, 0.07, 0.15, 0.22, 0.28, 0.35]\n",
"\n",
"fz = [751.71168, 1223.54627, 1739.13344, 2364.93284, 2798.24971, 3178.49790, 4275.39905, 5352.17283, 6637.80418, 8288.35264, 9573.59333]\n",
"dfz = [1.32859, 0.35554, 0.48471, 0.69762, 0.36873, 0.29413, 0.20667, 0.20818, 0.21978, 0.20285, 0.18495]\n",
"z_offset_current = [0.0, 0.03, 0.06, 0.095, 0.119, 0.140, 0.2, 0.259, 0.329, 0.419, 0.489]\n",
"\n",
"f = fy\n",
"df = dfy\n",
"offset_current = y_offset_current\n",
"\n",
"f_fit = fy[4:]\n",
"df_fit = dfy[4:]\n",
"offset_current_fit = y_offset_current[4:]\n",
"\n",
"x = np.array(offset_current_fit)\n",
"y = np.array(f_fit)\n",
"\n",
"# Degree of the fitting polynomial\n",
"deg = 1\n",
"# Parameters from the fit of the polynomial\n",
"p = np.polyfit(x, y, deg)\n",
"m = p[0] # Gradient\n",
"c = p[1] # y-intercept\n",
"\n",
"#print(f'The fitted straight line has equation y = {m:.1f}x {c:=+6.1f}')\n",
"\n",
"# Model the data using the parameters of the fitted straight line\n",
"y_model = np.polyval(p, x)\n",
"\n",
"# Create the linear (1 degree polynomial) model\n",
"model = np.poly1d(p)\n",
"# Fit the model\n",
"y_model = model(x)\n",
"\n",
"# Mean\n",
"y_bar = np.mean(y)\n",
"# Coefficient of determination, R²\n",
"R2 = np.sum((y_model - y_bar)**2) / np.sum((y - y_bar)**2)\n",
"\n",
"#print(f'R² = {R2:.2f}')\n",
"\n",
"fitted_SlopeInkHz = m\n",
"fitted_offsetInkHz = c\n",
"muB = 9.274e-24\n",
"hbar = 6.626e-34 / (2 * np.pi)\n",
"gJ = 1.24\n",
"Slope = (((2 * np.pi * fitted_SlopeInkHz * 1e3)*hbar) / (muB*gJ)) * 1e4\n",
"Offset = (((2 * np.pi * fitted_offsetInkHz * 1e3)*hbar) / (muB*gJ)) * 1e4\n",
"\n",
"def calib_fit(x, B):\n",
" alpha = ((2 * np.pi * fitted_SlopeInkHz * 1e3)*hbar) / (muB*gJ)\n",
" beta = ((2 * np.pi * fitted_offsetInkHz * 1e3)*hbar) / (muB*gJ)\n",
" delta_nu = ((muB * gJ) / hbar) * np.sqrt((B**2-beta**2) + ((alpha * x) + beta)**2)\n",
" return delta_nu / (2 * np.pi * 1e3)\n",
"\n",
"\n",
"popt, pcov = curve_fit(calib_fit, offset_current, f, np.array([0.1*1e-4]))\n",
"Boffset = popt[0] * 1e4\n",
"dBoffset = pcov[0][0]**0.5 * 1e4\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"plt.clf\n",
"plt.errorbar(offset_current, f, yerr=df, fmt='o')\n",
"xvals = np.linspace(0, 0.55, 500)\n",
"plt.plot(np.array(xvals), p[1] + p[0] * np.array(xvals), label=f'Line Fit')\n",
"plt.plot(xvals, calib_fit(xvals, *popt), label=f'Curve Fit')\n",
"plt.text(0.25, 2200, f'Line Slope = {Slope:.3f} G/A', fontsize=12)\n",
"plt.text(0.25, 1500, f'Line Offset = {Offset:=.3f} G', fontsize=12)\n",
"plt.text(0.25, 800, f'Bo= {Boffset:=.3f} +/- {dBoffset:=.3f} G', fontsize=12)\n",
"plt.xlabel('Y Offset Coil Current (A)', fontsize=12)\n",
"plt.ylabel('Resonance Frequency (kHz)', fontsize=12)\n",
"plt.xticks(fontsize=12)\n",
"plt.yticks(fontsize=12)\n",
"plt.legend(fontsize=12)\n",
"#plt.xlim(-0.01, 0.04)\n",
"plt.ylim(0, 10000)\n",
"plt.grid(visible=1)\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# X-comp coil"
]
},
{
"cell_type": "code",
"execution_count": 126,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGyCAYAAADptr7VAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm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+5cSVJ9fb22bdumGTNmBKSrIUOGaNKkSSooKLBqO3bskN/vV0ZGRsCYGRkZMsZoy5YtVq2goEAjRoxQcnKyVXM6nZo1a5YOHjyosrKy9p4KAACwiXYFnKqqKm3evFlpaWkaOnSopIa3sS5duqSkpKQm/UlJSTp69Kj8fr8k6ciRI5KkxMTEgL6YmBh5vV7reGNvS2NKUklJSYvzrK2tVXV1dcADAADYV7sCzvPPP69Lly7pwQcftGqVlZWSJI/H06Tf4/HIGKPz589bvS6XS/369Wu2t3Gsxt6Wxrz29zZn7dq1ioyMtB7x8fGtPEMAANATtSvgPPPMM4qOjtb06dObHHM4HC0+79pjre0Ltvday5YtU1VVlfU4depUi70AAKDna3PA+ctf/qLXXntNs2bNksvlsurR0dGSmr+icu7cOTkcDkVFRVm9fr9fFy9ebLb32is20dHRLY4pNX/FqJHL5VJERETAAwAA2FebA84zzzwjSZo3b15AfdiwYerbt6+Ki4ubPKe4uFjDhw+X2+2W9OFnbz7aW15eroqKCo0ePdqqJSYmtjimpIBeAADQu7Up4NTW1iovL0/jxo1rEiycTqemTp2q/Px81dTUWPWTJ0+qqKhIPp/PqqWnp8vtdis3Nzd
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fx = [751.71168, 736.56597, 885.97705, 1118.95297, 1538.68901, 3085.17389, 4700.81524, 6434.98779, 8223.48942]\n",
"dfx = [1.32859, 1.28606, 0.99619, 0.99134, 1.03403, 0.35958, 0.33758, 0.38790, 0.31241]\n",
"x_offset_current = [0, 0.03, 0.05, 0.07, 0.1, 0.2, 0.3, 0.4, 0.515]\n",
"\n",
"# fx = [736.56597, 885.97705, 1118.95297, 1538.68901, 3085.17389, 4700.81524, 6434.98779, 8223.48942]\n",
"# dfx = [1.28606, 0.99619, 0.99134, 1.03403, 0.35958, 0.33758, 0.38790, 0.31241]\n",
"# x_offset_current = [0.03, 0.05, 0.07, 0.1, 0.2, 0.3, 0.4, 0.515]\n",
"\n",
"data = xr.DataArray(\n",
" data=fx,\n",
" dims=['x'],\n",
" coords={\n",
" 'x': x_offset_current\n",
" } \n",
")\n",
"\n",
"data_std = xr.DataArray(\n",
" data=dfx,\n",
" dims=['x'],\n",
" coords={\n",
" 'x': x_offset_current\n",
" } \n",
")\n",
"\n",
"data.plot.errorbar(fmt='ob', yerr=data_std)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {},
"outputs": [],
"source": [
"def magnetic_field_func(x, b0=0, by0=0, alpha=1):\n",
" return 1 / (1e3 * 6.626e-34) * (9.273e-24 * 1.24) * np.sqrt( (b0**2 - by0**2) + (alpha * x + by0)**2 )\n",
"\n",
"data_quadratic = data\n",
"\n",
"fitModel_quadratic = NewFitModel(magnetic_field_func)\n",
"fitAnalyser_quadratic = FitAnalyser(fitModel_quadratic, fitDim=1)\n",
"params_quadratic = fitAnalyser_quadratic.fitModel.make_params()\n",
"params_quadratic.add(name=\"b0\", value= 0.3, max=np.inf, min=-np.inf, vary=True)\n",
"params_quadratic.add(name=\"by0\", value= 0.07, max=np.inf, min=-np.inf, vary=True)\n",
"params_quadratic.add(name=\"alpha\", value= 100, max=np.inf, min=-np.inf, vary=True)\n",
"fitResult_quadratic = fitAnalyser_quadratic.fit(data_quadratic, params_quadratic).load()\n",
"\n",
"fitCurve_quadratic = fitAnalyser_quadratic.eval(fitResult_quadratic, x=np.linspace(0, 0.6, 100), dask=\"parallelized\").load()"
]
},
{
"cell_type": "code",
"execution_count": 128,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAm8AAAHPCAYAAAAFwj37AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB6WUlEQVR4nO3dd1hUV/4G8HdoQ+8dbFEDoiAK9oLYokajoiYae4u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V2t9l6VVDG9ERERUKWw8/RCzdkYjTynQuLotfh4SCEdLqb7L0jqGNyIiIqrQ8pQC8/66hjXH7wMAevq7Y1EfP5gaG+q3MB1heCMiIqIKK10mx4RNFxB54zkAYHKnt/Fp+zqVYmLCqzC8ERERUYX0KCkLo9adxY1n6TA1NsC/+/njXT83fZelcwxvREREVOGce5CMj9afRWJmLpytpPh1aCD8PG31XVaZYHgjIiKiCmXHhVhM2XoZuXlK1He3xq9DA+FmY6bvssoMwxsRERFVCEqlwHcRN/FD5G0AQGcfFyzp7w9zk6oVZ6rWpyUiIqIKKTs3D5P/uIg9V54CAD5pVxtfdPaCgUHlnZjwKgxvREREVK49S5Nh9PqzuPw4FcaGEiwI8UPfAE99l6U3DG9ERERUbkXHpmLUurN4miaDnbkxfhociKa17PVdll4xvBEREVG5tC86Dp/9fgnZ8jzUcbbE6qFNUN3BXN9l6R3DGxEREZUrQgj8eOQOvt13AwDQpq4jlg9sDGtTYz1XVj4wvBE
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data_linear = data[3:]\n",
"\n",
"fitAnalyser_linear = FitAnalyser('Linear', fitDim=1)\n",
"params_linear = fitAnalyser_linear.guess(data_linear, dask=\"parallelized\")\n",
"fitResult_linear = fitAnalyser_linear.fit(data_linear, params_linear).load()\n",
"\n",
"fitCurve_linear = fitAnalyser_linear.eval(fitResult_linear, x=np.linspace(0, 0.5, 100), dask=\"parallelized\").load()\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"data.plot.errorbar(ax=ax, fmt='ob', yerr=data_std)\n",
"# fitCurve_linear.plot.errorbar(ax=ax)\n",
"fitCurve_quadratic.plot.errorbar(ax=ax)\n",
"\n",
"plt.xlabel('X Offset Coil Current (A)', fontsize=12)\n",
"plt.ylabel('Resonance Frequency (kHz)', fontsize=12)\n",
"plt.xticks(fontsize=12)\n",
"plt.yticks(fontsize=12)\n",
"# plt.legend(fontsize=12)\n",
"#plt.xlim(-0.01, 0.04)\n",
"# plt.ylim(0, 10000)\n",
"plt.grid(visible=1)\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 129,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body[data-theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: 'â–º';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: 'â–¼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-index-preview {\n",
" grid-column: 2 / 5;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data,\n",
".xr-index-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data,\n",
".xr-index-data-in:checked ~ .xr-index-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-index-name div,\n",
".xr-index-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data,\n",
".xr-index-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2,\n",
".xr-no-icon {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: ()\n",
"Data variables:\n",
" b0 object 0.435+/-0.016\n",
" by0 object -0.164+/-0.017\n",
" alpha object 9.52+/-0.05</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-05cbf367-574f-45e5-98fd-f2532de532ce' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-05cbf367-574f-45e5-98fd-f2532de532ce' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-2cac1ee7-d44a-409e-a1d6-5fb3b81d7410' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-2cac1ee7-d44a-409e-a1d6-5fb3b81d7410' class='xr-section-summary' title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-61f8ea8a-7171-490c-aba2-cefa0f0a3af7' class='xr-section-summary-in' type='checkbox' checked><label for='section-61f8ea8a-7171-490c-aba2-cefa0f0a3af7' class='xr-section-summary' >Data variables: <span>(3)</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>b0</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>0.435+/-0.016</div><input id='attrs-f7be1e84-7c68-4419-ad87-ba1f353393d0' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-f7be1e84-7c68-4419-ad87-ba1f353393d0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-e10443e6-b5c8-4635-808f-afc18505a93d' class='xr-var-data-in' type='checkbox'><label for='data-e10443e6-b5c8-4635-808f-afc18505a93d' 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.4354862392709215+/-0.016241255661794147, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>by0</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>-0.164+/-0.017</div><input id='attrs-a24f0b66-670b-43b8-994a-d9e43280d6d9' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-a24f0b66-670b-43b8-994a-d9e43280d6d9' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-da2b7bea-f86b-4433-b147-cf1694cf90cb' class='xr-var-data-in' type='checkbox'><label for='data-da2b7bea-f86b-4433-b147-cf1694cf90cb' 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.16389847359556292+/-0.017148268573828836, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>alpha</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>9.52+/-0.05</div><input id='attrs-15c77479-0068-4c20-958e-2dc56241d9d5' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-15c77479-0068-4c20-958e-2dc56241d9d5' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-551fa910-8da8-4f36-9eb0-5c44fc299dce' class='xr-var-data-in' type='checkbox'><label for='data-551fa910-8da8-4f36-9eb0-5c44fc299dce' 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(9.524149639955006+/-0.051341904930731916, dtype=object)</pre></div></li></ul></div></li><li class='
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: ()\n",
"Data variables:\n",
" b0 object 0.435+/-0.016\n",
" by0 object -0.164+/-0.017\n",
" alpha object 9.52+/-0.05"
]
},
"execution_count": 129,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fitAnalyser_quadratic.get_fit_full_result(fitResult_quadratic) * 1e4"
]
},
{
"cell_type": "code",
"execution_count": 130,
"metadata": {},
"outputs": [],
"source": [
"val_x = fitAnalyser_quadratic.get_fit_value(fitResult_quadratic) * 1e4\n",
"std_x = fitAnalyser_quadratic.get_fit_std(fitResult_quadratic) * 1e4\n",
"res_x = fitAnalyser_quadratic.get_fit_full_result(fitResult_quadratic) * 1e4"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Y-comp coil"
]
},
{
"cell_type": "code",
"execution_count": 131,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGyCAYAAADptr7VAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA0OElEQVR4nO3df1TU153/8deE0RmRAhlGDQiaVBOtCps29Qe7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mDFjgv+7tLRU6enpuvvuu7V582b5/X49/fTTSktL0zvvvKMBAwYEa7Ozs7Vq1SotX75cU6dO1aFDh7Ry5UqVlZXp+eefD9bV1tZq8uTJ+uCDD5STk6OBAwcqNzdXGRkZ2rNnjyZOnNiWqQAAABuZMBQXFxtJ5tVXX71u3dy5c43X6zVVVVXBtpMnT5o+ffqYZcuWBdsqKiqM2+02jzzySMjrs7OzjcPhMEePHg225ebmGklm//79wba6ujozatQoM27cuHCmYaqqqoykkPEBAIDuLZzP7w6/Bqe+vl7bt2/XnDlzFB0dHWwfOnSoJk2apMLCwmDbzp075ff7lZmZGdJHZmamjDHaunVrsK2wsFAjRoxQampqsM3pdGrevHk6ePCgysrKOnoqAACgh2pTwFm8eLGcTqeio6M1bdo0/fa3vw1uO378uC5fvqyUlJRmr0tJSdGxY8fk9/slSUeOHJEkJScnh9TFx8fL6/UGtzfWttanJB09erQtUwEAABYK6xqcmJgYLVmyROnp6YqLi9OxY8f0ve99T+np6fr1r3+
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fy = [751.71168, 918.67701, 1129.74687, 1429.82911, 1749.75310, 3089.87897, 4314.90128, 5387.64638, 6666.03670]\n",
"dfy = [1.32859, 0.90271, 1.33691, 1.77735, 1.42421, 1.58909, 1.73638, 1.40175, 1.00526]\n",
"y_offset_current = [0.0, 0.015, 0.03, 0.05, 0.07, 0.15, 0.22, 0.28, 0.35]\n",
"\n",
"# fy = [918.67701, 1129.74687, 1429.82911, 1749.75310, 3089.87897, 4314.90128, 5387.64638, 6666.03670]\n",
"# dfy = [0.90271, 1.33691, 1.77735, 1.42421, 1.58909, 1.73638, 1.40175, 1.00526]\n",
"# y_offset_current = [0.015, 0.03, 0.05, 0.07, 0.15, 0.22, 0.28, 0.35]\n",
"\n",
"data = xr.DataArray(\n",
" data=fy,\n",
" dims=['x'],\n",
" coords={\n",
" 'x': y_offset_current\n",
" } \n",
")\n",
"\n",
"data_std = xr.DataArray(\n",
" data=dfy,\n",
" dims=['x'],\n",
" coords={\n",
" 'x': y_offset_current\n",
" } \n",
")\n",
"\n",
"data.plot.errorbar(fmt='ob', yerr=data_std)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 132,
"metadata": {},
"outputs": [],
"source": [
"def magnetic_field_func(x, b0=0, by0=0, alpha=1):\n",
" return 1 / (1e3 * 6.626e-34) * (9.273e-24 * 1.24) * np.sqrt( (b0**2 - by0**2) + (alpha * x + by0)**2 )\n",
"\n",
"data_quadratic = data\n",
"\n",
"fitModel_quadratic = NewFitModel(magnetic_field_func)\n",
"fitAnalyser_quadratic = FitAnalyser(fitModel_quadratic, fitDim=1)\n",
"params_quadratic = fitAnalyser_quadratic.fitModel.make_params()\n",
"params_quadratic.add(name=\"b0\", value= 0.3, max=np.inf, min=-np.inf, vary=True)\n",
"params_quadratic.add(name=\"by0\", value= 0.07, max=np.inf, min=-np.inf, vary=True)\n",
"params_quadratic.add(name=\"alpha\", value= 100, max=np.inf, min=-np.inf, vary=True)\n",
"fitResult_quadratic = fitAnalyser_quadratic.fit(data_quadratic, params_quadratic).load()\n",
"\n",
"fitCurve_quadratic = fitAnalyser_quadratic.eval(fitResult_quadratic, x=np.linspace(0, 0.6, 100), dask=\"parallelized\").load()"
]
},
{
"cell_type": "code",
"execution_count": 133,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAm8AAAHQCAYAAAD3Qo21AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB46ElEQVR4nO3dd3hU1dbH8e+kVwhJKAmhSQ8tEARp0gQBAakCClKsgBT1inBBIFdFuBe9IEXlWlAQBamCghQBUao06b33JEACIf28f+TNSEzAzGSGSfl9niePztn77FmzGGBxztl7mwzDMBARERGR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/Mz942PjycuLi5TcRQdHU14eHiGce81Jvx5pe3v3j+rK3LpRo0axWuvvWZ+HRMTQ6lSpWjdunWG5/dsJSkpiTVr1tCqVStcXV1tPn5+ptxZT7mznnJnPeXOOg8yb8v/uMSHSw8Qn5RKSBFPZvSqRWiQ7f/ue1Dsnbv0u3N/J08Ub+XLl8fT05N9+/Zlatu3bx8VKlTAwyNtanH6s2779u2jfv365n6XL18mMjKS6tWrm4/VqFHjnmMC5r7p/923bx/t2rXL1PfuMf/K3d0dd3f3TMddXV3t+pvG3uPnZ8qd9ZQ76yl31lPurGPPvCWlpPLej4f5/LdTADxaqSgf9gzDz8vNLu/3oNkrd9kdM09MWHBxcaFDhw4sXryY2NhY8/GzZ8+yfv16unTpYj7Wpk0bPDw8mD17doYxZs+ejclkyrCWXOfOnTl8+HCGJUGSk5OZO3cu9evXJzg4GICSJUtSr14
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data_linear = data[3:]\n",
"\n",
"fitAnalyser_linear = FitAnalyser('Linear', fitDim=1)\n",
"params_linear = fitAnalyser_linear.guess(data_linear, dask=\"parallelized\")\n",
"fitResult_linear = fitAnalyser_linear.fit(data_linear, params_linear).load()\n",
"\n",
"fitCurve_linear = fitAnalyser_linear.eval(fitResult_linear, x=np.linspace(0, 0.5, 100), dask=\"parallelized\").load()\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"data.plot.errorbar(ax=ax, fmt='ob', yerr=data_std)\n",
"# fitCurve_linear.plot.errorbar(ax=ax)\n",
"fitCurve_quadratic.plot.errorbar(ax=ax)\n",
"\n",
"plt.xlabel('Y Offset Coil Current (A)', fontsize=12)\n",
"plt.ylabel('Resonance Frequency (kHz)', fontsize=12)\n",
"plt.xticks(fontsize=12)\n",
"plt.yticks(fontsize=12)\n",
"# plt.legend(fontsize=12)\n",
"#plt.xlim(-0.01, 0.04)\n",
"# plt.ylim(0, 10000)\n",
"plt.grid(visible=1)\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 134,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body[data-theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: 'â–º';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: 'â–¼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-index-preview {\n",
" grid-column: 2 / 5;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data,\n",
".xr-index-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data,\n",
".xr-index-data-in:checked ~ .xr-index-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-index-name div,\n",
".xr-index-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data,\n",
".xr-index-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2,\n",
".xr-no-icon {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: ()\n",
"Data variables:\n",
" b0 object 0.440+/-0.009\n",
" by0 object 0.202+/-0.015\n",
" alpha object 10.30+/-0.05</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-65c281c6-2c36-4496-9e23-a700b90819ce' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-65c281c6-2c36-4496-9e23-a700b90819ce' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-8318d64d-dd05-491e-a6f6-07f38de2619e' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-8318d64d-dd05-491e-a6f6-07f38de2619e' class='xr-section-summary' title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-ab018521-2dc5-4f64-a759-8c951922b69c' class='xr-section-summary-in' type='checkbox' checked><label for='section-ab018521-2dc5-4f64-a759-8c951922b69c' class='xr-section-summary' >Data variables: <span>(3)</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>b0</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>0.440+/-0.009</div><input id='attrs-909853d3-0cbb-4b52-a8da-d71ba069a7fb' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-909853d3-0cbb-4b52-a8da-d71ba069a7fb' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4546b020-7e06-402a-9ac2-83db067732a4' class='xr-var-data-in' type='checkbox'><label for='data-4546b020-7e06-402a-9ac2-83db067732a4' 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.44046053036292887+/-0.008743037526448819, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>by0</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>0.202+/-0.015</div><input id='attrs-90c38744-62fc-47b9-bb03-795b31d99a9a' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-90c38744-62fc-47b9-bb03-795b31d99a9a' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f6d9ce67-e2b6-4721-8ddc-5840cd33eec8' class='xr-var-data-in' type='checkbox'><label for='data-f6d9ce67-e2b6-4721-8ddc-5840cd33eec8' 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.2022134511996896+/-0.014697906285531557, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>alpha</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>10.30+/-0.05</div><input id='attrs-3524648c-1496-4088-bbe9-765d7f05351b' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-3524648c-1496-4088-bbe9-765d7f05351b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-0666538c-5594-4f58-af8b-f4d05c7a1744' class='xr-var-data-in' type='checkbox'><label for='data-0666538c-5594-4f58-af8b-f4d05c7a1744' 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(10.299175733301144+/-0.05309408600386392, dtype=object)</pre></div></li></ul></div></li><li class='
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: ()\n",
"Data variables:\n",
" b0 object 0.440+/-0.009\n",
" by0 object 0.202+/-0.015\n",
" alpha object 10.30+/-0.05"
]
},
"execution_count": 134,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fitAnalyser_quadratic.get_fit_full_result(fitResult_quadratic) * 1e4"
]
},
{
"cell_type": "code",
"execution_count": 135,
"metadata": {},
"outputs": [],
"source": [
"val_y = fitAnalyser_quadratic.get_fit_value(fitResult_quadratic) * 1e4\n",
"std_y = fitAnalyser_quadratic.get_fit_std(fitResult_quadratic) * 1e4\n",
"res_y = fitAnalyser_quadratic.get_fit_full_result(fitResult_quadratic) * 1e4"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Z-comp coil"
]
},
{
"cell_type": "code",
"execution_count": 136,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkMAAAG4CAYAAABGhOPcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAx9UlEQVR4nO3dfXSU5Z3/8c+YwAwhhhDCQ0ICuiBQIOjK8pDuRsKCGG0RGEDXI0sBW08Fa2LbVVAepBrAs6dbcjjQLUsxbfFhKQ6iLEIhBpoV5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OnDhh2rVrZ1544QVv7dy5c8bhcJinn37aZ7zs7Gxjs9nM4cOHvbWVK1caSWb37t3eWk1NjRk4cKAZPnx4i86joqLCSPKZHwAAuL215PU7aFeG2rVrJ0nq1KmTTz02NlZ33HGH2rdvr9raWm3evFmTJ09WTEyMt6d3794aPXq0Nm7c6K1t3bpVbrdbM2fO9Blv5syZMsbovffe89Y2btyo/v37KzU11VuLjIzUtGnTtHfvXpWUlATyVAEAQBgLWhj6wQ9+oNjYWD3zzDM6fvy4qqqqtHnzZv3mN7/RnDlz1LFjRx07dkyXL1/WkCFD/J4/ZMgQHT16VG63W5J06NAhSVJKSopPX0JCguLj473H63ubGlOSDh8+HLDzBAAA4S1o31p/11136ZNPPtGkSZPUp08fb/25557T8uXLJUllZWWSpLi4OL/nx8XFyRij8+fPKyEhQWVlZbLb7erYsWOjvfVj1Y/b1Jg
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fz = [751.71168, 1223.54627, 1739.13344, 2364.93284, 2798.24971, 3178.49790, 4275.39905, 5352.17283, 6637.80418, 8288.35264, 9573.59333]\n",
"dfz = [1.32859, 0.35554, 0.48471, 0.69762, 0.36873, 0.29413, 0.20667, 0.20818, 0.21978, 0.20285, 0.18495]\n",
"z_offset_current = [0.0, 0.03, 0.06, 0.095, 0.119, 0.140, 0.2, 0.259, 0.329, 0.419, 0.489]\n",
"\n",
"data = xr.DataArray(\n",
" data=fz,\n",
" dims=['x'],\n",
" coords={\n",
" 'x': z_offset_current\n",
" } \n",
")\n",
"\n",
"data_std = xr.DataArray(\n",
" data=dfz,\n",
" dims=['x'],\n",
" coords={\n",
" 'x': z_offset_current\n",
" } \n",
")\n",
"\n",
"data.plot.errorbar(fmt='ob', yerr=data_std)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 137,
"metadata": {},
"outputs": [],
"source": [
"def magnetic_field_func(x, b0=0, by0=0, alpha=1):\n",
" return 1 / (1e3 * 6.626e-34) * (9.273e-24 * 1.24) * np.sqrt( (b0**2 - by0**2) + (alpha * x + by0)**2 )\n",
"\n",
"data_quadratic = data\n",
"\n",
"fitModel_quadratic = NewFitModel(magnetic_field_func)\n",
"fitAnalyser_quadratic = FitAnalyser(fitModel_quadratic, fitDim=1)\n",
"params_quadratic = fitAnalyser_quadratic.fitModel.make_params()\n",
"params_quadratic.add(name=\"b0\", value= 0.3, max=np.inf, min=-np.inf, vary=True)\n",
"params_quadratic.add(name=\"by0\", value= 0.07, max=np.inf, min=-np.inf, vary=True)\n",
"params_quadratic.add(name=\"alpha\", value= 100, max=np.inf, min=-np.inf, vary=True)\n",
"fitResult_quadratic = fitAnalyser_quadratic.fit(data_quadratic, params_quadratic).load()\n",
"\n",
"fitCurve_quadratic = fitAnalyser_quadratic.eval(fitResult_quadratic, x=np.linspace(0, 0.6, 100), dask=\"parallelized\").load()"
]
},
{
"cell_type": "code",
"execution_count": 138,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAm8AAAHPCAYAAAAFwj37AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAACAEElEQVR4nO3dd3yN5//H8dfJOhlCJDFCFDVrk6KoXWoWKS2qVidqtL41vnaH0Wp/WkWnakvVqFFqK6o1K6i9Z2olQUJk378/8k3a0wQ5JzlOxvv5eOShue7rvs7n/jT4uO77vi6TYRgGIiIiIpIjODk6ABERERHJOBVvIiIiIjmIijcRERGRHETFm4iIiEgOouJNREREJAdR8SYiIiKSg6h4ExEREclBVLyJiIiI5CAujg4gr0lKSuKvv/7C29sbk8nk6HBEREQkmzAMg6ioKIoVK4aT0z3m1wwHi4yMNN58802jRYsWhr+/vwEY48aNs+iTkJBgfPDBB8aTTz5pFC9e3PDw8DAqVqxoDB8+3Lh+/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yoKPDcigVbyIiIpLtxCUkMWn1Eb7+/SwA9cv48XG3mvjnMzs2sGxAxZuIiIhkK5dvxjDg+xD2nLsOQP8mZRjasgLOTnnzNum/qXgTERGRbGPbqTAGzd9L2K04vN1d+PCZGrSoVMTRYWUrKt5ERETE4QzD4NMtp3l/7VGSDKhY1JtPewRRyt/L0aFlOyreRERExKEiY+IZunA/6w9
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data_linear = data[3:]\n",
"\n",
"fitAnalyser_linear = FitAnalyser('Linear', fitDim=1)\n",
"params_linear = fitAnalyser_linear.guess(data_linear, dask=\"parallelized\")\n",
"fitResult_linear = fitAnalyser_linear.fit(data_linear, params_linear).load()\n",
"\n",
"fitCurve_linear = fitAnalyser_linear.eval(fitResult_linear, x=np.linspace(0, 0.5, 100), dask=\"parallelized\").load()\n",
"\n",
"fig = plt.figure()\n",
"ax = fig.gca()\n",
"\n",
"data.plot.errorbar(ax=ax, fmt='ob', yerr=data_std)\n",
"# fitCurve_linear.plot.errorbar(ax=ax)\n",
"fitCurve_quadratic.plot.errorbar(ax=ax)\n",
"\n",
"plt.xlabel('Y Offset Coil Current (A)', fontsize=12)\n",
"plt.ylabel('Resonance Frequency (kHz)', fontsize=12)\n",
"plt.xticks(fontsize=12)\n",
"plt.yticks(fontsize=12)\n",
"# plt.legend(fontsize=12)\n",
"#plt.xlim(-0.01, 0.04)\n",
"# plt.ylim(0, 10000)\n",
"plt.grid(visible=1)\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 139,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body[data-theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: 'â–º';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: 'â–¼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-index-preview {\n",
" grid-column: 2 / 5;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data,\n",
".xr-index-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data,\n",
".xr-index-data-in:checked ~ .xr-index-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-index-name div,\n",
".xr-index-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data,\n",
".xr-index-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2,\n",
".xr-no-icon {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: ()\n",
"Data variables:\n",
" b0 object 0.4333+/-0.0007\n",
" by0 object 0.3254+/-0.0008\n",
" alpha object 10.6021+/-0.0022</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-f77d168d-c7f1-4cbb-be7f-2cef6dfaf365' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-f77d168d-c7f1-4cbb-be7f-2cef6dfaf365' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-57ddfb08-9489-4068-b143-f0306231c01c' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-57ddfb08-9489-4068-b143-f0306231c01c' class='xr-section-summary' title='Expand/collapse section'>Coordinates: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'></ul></div></li><li class='xr-section-item'><input id='section-cc75bd83-4893-4666-8e8c-e9d9cbec9fb9' class='xr-section-summary-in' type='checkbox' checked><label for='section-cc75bd83-4893-4666-8e8c-e9d9cbec9fb9' class='xr-section-summary' >Data variables: <span>(3)</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>b0</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>0.4333+/-0.0007</div><input id='attrs-d69271e3-d2be-4615-b6e9-16971b1d9bee' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-d69271e3-d2be-4615-b6e9-16971b1d9bee' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-9859a199-e6b6-4124-869a-40487a3bd516' class='xr-var-data-in' type='checkbox'><label for='data-9859a199-e6b6-4124-869a-40487a3bd516' 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.43327107997401876+/-0.0007013859839914253, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>by0</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>0.3254+/-0.0008</div><input id='attrs-001a69b2-d62f-4955-a882-ed50e4b925ea' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-001a69b2-d62f-4955-a882-ed50e4b925ea' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-637572eb-5cc6-461d-bf12-6de7cd87d0f5' class='xr-var-data-in' type='checkbox'><label for='data-637572eb-5cc6-461d-bf12-6de7cd87d0f5' 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.32538643700542086+/-0.000794288942625618, dtype=object)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>alpha</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>10.6021+/-0.0022</div><input id='attrs-36ac86c4-9b53-49ad-9820-b0daabbf0894' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-36ac86c4-9b53-49ad-9820-b0daabbf0894' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-03225bdf-14a6-42bc-9f5d-9f12aa4b7152' class='xr-var-data-in' type='checkbox'><label for='data-03225bdf-14a6-42bc-9f5d-9f12aa4b7152' 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(10.602080670806222+/-0.0022465278174072264, dtype=object)</pre></div></li></ul></div>
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: ()\n",
"Data variables:\n",
" b0 object 0.4333+/-0.0007\n",
" by0 object 0.3254+/-0.0008\n",
" alpha object 10.6021+/-0.0022"
]
},
"execution_count": 139,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fitAnalyser_quadratic.get_fit_full_result(fitResult_quadratic) * 1e4"
]
},
{
"cell_type": "code",
"execution_count": 140,
"metadata": {},
"outputs": [],
"source": [
"val_z = fitAnalyser_quadratic.get_fit_value(fitResult_quadratic) * 1e4\n",
"std_z = fitAnalyser_quadratic.get_fit_std(fitResult_quadratic) * 1e4\n",
"res_z = fitAnalyser_quadratic.get_fit_full_result(fitResult_quadratic) * 1e4"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 145,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.416688520216393+/-0.009836437571434223"
]
},
"execution_count": 145,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"umath.sqrt(res_x['by0'].item()**2 + res_y['by0'].item()**2 + res_z['by0'].item()**2)"
]
},
{
"cell_type": "code",
"execution_count": 148,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.43640594986928966+/-0.006152786477679057"
]
},
"execution_count": 148,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(res_x['b0'].item() + res_y['b0'].item() + res_z['b0'].item())/3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"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
}