cleanup: Separate a single method for running 2.2.a
This commit is contained in:
@@ -240,20 +240,6 @@ def load_scope_data(filename):
|
||||
print(f"Skipping malformed row: {row}")
|
||||
return np.array(timearr), np.array(v1arr), np.array(v2arr)
|
||||
|
||||
def test_interp():
|
||||
A = 1.0
|
||||
f = 100
|
||||
xmax = 2.0
|
||||
w = 2*np.pi*f
|
||||
x = A * np.sin(w*t) * (t >= 0)
|
||||
y_full = conv_num(x, h, dt)
|
||||
y = y_full[:N] # keep same length as x
|
||||
t2, v1, v2 = load_scope_data('/home/hurricos/Sync/org/School/EE3150/LAB3/data/2_2_a/100hz.csv')
|
||||
yinterp = np.interp(t2, t, y)
|
||||
plt.plot(t, y, 'o')
|
||||
plt.plot(t2, yinterp, '-x')
|
||||
plt.show()
|
||||
|
||||
def calc_rmse(predicted_t, predicted_v, actual_t, actual_v): # The frame of reference is t1.
|
||||
actual_v_interp = np.interp(predicted_t, actual_t, actual_v)
|
||||
# Now, we can directly compare actual_v_interp with predicted_v.
|
||||
@@ -272,8 +258,8 @@ def plot_single_sinusoid_freq(freq):
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
|
||||
plot_single_sinusoid_freq(1)
|
||||
plot_single_sinusoid_freq(5)
|
||||
plot_single_sinusoid_freq(10)
|
||||
plot_single_sinusoid_freq(100)
|
||||
def run_2_2_a_conv_pred():
|
||||
plot_single_sinusoid_freq(1)
|
||||
plot_single_sinusoid_freq(5)
|
||||
plot_single_sinusoid_freq(10)
|
||||
plot_single_sinusoid_freq(100)
|
||||
|
||||
Reference in New Issue
Block a user