python-2.7signal-processinghighpass-filter

Applying Butterworth High Pass Filter


I have a problem with applying Butterworth High Pass Filter to my data. I would like to print filter for Bx and By matrix. As you can see I have both positive and negative values,

how to apply math.fabs() to Bx and By to get only positive values?

For my high pass filter I have those requirements:

Fc = 2 Hz

I would like to cut off values below 100 pT.

A part of my current code is:

plt.ylabel('Pico Tesle [pT]')
plt.xlabel('Time [ms]')
plt.grid()
plt.plot(time[51:-14], Bx[51:-14], label='Canal 1', color='r', linewidth=0.1, linestyle="-")
plt.plot(time2[1:-14], By[1:-14], label='Canal 3', color='b', linewidth=0.1, linestyle="-")
plt.legend(loc='upper right', frameon=False, )

And a chart is: enter image description here

UPDATE: I have used this function to generate absolute values for Bx and By matrix.

plt.subplot(413)
np.absolute(fft1)
plt.plot(time[51:-14], np.absolute(fft1), color='r', linewidth=0.1, linestyle='-')
plt.grid()

plt.subplot(414)
np.absolute(fft2)
plt.plot(time2[1:-14], np.absolute(fft2), color='b', linewidth=0.1, linestyle='-')
plt.grid()

What I received thanks to that is that all my measurements (here are atmospheric discharges) are only in positive values (pT - picoTesla). First plot shows Canal 1, second plot shows Canal 3, and the third plot shows both Canals (Channels) combined.

No, I need (I guess) use High Pass Filter to cut off all measurements below 100 pT. Any ideas? enter image description here


Solution

  • I have used this method to solve the problem.

    Wn = float(1)/HalfSampling
    b, a = signal.butter(3, Wn, 'high', analog=False)
    BxHPF = signal.filtfilt(b, a, Bxfft)
    ByHPF = signal.filtfilt(b, a, Byfft)
    plt.plot(BxTime, BxHPF, label='Canal 1', color='r', linewidth=0.5, linestyle="-")
    plt.plot(ByTime, ByHPF, label='Canal 3', color='b', linewidth=0.5, linestyle="-")