2

I saw similar questions partially solved but in matlab ref1, ref2, but I'm working with python. I am new processing signals and I am trying to remove harmonics from the following signals. enter image description here These are radio observations (at 3 and 7 THz). So first, I'd like to obtain the frequency of the predominant oscilation (visually, the period is about 1.78 s, so f=1/T), the four following enhancements are only tests and are not oscilations. Data resolution is 0.25 s (i.e. 4 points per second). I was trying to use np.fft.fft to find the predominant frequency but I can't figure out the way. So I was checking for 'Filtering' in scipy.signal but there are many filters.

  • Which filter would be more appropriate for this case and how can I used?
  • Is it necessary find the predominant frequency to eliminate it?
  • Is it necessary decompose the signal to extract the harmonics?

I'll keep checking the documentation but it would be helpful some lights!

Here my try

from scipy import fftpack 

d_step = 0.250

#Sampling para 3 THz
sample_freq_3T = fftpack.fftfreq(prosolar3.temp.size, d=d_step)
sig_fft_3T     = fftpack.fft(prosolar3.temp)

#Sampling para 7 THz
sample_freq_7T = fftpack.fftfreq(prosolar7.temp.size, d=d_step)
sig_fft_7T     = fftpack.fft(prosolar7.temp)

pidxs_3T = np.where(sample_freq_3T > 0)
freqs_3T = sample_freq_3T[pidxs_3T]
power_3T = np.abs(sig_fft_3T)[pidxs_3T]

pidxs_7T = np.where(sample_freq_7T > 0)
freqs_7T = sample_freq_7T[pidxs_7T]
power_7T = np.abs(sig_fft_7T)[pidxs_7T]

enter image description here

I'm trying to block the harmonics in the signal centered at 0.34 Hz (3 THz signal) and 0.64 Hz (7 THz signal)

I tried doing a passband, in order to substract from the original signal, but actually it does work

sig_fft_3T[np.abs(sample_freq_3T) < 0.24] = 0
sig_fft_3T[np.abs(sample_freq_3T) > 0.40] = 0

sig_fft_7T[np.abs(sample_freq_7T) < 0.57] = 0
sig_fft_7T[np.abs(sample_freq_7T) > 0.71] = 0

main_sig_3T = fftpack.ifft(sig_fft_3T)
main_sig_7T = fftpack.ifft(sig_fft_7T)

So, when ploting main_sig vs time and compare with the original signal, I get enter image description here

So, which filter can I use? Remembering that I want to remove the harmonics at 0.34 and 0.64 Hz from signal.

Is the better option to use a FFT? Are there another options?

Here the data

Community
  • 1
  • 1
nandhos
  • 681
  • 2
  • 16
  • 31
  • Your could try plotting the power spectral density (http://matplotlib.org/examples/pylab_examples/psd_demo2.html). For designing a filter look at http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.filtfilt.html#scipy.signal.filtfilt . Furthermore, it is usually easier to use `rfft()` and `rfftfreq()` than `fft()`. – Dietrich Aug 15 '15 at 18:47
  • @Dietrich, i did a try – nandhos Aug 17 '15 at 03:59

0 Answers0