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

data = uff_file.read_sets()

#Taking the second dataset from the data dictionary and plotting the timewaveform

plt.plot(data[1]['x'], (new_y),linestyle='-', color='c')

Python Plot

WTG Analyzer

The above plot matches exactly with the timewaveform of the WTG analyzer#

#Performing FFT#
N=262144 #no of samples
T=1.024/25600 #time interval

Python FFT Plot

WTG Analyzers Autospectrum plot

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[1]['data'],  # input data
plt.plot(f, pxx)

welch power spectrum

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.

  • $\begingroup$ Can you share the data? $\endgroup$
    – Jdip
    Aug 7, 2023 at 10:39

1 Answer 1


The correct scaling for the Power Spectrum (which is, based on the title of BKV's WTG analyzer plot, what is being computed) is:

$$\texttt{Power Spectrum} = \cfrac{2|X|^2}{S}$$ with:

$|X|^2=X\cdot X^*$ the squared spectrum magnitude

$S=\displaystyle\left(\sum_{i=1}^{N} w_{i}\right)^{2}$ the scaling factor defined as square of the sum of samples of window function.

My guess is they are computing a windowed fft. Your problem is to find which window is being used by trying out a few. For all we know they might also be computing an averaged Power Spectrum (try out a few values for nperseg).

  • $\begingroup$ Thanks. I have tried various npserseg values. But still I can't match these two graphs. $\endgroup$ Aug 10, 2023 at 11:08
  • $\begingroup$ Curious, why do you want to match them? Pick a window and scale the right way! $\endgroup$
    – Jdip
    Aug 10, 2023 at 13:23
  • $\begingroup$ For the sake of validation, I want to match both the graphs. Or, are there any other ways to validate the power spectrum? $\endgroup$ Aug 11, 2023 at 4:10
  • $\begingroup$ Why don’t you try with a few sinusoids with different amplitudes? Such as $A_1\cdot \sin(2\pi f_1n) + A_2\cdot \sin(2\pi f_2n) …$ See if you recover $A_1$ and $A_2$ in your power spectrum. $\endgroup$
    – Jdip
    Aug 11, 2023 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.