0
$\begingroup$

Goal:

I'm trying to model a waveform in the time-domain for pattern recognition.

My plan:

  1. Convert signal to frequency domain using FFT
  2. Reduce harmonics to hopefully isolate residual data, and make it zero (low pass filter)
  3. Use IFFT to find the deterministic part of the waveform.

My problem:

Although the modelling in shape is accurate, the amplitude of the waveform seems to be 'compressed'.

My question:

What is the reason for this and are there any techniques to fix the amplitude?

Code:

# Perform Fourier transform using scipy

from scipy import fftpack
from scipy.fft import fft, fftfreq

x = x[:1400]

SAMPLE_RATE = 100 # number of samples obtained in one second - 100Hz
DURATION = 14

# Number of samples in normalized_tone
N = SAMPLE_RATE * DURATION

yf = fft(x)
xf = fftfreq(N, 1 / SAMPLE_RATE)

plt.plot(xf, np.abs(yf))
plt.show()

for index,val in enumerate(yf[:1000],1):
    if (abs(val) > 1000):
        print(index)

ynew = yf # copy
ynew[1350:] = 0
print(ynew)
y = np.fft.ifft(yf)

plt.plot(y)
plt.plot(x)
plt.legend(['raw signal', 'filtered signal'])
plt.show(block=False)
enter preformatted text here

Results:

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Generally speaking zeroing FFT bins is not a good way to implement a low pass filter, see dsp.stackexchange.com/questions/6220/… . Lowpass filtering does reduce energy, so the output tends be smaller than the input and also less "wiggly" since high frequencies are removed $\endgroup$
    – Hilmar
    Oct 13 at 17:48
0
$\begingroup$

Parseval's theorem says the energy in a time domain signal and it's FFT will be identical. Remove energy from an FFT result, and that same amount of energy will be removed from its IFFT time domain result. Thus the reduced amplitude.

e.g. It's likely those high frequency artifacts you removed contributed to the amplitude of your original signal.

$\endgroup$
0
$\begingroup$

A low pass filter attenuate high frequencies, the low frequencies can only describe smooth features of the curve, this is why the depth of the narrow values reduced, while the other parts of the signal seems to be unchanged, this is why we call it a filter.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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