-1

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

JRE
  • 2,240
  • 1
  • 11
  • 20
  • 1
    Generally speaking zeroing FFT bins is not a good way to implement a low pass filter, see https://dsp.stackexchange.com/questions/6220/why-is-it-a-bad-idea-to-filter-by-zeroing-out-fft-bins . Lowpass filtering does reduce energy, so the output tends be smaller than the input and also less "wiggly" since high frequencies are removed – Hilmar Oct 13 '21 at 17:48

2 Answers2

0

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.

hotpaw2
  • 35,346
  • 9
  • 47
  • 90
0

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.

Bob
  • 2,348
  • 4
  • 11