You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
355 KiB
355 KiB
None
<html lang="en">
<head>
</head>
</html>
Experimental Data-Analysis¶
In [ ]:
!pip install pandas
!pip install matplotlib
In [24]:
import pandas as pd
import numpy as np
from pathlib import Path
from dataclasses import dataclass
import math
import matplotlib.pyplot as plt
class Experimento:
def __init__(self, volt_iny, volt_elec, corr_elec, resistencia):
self.volt_iny = volt_iny
self.volt_elec = volt_elec
self.corr_elec = corr_elec
self.resistencia = resistencia
In [62]:
path_1 = Path("/home/mgph/Desktop/?/MAESTRIA/HYDROGEN_PROJ/Data/Experimental-Data/EXP-A_20250917_163949.csv") # Path for the experiment 20250917
path_2 = Path("/home/mgph/Desktop/?/MAESTRIA/HYDROGEN_PROJ/Data/Experimental-Data/EXP-A_20250922_100524.csv") # Path for the experiment 20250922
# Import the experiment "20250917"
df_1 = pd.read_csv(path_1, encoding="latin-1")
# Import the experiment "20250922"
df_2 = pd.read_csv(path_2, encoding="latin-1")
#df_1.head()
#df_1.head()
cols_extract = ["Voltaje Inyectado (V)", "Voltaje Electrodos (V)", "Corriente Electrodos (A)", "Resistencia"]
dt_exp1 = df_1[cols_extract].copy() #Exp 20250917
dt_exp2 = df_2[cols_extract].copy() #Exp 20250922
exp_1 = Experimento(
volt_iny = dt_exp1["Voltaje Inyectado (V)"],
volt_elec = dt_exp1["Voltaje Electrodos (V)"],
corr_elec = dt_exp1["Corriente Electrodos (A)"],
resistencia = dt_exp1["Resistencia"],
)
exp_2 = Experimento(
volt_iny = dt_exp2["Voltaje Inyectado (V)"],
volt_elec = dt_exp2["Voltaje Electrodos (V)"],
corr_elec = dt_exp2["Corriente Electrodos (A)"],
resistencia = dt_exp2["Resistencia"],
)
min_val_exp1 = min(exp_1.volt_iny)
min_val_exp2 = min(exp_2.volt_iny)
print(f"The min value of the exp_1 are: {min_val_exp1} V, length: {len(exp_1.volt_iny)}")
print(f"The min value of the exp_2 are: {min_val_exp2} V, length: {len(exp_2.volt_iny)}")
# Now we filter the data for extract only the values that we need to work with
min_value = 0.6
min_val_curr = 1.2
max_value = 8.0
# Voltage from the both experiments
volt_iny_20250917 = exp_1.volt_iny.to_list() # voltage supply for exp_1
volt_iny_20250922 = exp_2.volt_iny.to_list() # voltage supply for exp_2
volt_elec_20250917 = exp_1.volt_elec.to_list() # from exp_1
volt_elec_20250922 = exp_2.volt_elec.to_list() # from exp_2
#Current from the both experiments
curr_elec_20250917 = exp_1.corr_elec.to_list() # Current electrodes from the exp_1
curr_elec_20250922 = exp_2.corr_elec.to_list() # Current electrodes from the exp_2
#Resistance from the both experiments
res_20250917 = exp_1.resistencia.to_list() # Resistance from the exp_1
res_20250922 = exp_2.resistencia.to_list() # Resistance from the exp_2
print(len(volt_iny_20250917), len(volt_iny_20250922))
print(len(volt_elec_20250917))
print(len(volt_elec_20250922))
volt_iny_filt_20250917 = [] # Variable for the volt_iny filtered values
volt_elec_filt_20250917 = [] # Variable for the volt_elec filtered values from the exp_1
volt_elec_filt_20250922 = [] # Variable for the volt_elec filtered values from the exp_2
curr_elec_filt_20250917 = [] # Variable for the curr_elec filtered values from the exp_1
curr_elec_filt_20250922 = [] # Variable for the curr_elec filtered values from the exp_2
for x in range(len(volt_iny_20250917)):
if min_value <= volt_iny_20250917[x] <= max_value:
volt_iny_filt_20250917.append(volt_iny_20250917[x])
volt_elec_filt_20250917.append(volt_elec_20250917[x])
curr_elec_filt_20250917.append(curr_elec_20250917[x])
for x in range(len(volt_iny_20250922)):
if min_value <= volt_iny_20250922[x] <= max_value:
volt_elec_filt_20250922.append(volt_elec_20250922[x])
curr_elec_filt_20250922.append(curr_elec_20250922[x])
if len(volt_iny_filt_20250917) == len(volt_elec_filt_20250917) and len(volt_iny_filt_20250917) == len(volt_elec_filt_20250922):
print(True)
else:
print(False)
print(volt_elec_filt_20250917)
print(volt_elec_filt_20250922)
print(volt_iny_filt_20250917)
print(curr_elec_filt_20250917)
print(curr_elec_filt_20250922)
curr_elec_filt_20250917 = [] # Variable for the curr_elec filtered values from the exp_1
curr_elec_filt_20250922 = [] # Variable for the curr_elec filtered values from the exp_2
res_filt_20250917 = []
res_filt_20250922 = []
for x in range(len(volt_iny_20250917)):
if min_val_curr <= volt_iny_20250917[x] <= max_value:
curr_elec_filt_20250917.append(curr_elec_20250917[x])
res_filt_20250917.append(res_20250917[x])
for x in range(len(volt_iny_20250922)):
if min_val_curr <= volt_iny_20250922[x] <= max_value:
curr_elec_filt_20250922.append(curr_elec_20250922[x])
res_filt_20250922.append(res_20250922[x])
print(curr_elec_filt_20250917)
print(curr_elec_filt_20250922)
print(res_filt_20250917)
print(res_filt_20250922)
In [63]:
def _minlen(*list):
return min(len(lst) for lst in list)
# Ploting "volt_iny_filt_20250917 (x)" vs "volt_elec_20250917" - "volt_elec_20250922" (y)
n1 = _minlen(volt_iny_filt_20250917, volt_elec_filt_20250917, volt_elec_filt_20250922)
x1 = volt_iny_filt_20250917[:n1]
#y1 = [volt_elec_filt_20250917[i] - volt_elec_filt_20250922[i] for i in range(n1)]
y1 = volt_elec_filt_20250917
y2 = volt_elec_filt_20250922
plt.figure()
plt.plot(x1, y1, marker='o', linestyle='-', color='tab:blue', label='V_elec_20250917')
plt.plot(x1, y2, marker='o', linestyle='-', color='tab:red', label='V_elec_20250922')
plt.title('Comparative between the Voltage Electrodes and Voltage Supply')
plt.xlabel('Suply Voltage (V)')
plt.ylabel('ΔVoltage Electrodes (V)')
plt.grid(True)
plt.legend()
plt.show()
n1 = _minlen(volt_iny_filt_20250917, curr_elec_filt_20250917, curr_elec_filt_20250922)
x1 = volt_iny_filt_20250917[:n1]
#y1 = [volt_elec_filt_20250917[i] - volt_elec_filt_20250922[i] for i in range(n1)]
y1 = curr_elec_filt_20250917
y2 = curr_elec_filt_20250922
plt.figure()
plt.plot(x1, y1, marker='o', linestyle='-', color='tab:blue', label='C_elec_20250917')
plt.plot(x1, y2, marker='o', linestyle='-', color='tab:red', label='C_elec_20250922')
plt.title('Comparative between the Current Electrodes and Voltage Supply')
plt.xlabel('Suply Voltage (V)')
plt.ylabel('ΔCurrent Electrodes (A)')
plt.grid(True)
plt.legend()
plt.show()
n1 = _minlen(volt_iny_filt_20250917, res_filt_20250917, res_filt_20250922)
x1 = volt_iny_filt_20250917[:n1]
#y1 = [volt_elec_filt_20250917[i] - volt_elec_filt_20250922[i] for i in range(n1)]
y1 = res_filt_20250917
y2 = res_filt_20250922
plt.figure()
plt.plot(x1, y1, marker='o', linestyle='-', color='tab:blue', label='Resistance_20250917')
plt.plot(x1, y2, marker='o', linestyle='-', color='tab:red', label='Resistance_20250922')
plt.title('Comparative between the Resistance and Voltage Supply')
plt.xlabel('Suply Voltage (V)')
plt.ylabel('Δ Resistance (Ohms)')
plt.grid(True)
plt.legend()
plt.show()
n1 = _minlen(volt_iny_filt_20250917, res_filt_20250917, res_filt_20250922)
x1 = volt_iny_filt_20250917[:n1]
y1 = [res_filt_20250917[i] - res_filt_20250922[i] for i in range(n1)]
plt.figure()
plt.plot(x1, y1, marker='o', linestyle='-', color='tab:blue', label='ΔResistance = Resistance_20250917 - Resistance_20250922')
plt.title('Comparative between the Resistance and Voltage Supply')
plt.xlabel('Suply Voltage (V)')
plt.ylabel('ΔResistance (Ohms)')
plt.grid(True)
plt.legend()
plt.show()
res_filt_20250917 = []
res_filt_20250922 = []
volt_iny_filt_20250917 = []
min_val_curr = 2.5
for x in range(len(volt_iny_20250917)):
if min_val_curr <= volt_iny_20250917[x] <= max_value:
volt_iny_filt_20250917.append(volt_iny_20250917[x])
res_filt_20250917.append(res_20250917[x])
for x in range(len(volt_iny_20250922)):
if min_val_curr <= volt_iny_20250922[x] <= max_value:
res_filt_20250922.append(res_20250922[x])
n1 = _minlen(volt_iny_filt_20250917, res_filt_20250917, res_filt_20250922)
x1 = volt_iny_filt_20250917[:n1]
#y1 = [volt_elec_filt_20250917[i] - volt_elec_filt_20250922[i] for i in range(n1)]
y1 = res_filt_20250917
y2 = res_filt_20250922
plt.figure()
plt.plot(x1, y1, marker='o', linestyle='-', color='tab:blue', label='Resistance_20250917')
plt.plot(x1, y2, marker='o', linestyle='-', color='tab:red', label='Resistance_20250922')
plt.title('Comparative between the Resistance and Voltage Supply')
plt.xlabel('Suply Voltage (V)')
plt.ylabel('Δ Resistance (Ohms)')
plt.grid(True)
plt.legend()
plt.show()
n1 = _minlen(volt_iny_filt_20250917, res_filt_20250917, res_filt_20250922)
x1 = volt_iny_filt_20250917[:n1]
y1 = [res_filt_20250922[i] - res_filt_20250917[i] for i in range(n1)]
plt.figure()
plt.plot(x1, y1, marker='o', linestyle='-', color='tab:blue', label='ΔResistance = Resistance_20250917 - Resistance_20250922')
plt.title('Comparative between the Resistance and Voltage Supply')
plt.xlabel('Suply Voltage (V)')
plt.ylabel('ΔResistance (Ohms)')
plt.grid(True)
plt.legend()
plt.show()
pwr_consup_20250917 = []
pwr_consup_20250922 = []
volt_iny_filt_20250917_1 = []
min_val_curr_1 = 1.2
val_aux = 0
n = _minlen(volt_iny_20250917, volt_elec_filt_20250917, curr_elec_filt_20250917)
for x in range(n):
if min_val_curr_1 <= volt_iny_20250917[x] <= max_value:
volt_iny_filt_20250917_1.append(volt_iny_20250917[x])
pwr_consup_20250917.append((volt_elec_filt_20250917[x]*curr_elec_filt_20250917[x]))
n = _minlen(volt_iny_20250917, volt_elec_filt_20250922, curr_elec_filt_20250922)
for x in range(n):
if min_val_curr_1 <= volt_iny_20250922[x] <= max_value:
pwr_consup_20250922.append((volt_elec_filt_20250922[x]*curr_elec_filt_20250922[x]))
n1 = _minlen(volt_iny_filt_20250917_1, pwr_consup_20250917, pwr_consup_20250922)
x1 = volt_iny_filt_20250917_1[:n1]
#y1 = [volt_elec_filt_20250917[i] - volt_elec_filt_20250922[i] for i in range(n1)]
y1 = pwr_consup_20250917[:n1]
y2 = pwr_consup_20250922
plt.figure()
plt.plot(x1, y1, marker='o', linestyle='-', color='tab:blue', label='Power_Consumption_20250917')
plt.plot(x1, y2, marker='o', linestyle='-', color='tab:red', label='Power_Consumption_20250922')
plt.title('Comparative the Power Consumption (W) of both experiments')
plt.xlabel('Suply Voltage (V)')
plt.ylabel('Δ Power (W)')
plt.grid(True)
plt.legend()
plt.show()