I have an UFF file which consists of Vibration data. The objective is to convert the timewaveform signal to frequency domain. I have written a python script to convert the timewave form signal to frequency domain using scipy.fft. I have an UFF file. I am importing that uff using pyuff. I am validating the output of my python script with another software's output (BKV's WTG analyzer)
#Python Script# import pandas as pd import numpy as np import matplotlib.pyplot as plt import pyuff from scipy.fft import fft, fftfreq uff_file=pyuff.UFF('new1.uff') data = uff_file.read_sets() #Taking the second dataset from the data dictionary and plotting the timewaveform avg=np.mean(data['data']) new_y=data['data']-avg plt.plot(data['x'], (new_y),linestyle='-', color='c') plt.xlabel('secs') plt.ylabel(data['id5']) plt.xlim([min(data['x']),max(data['x'])+0.25]) plt.show()
The above plot matches exactly with the timewaveform of the WTG analyzer#
#Performing FFT# x=data['x'] y=new_y N=262144 #no of samples T=1.024/25600 #time interval yf=(abs(fft(y))) xf=abs(fftfreq(N,T)) plt.plot(xf,yf) plt.grid() plt.show()
The values which I get after executing the FFT doesn't match with that of the WTG analyzer. I have tried all possible things like dividing the output of y axis with the number of samples, rfft, etc. But nothing is matching the output of the WTG analyzer. I want to have the exact output as that of the WTG Analyzer.
I have also tried using the welch's method with the below code.
fs = 1/(T) # sampling frequency f, pxx = welch( data['data'], # input data fs=fs, window="hann", nperseg=len(data['data']), scaling="spectrum" ) plt.grid() plt.plot(f, pxx)
The peaks are occurring almost at the correct frequencies (python's output is somewhat shifted towards the left side when compared to the WTGs output). But the Y axis values are not matching. At some frequency range the python output is less than the WTG and vice versa.