feat: function to load scope data

This commit is contained in:
2025-10-21 20:26:35 -04:00
parent 142a043355
commit fe93a84ed8

View File

@@ -3,6 +3,8 @@
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
import csv
import io
# Components (same as Lab #2)
R1, C1 = 10e3, 1e-6
@@ -159,5 +161,31 @@ def plot_commutativity():
plt.tight_layout()
plt.show()
plot_commutativity()
exit()
#plot_commutativity()
#exit()
def load_scope_data(filename):
f = open(filename, 'r', newline='')
reader = csv.reader(f)
# 3. Read the data rows
timearr, v1arr, v2arr = [], [], []
for row in reader:
# Check if the row is not empty
if row:
try:
# Extract Time (column index 1) and Voltage (column index 2)
time = float(row[1])
v1 = float(row[2])
v2 = float(row[3])
# Add the pair to our data list
timearr.append(time)
v1arr.append(v1)
v2arr.append(v2)
except (ValueError, IndexError):
# This handles any malformed lines or conversion errors
print(f"Skipping malformed row: {row}")
return timearr, v1arr, v2arr
#t, v1, v2 = load_scope_data('~/Sync/org/School/EE3150/LAB3/data/2_2_a/100hz.csv')
#print (t1)