Calculations/Time Series Analyzer/Intensity Noise Analysis.ipynb

550 lines
957 KiB
Plaintext
Raw Normal View History

2024-03-25 17:52:11 +01:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
2024-03-25 17:52:11 +01:00
"id": "6c616b70",
"metadata": {},
"outputs": [],
"source": [
"from Analyzer import *\n",
"import numpy as np"
2024-03-25 17:52:11 +01:00
]
},
{
"cell_type": "code",
"execution_count": 4,
2024-03-25 17:52:11 +01:00
"id": "96bd598e",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Synthetic data to validate analysis\"\"\"\n",
"# # Generate time series data with values against time in seconds\n",
"# num_seconds = 10 # Total number of seconds\n",
"# time = np.arange(0, num_seconds, 1/30) # Create timestamp index\n",
"# voltage = np.sin(2*np.pi*4*time) + np.sin(2*np.pi*7*time) + np.random.randn(len(time))*0.2 # Generate 4 Hz and 7 Hz sine wave\n",
"# data = np.column_stack((time, voltage))\n",
"\n",
"\"\"\"Real data\"\"\" \n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_bkg = \"Arm 1/PID_Active_SP_7V_Mod_1.0_20khz\"\n",
"filepath_bkg = dir + filename_bkg + \".csv\"\n",
"\n",
"background_data = extract_data(filepath_bkg)\n",
"\n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_data = \"Arm 1/PID_Inactive_SP_7V_Mod_1.0_20khz\"\n",
"filepath_data = dir + filename_data + \".csv\"\n",
"\n",
"data = extract_data(filepath_data)"
]
},
{
"cell_type": "code",
"execution_count": 5,
2024-03-25 17:52:11 +01:00
"id": "354ff9ed",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time_bkg = background_data[:, 0]\n",
"voltage_bkg = background_data[:, 1]\n",
" \n",
"processed_data_bkg, Sxx_bkg = compute_psd(background_data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 6,
2024-03-25 17:52:11 +01:00
"id": "bad46fa8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time = data[:, 0]\n",
"voltages = data[:, 1]\n",
"\n",
"processed_data, Sxx = compute_psd(data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 7,
2024-03-25 17:52:11 +01:00
"id": "e11977b3",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAMWCAYAAAAgRDUeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3hU1dbG35n0BEjoKXQRRLqCgOgFLwIiRaQE5Ar4IXoVkSZ2L4JXbBCKKKjIpYhUARVEQERQFCx0EGlCgGTSk0mZzKTt748xQ8ZkkrNPzznr9zx5InPWWmfNnvfNubPv2ftYGGMMBEEQBEEQBEEQBEEQBKEiVq0bIAiCIAiCIAiCIAiCIMwHTUoRBEEQBEEQBEEQBEEQqkOTUgRBEARBEARBEARBEITq0KQUQRAEQRAEQRAEQRAEoTo0KUUQBEEQBEEQBEEQBEGoDk1KEQRBEARBEARBEARBEKpDk1IEQRAEQRAEQRAEQRCE6tCkFEEQBEEQBEEQBEEQBKE6/lo3UB0oKSlBYmIiatasCYvFonU7BEEQBEEQBEEQBEEQuoUxhpycHERHR8Nq9X0/FE1KCSAxMRGNGzfWug2CIAiCIAiCIAiCIIhqw7Vr19CoUSOfx2lSSgA1a9YE4B7MWrVqVRhzyy23wGazISoqCn/88Yea7RGELiAPEGaG9E+YHfIAYWZI/4SZIf0TvsjOzkbjxo098yk+YUSV2O12BoBduHDBZ0xUVBQDwKKiolTsTH2SkpLY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ux7Qw1iQ/uXJIf3zo5exIA/Ik0Me4EMv40D6lyenNLawsBAzZszAXXfdhXbt2gGA53tCw4Y
2024-03-25 17:52:11 +01:00
"text/plain": [
"<Figure size 1200x800 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_analysis(processed_data_bkg, processed_data, Sxx_bkg, Sxx, filename_bkg, filename_data, peak_find_threshold=-60)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2522948d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 8,
2024-03-25 17:52:11 +01:00
"id": "f91c772c",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Synthetic data to validate analysis\"\"\"\n",
"# # Generate time series data with values against time in seconds\n",
"# num_seconds = 10 # Total number of seconds\n",
"# time = np.arange(0, num_seconds, 1/30) # Create timestamp index\n",
"# voltage = np.sin(2*np.pi*4*time) + np.sin(2*np.pi*7*time) + np.random.randn(len(time))*0.2 # Generate 4 Hz and 7 Hz sine wave\n",
"# data = np.column_stack((time, voltage))\n",
"\n",
"\"\"\"Real data\"\"\" \n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_bkg = \"Arm 1/PID_Active_SP_7V_Mod_1.0_100khz\"\n",
"filepath_bkg = dir + filename_bkg + \".csv\"\n",
"\n",
"background_data = extract_data(filepath_bkg)\n",
"\n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_data = \"Arm 1/PID_Inactive_SP_7V_Mod_1.0_100khz\"\n",
"filepath_data = dir + filename_data + \".csv\"\n",
"\n",
"data = extract_data(filepath_data)"
]
},
{
"cell_type": "code",
"execution_count": 9,
2024-03-25 17:52:11 +01:00
"id": "f8ad9496",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time_bkg = background_data[:, 0]\n",
"voltage_bkg = background_data[:, 1]\n",
" \n",
"processed_data_bkg, Sxx_bkg = compute_psd(background_data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 10,
2024-03-25 17:52:11 +01:00
"id": "1a9afee9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time = data[:, 0]\n",
"voltages = data[:, 1]\n",
"\n",
"processed_data, Sxx = compute_psd(data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 11,
2024-03-25 17:52:11 +01:00
"id": "3bbcd482",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAMWCAYAAAAgRDUeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5gUxdbG35nNC5vIu0tWxIBIEAVzBAMqoijqVUyoV1FRuVc/A4JZAb2KoqiIGURBUUBBRBEQBCQjkiSzOczmXN8f646s7CxVMz091d3v73nmWXf6nNOnq9/X9dbtqnYJIQQIIYQQQgghhBBCCDERd6gbIIQQQgghhBBCCCHOg5NShBBCCCGEEEIIIcR0OClFCCGEEEIIIYQQQkyHk1KEEEIIIYQQQgghxHQ4KUUIIYQQQgghhBBCTIeTUoQQQgghhBBCCCHEdDgpRQghhBBCCCGEEEJMh5NShBBCCCGEEEIIIcR0wkPdgBWoqanBwYMHERcXB5fLFep2CCGEEEIIIYQQQrRFCIHCwkKkpKTA7fb9PBQnpSQ4ePAg2rVrF+o2CCGEEEIIIYQQQizDvn370LZtW5/HOSklQVxcHIDawYyPj28w5thjj0VaWhqSk5Pxxx9/mNkeIVpADxAnQ/0Tp0MPECdD/RMnQ/0TXxQUFKBdu3be+RSfCHJEPB6PACC2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rxezc+dOXHnllWjZsiXi4+NxzTXXICMjo17MmjVrcOGFF6JZs2Zo06YNhg0bhqKionoxP/zwA0477TTExcUhOTkZDz/8MKqqqhq9ziO
2024-03-25 17:52:11 +01:00
"text/plain": [
"<Figure size 1200x800 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_analysis(processed_data_bkg, processed_data, Sxx_bkg, Sxx, filename_bkg, filename_data, peak_find_threshold=-60)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d58a4d17",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "960c77bc",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 12,
2024-03-25 17:52:11 +01:00
"id": "27ef8df7",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Synthetic data to validate analysis\"\"\"\n",
"# # Generate time series data with values against time in seconds\n",
"# num_seconds = 10 # Total number of seconds\n",
"# time = np.arange(0, num_seconds, 1/30) # Create timestamp index\n",
"# voltage = np.sin(2*np.pi*4*time) + np.sin(2*np.pi*7*time) + np.random.randn(len(time))*0.2 # Generate 4 Hz and 7 Hz sine wave\n",
"# data = np.column_stack((time, voltage))\n",
"\n",
"\"\"\"Real data\"\"\" \n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_bkg = \"Arm 1/PID_Active_SP_7V_Mod_0.5\"\n",
"filepath_bkg = dir + filename_bkg + \".csv\"\n",
"\n",
"background_data = extract_data(filepath_bkg)\n",
"\n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_data = \"Arm 1/PID_Inactive_SP_7V_Mod_0.5\"\n",
"filepath_data = dir + filename_data + \".csv\"\n",
"\n",
"data = extract_data(filepath_data)"
]
},
{
"cell_type": "code",
"execution_count": 13,
2024-03-25 17:52:11 +01:00
"id": "716046fb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time_bkg = background_data[:, 0]\n",
"voltage_bkg = background_data[:, 1]\n",
" \n",
"processed_data_bkg, Sxx_bkg = compute_psd(background_data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 14,
2024-03-25 17:52:11 +01:00
"id": "dec099f0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time = data[:, 0]\n",
"voltages = data[:, 1]\n",
"\n",
"processed_data, Sxx = compute_psd(data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 15,
2024-03-25 17:52:11 +01:00
"id": "c6317732",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAMWCAYAAAAgRDUeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3gVVfrHvzc9JBB6SZAiNhQR7IqKDVwLgjTLiqiI66qLjd/quisLKlbAjgVQsdFRsQEqghVFEKQoKL2kd1Ju2vz+yOaaSG5yzsyZkjnfz/PkCbnzvu+899zvN/PkMOdMwDAMA4QQQgghhBBCCCGEOEiE2w0QQgghhBBCCCGEEP3gpBQhhBBCCCGEEEIIcRxOShFCCCGEEEIIIYQQx+GkFCGEEEIIIYQQQghxHE5KEUIIIYQQQgghhBDH4aQUIYQQQgghhBBCCHEcTkoRQgghhBBCCCGEEMfhpBQhhBBCCCGEEEIIcZwotxtoClRVVeHAgQNo3rw5AoGA2+0QQgghhBBCCCGEeBbDMFBYWIjk5GRERIS/H4qTUgIcOHAAhx12mNttEEIIIYQQQgghhDQZ9u7di86dO4c9zkkpAZo3bw6gejBbtGh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1tJmZGTgqaeeQkZGhq/7UFnfSi0zuTI5orEicfSAf3qg/uXjqH9/9UEPyMfp4AHq39la1L/3qKiowPr16+kBh2o1FQ/oon9eA+yDy/cEqLntLCMjA+3atas3RpfbFoPBIPbu3YvDDjsMsbGxvu1DZX0rtczkyuSIxorE0QP+6YH6l4+j/v3VBz0gH6eDB6h
2024-03-25 17:52:11 +01:00
"text/plain": [
"<Figure size 1200x800 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_analysis(processed_data_bkg, processed_data, Sxx_bkg, Sxx, filename_bkg, filename_data, peak_find_threshold=-60)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c4dc198",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 16,
2024-03-25 17:52:11 +01:00
"id": "05fa8d30",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Synthetic data to validate analysis\"\"\"\n",
"# # Generate time series data with values against time in seconds\n",
"# num_seconds = 10 # Total number of seconds\n",
"# time = np.arange(0, num_seconds, 1/30) # Create timestamp index\n",
"# voltage = np.sin(2*np.pi*4*time) + np.sin(2*np.pi*7*time) + np.random.randn(len(time))*0.2 # Generate 4 Hz and 7 Hz sine wave\n",
"# data = np.column_stack((time, voltage))\n",
"\n",
"\"\"\"Real data\"\"\" \n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_bkg = \"Arm 1/PID_Active_SP_7V_Mod_0\"\n",
"filepath_bkg = dir + filename_bkg + \".csv\"\n",
"\n",
"background_data = extract_data(filepath_bkg)\n",
"\n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_data = \"Arm 1/PID_Inactive_SP_7V_Mod_0\"\n",
"filepath_data = dir + filename_data + \".csv\"\n",
"\n",
"data = extract_data(filepath_data)"
]
},
{
"cell_type": "code",
"execution_count": 17,
2024-03-25 17:52:11 +01:00
"id": "1f4a1b8b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time_bkg = background_data[:, 0]\n",
"voltage_bkg = background_data[:, 1]\n",
" \n",
"processed_data_bkg, Sxx_bkg = compute_psd(background_data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 18,
2024-03-25 17:52:11 +01:00
"id": "a00aa553",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time = data[:, 0]\n",
"voltages = data[:, 1]\n",
"\n",
"processed_data, Sxx = compute_psd(data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 19,
2024-03-25 17:52:11 +01:00
"id": "ebb9c09a",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAMWCAYAAAAgRDUeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd5gUVdbG3+6eHGDIM0NOiiKIghEFDGvAgHnVXcPi6rrqrnHX3f0MmHbNCbOYcxZQQVQEQUEQSYKA5DA559Dd9f1RzAwD0zP3Vle4XfX+nodnZrrOOX3q9vva33f33ls+TdM0EEIIIYQQQgghhBBiI36nGyCEEEIIIYQQQggh3oOTUoQQQgghhBBCCCHEdjgpRQghhBBCCCGEEEJsh5NShBBCCCGEEEIIIcR2OClFCCGEEEIIIYQQQmyHk1KEEEIIIYQQQgghxHY4KUUIIYQQQgghhBBCbIeTUoQQQgghhBBCCCHEduKcbiAWCIfDyMnJQXp6Onw+n9PtEEIIIYQQQgghhCiLpmmorKxEdnY2/P7I66E4KSVATk4O+vbt63QbhBBCCCGEEEIIITHDjh070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+X6uf8Pn0iafuR7Zf9OB7gflnAN2PAhI6m9WqZcTHxyMzMxPx8fGu7sPM+tHUMpIrkyMaKxK3jwdcigoeoP7NyaH+5VFB/3b0QQ/Ix3nBA9S/vbWof/WgB+ytFSseoP7d1YcT98kzpQQQ2QsZ1V7aggXA1reAw58zoVtCnIH7yYmXof6J16EHiJeh/omXof5JJETPlOL2PQlCoZA1hXseC/gT9cPPFScUCqGiosK
2024-03-25 17:52:11 +01:00
"text/plain": [
"<Figure size 1200x800 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_analysis(processed_data_bkg, processed_data, Sxx_bkg, Sxx, filename_bkg, filename_data, peak_find_threshold=-60)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "699f9f52",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 20,
2024-03-25 17:52:11 +01:00
"id": "67f9cd80",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Synthetic data to validate analysis\"\"\"\n",
"# # Generate time series data with values against time in seconds\n",
"# num_seconds = 10 # Total number of seconds\n",
"# time = np.arange(0, num_seconds, 1/30) # Create timestamp index\n",
"# voltage = np.sin(2*np.pi*4*time) + np.sin(2*np.pi*7*time) + np.random.randn(len(time))*0.2 # Generate 4 Hz and 7 Hz sine wave\n",
"# data = np.column_stack((time, voltage))\n",
"\n",
"\"\"\"Real data\"\"\" \n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_bkg = \"Arm 2/PID_Active_SP_9V\"\n",
"filepath_bkg = dir + filename_bkg + \".csv\"\n",
"\n",
"background_data = extract_data(filepath_bkg)\n",
"\n",
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time Series Data/\"\n",
"filename_data = \"Arm 2/PID_Inactive_SP_9V\"\n",
"filepath_data = dir + filename_data + \".csv\"\n",
"\n",
"data = extract_data(filepath_data)"
]
},
{
"cell_type": "code",
"execution_count": 21,
2024-03-25 17:52:11 +01:00
"id": "be833e35",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time_bkg = background_data[:, 0]\n",
"voltage_bkg = background_data[:, 1]\n",
" \n",
"processed_data_bkg, Sxx_bkg = compute_psd(background_data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 22,
2024-03-25 17:52:11 +01:00
"id": "a37ab5b3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating power spectrum...\n"
]
}
],
"source": [
"# Extract the first and second columns from data_array\n",
"time = data[:, 0]\n",
"voltages = data[:, 1]\n",
"\n",
"processed_data, Sxx = compute_psd(data, new_sampling_rate = 1000000)"
]
},
{
"cell_type": "code",
"execution_count": 23,
2024-03-25 17:52:11 +01:00
"id": "e5ca8ba3",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAMWCAYAAAAgRDUeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3gU1f7G3930hBJCaAGpggpYEBRRENvVnwL2roBi71673iuC/Sr23gFFsIAFBSsqoiBKBwWUFkp62YT0Teb3R8xCJBvOmT07c2bm/TxPHpOd7/e775y8L3nu3JmzPsMwDBBCCCGEEEIIIYQQYiF+uwUQQgghhBBCCCGEEO/Bi1KEEEIIIYQQQgghxHJ4UYoQQgghhBBCCCGEWA4vShFCCCGEEEIIIYQQy+FFKUIIIYQQQgghhBBiObwoRQghhBBCCCGEEEIshxelCCGEEEIIIYQQQojl8KIUIYQQQgghhBBCCLGcWLsFOIG6ujrs2LEDLVu2hM/ns1sOIYQQQgghhBBCiLYYhoHS0lJkZGTA7w9/PxQvSgmwY8c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V6RGtF6nw+X6P/uhUdMkD/q+mh/+XRwf9W6GAG5Ou8kAH639pZ9L9+MAPWznJKBuh/d+mw4zy5p5QAIs9Cdu7cGTt27ABaArgVmHXuLJxxwBnWCiXERvg8OfEy9D/xOswA8TL0P/Ey9D8Jh+ieUrxTSoLa2tqwx/55ZfiGuTegtKo02pIsp7a2FiUlJc2uhRt0qJwfySwzvTI9orW6/N51QIe1oP/V9ND/8uiyFsyAmh5mQA5d1oH+V9ND/8ujy1owA2p6mAE5dFk
2024-03-25 17:52:11 +01:00
"text/plain": [
"<Figure size 1200x800 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_analysis(processed_data_bkg, processed_data, Sxx_bkg, Sxx, filename_bkg, filename_data, peak_find_threshold=-60)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "04388b5c",
2024-03-25 17:52:11 +01:00
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}