2024-06-18 19:01:35 +02:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-09-04 17:06:13 +02:00
|
|
|
"execution_count": 1,
|
2024-06-18 19:01:35 +02:00
|
|
|
"id": "6c616b70",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2024-09-04 17:06:13 +02:00
|
|
|
"from Analyzer import *"
|
2024-06-18 19:01:35 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2024-09-04 17:06:13 +02:00
|
|
|
"execution_count": 2,
|
2024-06-18 19:01:35 +02:00
|
|
|
"id": "96bd598e",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"Calculating power spectrum...\n"
|
|
|
|
]
|
2024-09-04 17:06:13 +02:00
|
|
|
},
|
2024-06-18 19:01:35 +02:00
|
|
|
{
|
|
|
|
"data": {
|
2024-09-04 17:06:13 +02:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAMWCAYAAAAgRDUeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOy9d5hV1fX//75T6Qy9SROxYIkl9t6jiViiiSWWKNaoxJh8TfETxcQSS6yJiaDYosbYu6iIilFREA0o0gVheu/1/v7gN9cZ770zu6xzzr7nvF/Pw8NwZ62112zvy43bs/eNxePxOAghhBBCCCGEEEII8ZGsoBsghBBCCCGEEEIIIdGDm1KEEEIIIYQQQgghxHe4KUUIIYQQQgghhBBCfIebUoQQQgghhBBCCCHEd7gpRQghhBBCCCGEEEJ8h5tShBBCCCGEEEIIIcR3uClFCCGEEEIIIYQQQny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h6aEfhKSGbhCSHvpBXIZ3SmUuvFPKZ9rb21FTU4P29nbR2Kjg0pz40YvkGLa1TPJ1c1TjXXofuIJrc0I/5HPohzkuzQndkM+jG3a4NC/0Qz6Hfpjj0pxkmhu29STckhrDpfeBSwQxL9yUEqKkpAS33347SkpKRGKjdnZVZ/7C0IvkGLa1TPJ1c1Tj6UYyLrkB0A8vcuiHOS75QTfk8+iGHfQjuFpcO9yGbgRXz7aX8vJysTFU4+iH9/D4ngIqj501Nzdj48aNGD9+PPLz83uspxIbtccEdeYvDL1IjmFbyyRfN0c1nm4k45IbfvVDP8zj6Ee4e8l0N3Tz6IYd9CO4Wlw73IZuBFfPJLfr8b0vL/oS24/aXmQ
|
2024-06-18 19:01:35 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 1200x800 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"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",
|
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"ac_filename_list = [\"20240807/AC Coupling/P1.0_M0_OOL\",\n",
|
|
|
|
" \"20240807/AC Coupling/P5.0_M1.1_OOL\",\n",
|
|
|
|
" \"20240807/AC Coupling/P6.0_M2.1_OOL\",\n",
|
|
|
|
" \"20240807/AC Coupling/P7.0_M3.0_OOL\"]\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"dc_filename_list = [\"20240807/DC Coupling/P1.0_M0_OOL\",\n",
|
|
|
|
" \"20240807/DC Coupling/P5.0_M1.1_OOL\",\n",
|
|
|
|
" \"20240807/DC Coupling/P6.0_M2.1_OOL\",\n",
|
|
|
|
" \"20240807/DC Coupling/P7.0_M3.0_OOL\"]\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"idx = 3\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"filename = ac_filename_list[idx]\n",
|
|
|
|
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time-Series-Data/\"\n",
|
|
|
|
"filepath_data = dir + filename + \".csv\"\n",
|
|
|
|
"ac_data = extract_data(filepath_data)\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"filename = dc_filename_list[idx]\n",
|
|
|
|
"dir = str(globals()['_dh'][0]).replace('\\\\','/') + \"/Time-Series-Data/\"\n",
|
|
|
|
"filepath_data = dir + filename + \".csv\"\n",
|
|
|
|
"dc_data = extract_data(filepath_data)\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
|
|
|
"# Extract the first and second columns from data_array\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"dc_voltages = dc_data[:, 1]\n",
|
|
|
|
"ac_time = ac_data[:, 0]\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"processed_ac_data, Sxx_smooth = compute_psd(ac_data)\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"dt = ac_time[1] - ac_time[0] # Sampling interval / time step\n",
|
|
|
|
"N = ac_time.shape[0] # Total number of data points\n",
|
|
|
|
"f_s = 1 / dt # Sampling frequency\n",
|
|
|
|
"delta_f = f_s/N; # Step size in frequency domain\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"Skk, RIN_Sxx_smooth = compute_RIN(dc_voltages, delta_f, Sxx_smooth)\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"# plot_psd(processed_ac_data, Sxx_smooth, filename.split('/')[-1])\n",
|
2024-06-18 19:01:35 +02:00
|
|
|
"\n",
|
2024-09-04 17:06:13 +02:00
|
|
|
"plot_rin(processed_ac_data, RIN_Sxx_smooth, filename.split('/')[-1])"
|
2024-06-18 19:01:35 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2024-09-04 17:06:13 +02:00
|
|
|
"id": "1db01efd",
|
2024-06-18 19:01:35 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2024-09-04 17:06:13 +02:00
|
|
|
"plot_e_folding_time(processed_ac_data, Skk, 100, 1000, filename.split('/')[-1])"
|
2024-06-18 19:01:35 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2024-09-04 17:06:13 +02:00
|
|
|
"id": "3f19dbfa",
|
2024-06-18 19:01:35 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
2024-09-04 17:06:13 +02:00
|
|
|
"source": [
|
|
|
|
"plot_e_folding_time(processed_ac_data, Skk, 1000, 5000, filename.split('/')[-1])"
|
|
|
|
]
|
2024-06-18 19:01:35 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"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
|
|
|
|
}
|