1

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[1]['data'])
new_y=data[1]['data']-avg
plt.plot(data[1]['x'], (new_y),linestyle='-', color='c')
plt.xlabel('secs')
plt.ylabel(data[1]['id5'])
plt.xlim([min(data[1]['x']),max(data[1]['x'])+0.25])
plt.show()
[Python Plot](https://i.stack.imgur.com/Ye3LU.png)
[WTG Analyzer](https://i.stack.imgur.com/Lm3mf.png)
#The above plot matches exactly with the timewaveform of the WTG analyzer#

#Performing FFT#
x=data[1]['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()

[Python FFT Plot](https://i.stack.imgur.com/7BRwV.png)
[WTG Analyzers Autospectrum plot](https://i.stack.imgur.com/prJnW.png)

The time domain waveforms, which match are shown below:

enter image description here

enter image description here

The values which I get after executing the FFT doesn't match with that of the WTG analyzer (see below).

enter image description here

enter image description here

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.

Thanks

Matt Pitkin
  • 3,989
  • 1
  • 18
  • 32

1 Answers1

1

The WTG analyzer might be plotting the power spectrum. You could try using the scipy.signal.welch function to generate this (e.g., like this answer). E.g.,

from scipy.signal import welch

fs = 1 / T  # sampling frequency
f, pxx = welch(
    y,  # input data
    fs=fs,
    window="flattop",  # a flat window
    nperseg=len(y),  # just use one FFT the same length as the data
    scaling="spectrum"  # output the power spectrum rather than spectral density
)

plt.plot(f, pxx)

If I use some Gaussian white noise with a similar scale to your data, it seems to have a similar scale to the output of the WTG analyzer for regions where there are not spectral lines (although it's hard to tell exactly).

You may also want to play around with the window function used by welch as the WTG analyzer may use a different window, e.g., a Hann window.

Matt Pitkin
  • 3,989
  • 1
  • 18
  • 32
  • Hi Matt. Thanks for your input. I have tried this method and used hann as the window function (from the WTGs documentation). The peaks are somewhat similar to that of the WTGs but still the values are not matching. Also, I find that the X axis values are some what shifted towards the left when compared to the WTGs. – prashanth ramakrishnan Aug 07 '23 at 09:03