{ "cells": [ { "cell_type": "markdown", "id": "dfef53e3-d4bc-4925-b907-d166f8ca3dad", "metadata": {}, "source": [ "# Experimental Data-Analysis " ] }, { "cell_type": "code", "execution_count": 3, "id": "8742325a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting pandas\n", " Downloading pandas-2.3.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.metadata (91 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m91.2/91.2 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting numpy>=1.26.0 (from pandas)\n", " Downloading numpy-2.3.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (62 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.1/62.1 kB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: python-dateutil>=2.8.2 in ./.venv/lib/python3.12/site-packages (from pandas) (2.9.0.post0)\n", "Collecting pytz>=2020.1 (from pandas)\n", " Using cached pytz-2025.2-py2.py3-none-any.whl.metadata (22 kB)\n", "Collecting tzdata>=2022.7 (from pandas)\n", " Using cached tzdata-2025.2-py2.py3-none-any.whl.metadata (1.4 kB)\n", "Requirement already satisfied: six>=1.5 in ./.venv/lib/python3.12/site-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n", "Downloading pandas-2.3.3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (12.4 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.4/12.4 MB\u001b[0m \u001b[31m9.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading numpy-2.3.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.6 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m16.6/16.6 MB\u001b[0m \u001b[31m11.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hUsing cached pytz-2025.2-py2.py3-none-any.whl (509 kB)\n", "Using cached tzdata-2025.2-py2.py3-none-any.whl (347 kB)\n", "Installing collected packages: pytz, tzdata, numpy, pandas\n", "Successfully installed numpy-2.3.3 pandas-2.3.3 pytz-2025.2 tzdata-2025.2\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install pandas" ] }, { "cell_type": "code", "execution_count": 17, "id": "5bbeed9a", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "from pathlib import Path\n", "from dataclasses import dataclass\n", "\n", "class Experimento:\n", " def __init__(self, volt_iny, volt_elec, corr_elec, resistencia):\n", " self.volt_iny = volt_iny\n", " self.volt_elec = volt_elec\n", " self.corr_elec = corr_elec\n", " self.resistencia = resistencia" ] }, { "cell_type": "code", "execution_count": 33, "id": "12b2d8f0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The min value of the exp_1 are: 0.6 V, length: 77\n", "The min value of the exp_2 are: 0.3 V, length: 85\n", "77 85\n", "77\n", "85\n", "True\n", "[0.573808, 0.668549, 0.772401, 0.869213, 0.973349, 1.071694, 1.173009, 1.27474, 1.372375, 1.471467, 1.568757, 1.672959, 1.776859, 1.8776, 1.965347, 2.064571, 2.151419, 2.243739, 2.32795, 2.419784, 2.508601, 2.592741, 2.677183, 2.768261, 2.852988, 2.93498, 3.019871, 3.10941, 3.193848, 3.277706, 3.360108, 3.445992, 3.533107, 3.616832, 3.679116, 3.766311, 3.8489, 3.934223, 4.016886, 4.090264, 4.178369, 4.247341, 4.296629, 4.383905, 4.464879, 4.5511, 4.644093, 4.728928, 4.781434, 4.892725, 4.971322, 5.060052, 5.185251, 5.194691, 5.262038, 5.357256, 5.458388, 5.544996, 5.60318, 5.675927, 5.757613, 5.844239, 5.910516, 6.025117, 6.090627, 6.175911, 6.266985, 6.351973, 6.424481, 6.592911, 6.674127, 6.741563, 6.831755, 6.913147, 7.000398]\n", "[0.573853, 0.667522, 0.773055, 0.872369, 0.97355, 1.074186, 1.167853, 1.272827, 1.3683, 1.472672, 1.569552, 1.675805, 1.769356, 1.86589, 1.944208, 2.018332, 2.088197, 2.15909, 2.220222, 2.275156, 2.355009, 2.439813, 2.553364, 2.649481, 2.717847, 2.788432, 2.873282, 2.976466, 3.050858, 3.131146, 3.22697, 3.317778, 3.398386, 3.487932, 3.575035, 3.661309, 3.763909, 3.864253, 3.941614, 4.043282, 4.12081, 4.20273, 4.280082, 4.37163, 4.440561, 4.539856, 4.623924, 4.683808, 4.75006, 4.844785, 4.948401, 5.019534, 5.09199, 5.184119, 5.246069, 5.346119, 5.423541, 5.508804, 5.592692, 5.677811, 5.766302, 5.8584, 5.936311, 6.080866, 6.150302, 6.232371, 6.324351, 6.402649, 6.494829, 6.574733, 6.642314, 6.733614, 6.813686, 6.892127, 6.970774]\n", "[0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0]\n" ] } ], "source": [ "\n", "path_1 = Path(\"/home/mgph/Desktop/?/MAESTRIA/HYDROGEN_PROJ/Data/Experimental-Data/EXP-A_20250917_163949.csv\") # Path for the experiment 20250917\n", "path_2 = Path(\"/home/mgph/Desktop/?/MAESTRIA/HYDROGEN_PROJ/Data/Experimental-Data/EXP-A_20250922_100524.csv\") # Path for the experiment 20250922\n", "# Import the experiment \"20250917\"\n", "df_1 = pd.read_csv(path_1, encoding=\"latin-1\")\n", "# Import the experiment \"20250922\"\n", "df_2 = pd.read_csv(path_2, encoding=\"latin-1\")\n", "#df_1.head() \n", "#df_1.head()\n", "\n", "cols_extract = [\"Voltaje Inyectado (V)\", \"Voltaje Electrodos (V)\", \"Corriente Electrodos (A)\", \"Resistencia\"]\n", "dt_exp1 = df_1[cols_extract].copy() #Exp 20250917\n", "dt_exp2 = df_2[cols_extract].copy() #Exp 20250922\n", "\n", "exp_1 = Experimento(\n", " volt_iny = dt_exp1[\"Voltaje Inyectado (V)\"], \n", " volt_elec = dt_exp1[\"Voltaje Electrodos (V)\"],\n", " corr_elec = dt_exp1[\"Corriente Electrodos (A)\"],\n", " resistencia = dt_exp1[\"Resistencia\"],\n", ")\n", "\n", "exp_2 = Experimento(\n", " volt_iny = dt_exp2[\"Voltaje Inyectado (V)\"], \n", " volt_elec = dt_exp2[\"Voltaje Electrodos (V)\"],\n", " corr_elec = dt_exp2[\"Corriente Electrodos (A)\"],\n", " resistencia = dt_exp2[\"Resistencia\"],\n", ")\n", "\n", "min_val_exp1 = min(exp_1.volt_iny)\n", "min_val_exp2 = min(exp_2.volt_iny)\n", "\n", "print(f\"The min value of the exp_1 are: {min_val_exp1} V, length: {len(exp_1.volt_iny)}\")\n", "print(f\"The min value of the exp_2 are: {min_val_exp2} V, length: {len(exp_2.volt_iny)}\")\n", "\n", "# Now we filter the data for extract only the values that we need to work with\n", "min_value = 0.6\n", "max_value = 8.0\n", "\n", "volt_iny_20250917 = exp_1.volt_iny.to_list() # voltage supply for exp_1\n", "volt_iny_20250922 = exp_2.volt_iny.to_list() # voltage supply for exp_2\n", "volt_elec_20250917 = exp_1.volt_elec.to_list() # from exp_1\n", "volt_elec_20250922 = exp_2.volt_elec.to_list() # from exp_2\n", "\n", "print(len(volt_iny_20250917), len(volt_iny_20250922))\n", "print(len(volt_elec_20250917))\n", "print(len(volt_elec_20250922))\n", "\n", "volt_iny_filt_20250917 = []\n", "volt_elec_filt_20250917 = []\n", "volt_elec_filt_20250922 = []\n", "\n", "for x in range(len(volt_iny_20250917)):\n", " if min_value <= volt_iny_20250917[x] <= max_value:\n", " volt_iny_filt_20250917.append(volt_iny_20250917[x])\n", " volt_elec_filt_20250917.append(volt_elec_20250917[x])\n", "\n", "for x in range(len(volt_iny_20250922)):\n", " if min_value <= volt_iny_20250922[x] <= max_value:\n", " volt_elec_filt_20250922.append(volt_elec_20250922[x])\n", "\n", "if len(volt_iny_filt_20250917) == len(volt_elec_filt_20250917) and len(volt_iny_filt_20250917) == len(volt_elec_filt_20250922):\n", " print(True)\n", "else:\n", " print(False)\n", "\n", "print(volt_elec_filt_20250917)\n", "print(volt_elec_filt_20250922)\n", "print(volt_iny_filt_20250917)\n", "\n", "\n", "\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }