upd
This commit is contained in:
parent
6b66a2f3da
commit
d4983f45f2
2 changed files with 13 additions and 12 deletions
|
@ -1 +1 @@
|
|||
__version__ = '0.1.1'
|
||||
__version__ = '0.1.2'
|
||||
|
|
|
@ -9,7 +9,7 @@ from scipy.stats import linregress
|
|||
from scipy.optimize import curve_fit
|
||||
|
||||
|
||||
def filter_signal_by_modes(time, signal, num_modes=1, bandwidth_factor=0.1):
|
||||
def filter_signal_by_modes(time, signal, num_modes=1, bandwidth_factor=0.1, nyquist=False):
|
||||
"""
|
||||
Filtre un signal pour extraire ses composantes fréquentielles dominantes.
|
||||
|
||||
|
@ -68,16 +68,17 @@ def filter_signal_by_modes(time, signal, num_modes=1, bandwidth_factor=0.1):
|
|||
lowcut = freq - bandwidth
|
||||
highcut = freq + bandwidth
|
||||
|
||||
# Éviter les fréquences négatives ou supérieures à la fréquence de Nyquist
|
||||
nyq = 0.5 * fs
|
||||
if lowcut <= 0:
|
||||
lowcut = 0.01
|
||||
if highcut >= nyq:
|
||||
highcut = nyq - 0.01
|
||||
|
||||
# Créer le filtre Butterworth
|
||||
low = lowcut / nyq
|
||||
high = highcut / nyq
|
||||
if nyquist:
|
||||
# Éviter les fréquences négatives ou supérieures à la fréquence de Nyquist
|
||||
nyq = 0.5 * fs
|
||||
if lowcut <= 0:
|
||||
lowcut = 0.01
|
||||
if highcut >= nyq:
|
||||
highcut = nyq - 0.01
|
||||
|
||||
# Créer le filtre Butterworth
|
||||
lowcut = lowcut / nyq
|
||||
highcut = highcut / nyq
|
||||
b, a = butter(4, [low, high], btype='band')
|
||||
|
||||
# Appliquer le filtre (filtfilt pour éviter le déphasage)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue