Example of Input and Output graph
I am running some experiments on a vibration isolator whose performance varies in time and I am trying to find the process the data.
I have recorded a dataset comprising 3 columns: Time, Input_amplitude and Output_amplitude.
On a Windows machine I am using Anaconda Spyder 5.4 to process the date. First I defined a Pandas dataframe from the measured data, with the index column defined as Time, which is an equally spaced vector.
The transmissibility of a vibration isolator is computed by dividing the output signal FFT by the input signal FFT.
Since my vibration isolator performance varies in time, I assumed I need to use a spectrogram function in order to be able to visualize the change in time.
I created a function using the scipy library signal .spectrogram function, but I am not sure I have defined the function parameters correctly. I am interested only in the performance for frequencies up to 50 Hertz.
Following is the function code:
import numpy as np
from scipy import signal
def Calculate_T(Input_amplitude, Output_amplitude, Time):
#Compute the sampling frequency
FS = 1/(Time[1]-Time[0])
#Define the window range into which the dataset if divided (60 seconds)
Time_Domain = 60
#Define the overlapping time ratio between adjacent segments
Ovrl_Ratio = 0.5
#Compute the overlapping time range between adjacent segments
Ovrl_Time_Domain = Time_Domain*Ovrl_Ratio
#Compute the input and output spectrograms
Input_frequency, Input_time, spec_input - signal.spectrogram(Input_amplitude, FS, nperseg = Time_Domain, noverlap = Ovrl_Time_Domain, mode = 'magnitude']
Output_frequency, Output_time, spec_output - signal.spectrogram(Output_amplitude, FS, nperseg = Time_Domain, noverlap = Ovrl_Time_Domain, mode = 'magnitude']
#Notify the user regarding the length of the segments into which the dataset is split and the overlapping ratio
print ('The function splits the data into', Time_Domain*(Time[1]-Time[0]), 'seconds time segments with', Ovrl_Time_Domain*(Time[1]-Time[0]), 'seconds overlapping between adjacent time segments')
#Compute the transmissibility as the magnitude ratio of the output to input spectra
Transmissibility = np.abs(spec_output)/np.abs(spec_input)
#Return the frequency and time vectors and transmissibility
return Input_frequency, Input_time, Transmissibility}
I would like to know if I used correctly the spectrogram function, especially the nperseg parameters and a way to plot the spectrogram against the initial time vector
Thanks a lot!
Edit: Have added an image of an Input/Output example.