I am trying to filter this signal (download-zip):
import pandas as pd import matplotlib.pyplot as plt import numpy as np from scipy import signal df = pd.read_csv('signal.csv') sig = df['1'] b, a = signal.butter(4, 0.1, analog=False) sig_ff = signal.filtfilt(b, a, sig) plt.plot(sig, color='silver', lw=0.3, label='Original') plt.plot(sig_ff, color='red', lw=0.3, label='filtfilt') plt.xlim(0, sig.index[-1]) plt.legend() plt.show()
As you can see the noise reduction works but it also cuts off the impulse signal. I think the impulse frequenzy might be as high as the noise frequency. How can I filter out the noise of the signal without deleting the impulse?
To give a further explanation what I am trying to do: I am trying to determine the Impulse properties like raise time and half-life time. Although it is possible to do with the noise in the system, I thought it might influence the Impulse. The Impulse I have shown is one of the larger ones that I have. It gets harder and harder to analyze smaller Impulses like this one:
As you see, this Impulse is partly concealed by the noise signal. I was wondering if it would be possible to remove the noise sufficiently to also be able to analyze these small Impulses.
The Spectrum (
np.fft.rfft) of the larger Impulse (Gray/Red) is this:
import pandas as pd import matplotlib.pyplot as plt import numpy as np df = pd.read_csv('signal.csv') fft = pd.DataFrame(np.abs(np.fft.rfft(df['1']))) #y n = df['0'].size unit_freq = 1000000000 #Giga sample_rate = 10000000000 #10 GS/s freq_sample_fact = sample_rate/unit_freq freq = np.fft.rfftfreq(n, 1/freq_sample_fact) #x fft.index = freq fft.values = 0 fft.plot(grid = 1, color = (255/255,0,0), linewidth = 0.3, figsize = (10,5), legend = False, xlim = [fft.index, fft.index[-1]*0.8], ylim = 0, xticks = np.arange(0, freq_sample_fact/2 + 0.1, round(freq_sample_fact/2/10, 1))) ##plt.semilogy(fft) plt.xlabel('Frequenz / GHz') plt.ylabel('Signalstärke') plt.title('FFT') plt.show()
The FFT of the smaller Impulse (blue) is:
This is the spectrum of the noise:
I believe the y axis (Signalstärke) represents the "amount" of signal found on one frequency. The noise signal has a pretty high amount compared to the other ones because I took a wider time frame of the noise.