TL;DR I want to find theta_1
in the system below from theta_2
, without knowing other parameters.
Following this question, I have modeled the system below
in Modelica language and solved by OpenModelica generating a CSV file:
"time", "theta1", "theta2"
0, 0, 0
0.02, -6.40192, -7.79226
0.04, -12.8038, -12.1422
0.06, -19.2058, -18.1304
0.08, -25.6077, -26.7809
You may find the Modelica code and CSV here in this GitHub Gist. What I want to do is to filter the theta_2
to get theta_1
without knowing the sample rates for tau
and theta_1
, compliant element k
and angular inertia J
. I speculate that the rotational spring would leave a distinguishable footprint in the frequency domain spectrum of the angle data theta_2
.
what I have done so far:
- Importing the data as a Pandas data frame:
import pandas as pd
df = pd.read_csv("exportedVariables.csv")
df.head()
- plotting the data:
import matplotlib.pyplot as plt
plt.plot(df["time"], df["theta2"], df["time"], df["theta1"])
plt.xlabel("Time (sec)")
plt.ylabel("Angle (deg)")
- calculating the Fast Fourier Transform (FFT) of
theta_2
data:
import numpy as np
from scipy.fftpack import fft
theta2_scipy_fft = fft(df["theta2"])
N = len(df.index)
time = df["time"].values
dt = np.mean(np.diff(time))
frequency = np.linspace(0.0, 1.0 / (2.0 * dt), N // 2)
plt.plot(frequency, 2.0 / N * np.abs(theta2_scipy_fft[0: N // 2]))
plt.xscale("log")
plt.xlabel("Frequency (Hz)")
plt.ylabel("Amplitude (dB)")
However, what I see here is the first two dominant amplitudes in the spectrogram are actually the sample rate by which the random value of tau
and omega_1
are generated and I can't find the pick I was looking for. So I don't know how to go forward from here. I would appreciate if you could help me know if it is possible to filter out the disturbance caused by the rotational spring without knowing the system and how it can be implemented.