You are almost like Mike , but here is a different approach that is easier to understand. You can set a variable containing the filtered signal and return a 1d array Af, then apply the above formula, which is quite simple (the square of the sum of these amplitudes)
Filter out such signals
from scipy.signal import butter, lfilter def butter_bandpass(lowcut, highcut, fs, order=5): nyq = 0.5 * fs low = lowcut / nyq high = highcut / nyq b, a = butter(order, [low, high], btype='band') return b, a def butter_bandpass_filter(data, lowcut, highcut, fs, order=5): b, a = butter_bandpass(lowcut, highcut, fs, order=order) y = lfilter(b, a, data) return y
now itβs assumed that y is your original signal, and you need 5 Hz of energy in the signal,
#let fs = 250
source share